Amazon AWS EC2 service offers high scalable cloud servers. It operates just like a Linux server and you may install packages and setup domains. The EC2 service offers range of instance types depending on the hardware capacity. It’s really quick to launch a Linux server with Apache or nginx as web server with required PHP versions.
Amazon AWS EC2 AMI Linux Setup with Apache2.4 PHP 7.x and MySQL.
Please follow the below steps to configure.
SSH connect to EC2 instance via terminal
ssh -i /path/to/key.pem [email protected]
Update server with latest packages if required (its optional)
sudo yum update
Install Apache and PHP and MySQL
PHP7.1
sudo yum install -y httpd24 php71 mysql56-server php71-mysqlnd
PHP7.0
sudo yum install -y httpd24 php70 mysql56-server php70-mysqlnd
PHP5.6
sudo yum install -y httpd24 php56 mysql56-server php56-mysqlnd
Restart Apache and MySQL services
sudo service mysqld start
sudo service httpd start
Automated service enabled after reboot
sudo chkconfig mysqld on
sudo chkconfig httpd on
MySQL root password setup
mysqladmin -u root password [yourpassword]
([yourpassword] – is the password)
now try mysql root login via terminal
mysql -u root -p
> enter password
Virtual Host domain setup
Switch as super user sudo -s
cd /etc/httpd/conf.d
nano vhosts.conf
<VirtualHost *:80>
ServerName yourdomain.com
#ServerAlias www.yourdomain.com yourdomain.net
DocumentRoot /var/www/vhosts/yourdomain.com/html
ServerAdmin [email protected]
ErrorLog /var/www/vhosts/logs/error_log
<Directory /var/www/vhosts/yourdomain.com/html>
AllowOverride All
</Directory>
</VirtualHost>
service httpd restart
Its all ready now.