LAMP involves four different technologies. These are Linux, Apache, MySQL, and PHP. However, we have already covered the Linux portion with our EC2 server. Now we can focus on the other three facets of LAMP. The following series of steps will help you quickly identify, install, and setup LAMP. If you run into any problems with your specific install. Because we want to cover as many variations of versions and libraries as possible.
Installing LAMP
- Start by logging into your server on your EC2 instance
- Then Install all the yum components for LAMP with:
sudo yum install -y httpd24 php56 mysql55-server php56-mysqlnd
- Now we can start the service type the following command:
sudo service httpd start
- However, we need to set up a “www” security group:
sudo groupadd www
- Before proceeding, we need to add ec2-user to the www group:
sudo usermod -a -G www ec2-user
- At this point, log out and log back in to get the new permissions
- Set the web folder ownership:
sudo chown -R root.www /var/www
- Set all the folder permissions:
find /var/www -type d -exec sudo chmod 2775 {} \;
- Set all the file permissions:
find /var/www -type f -exec sudo chmod 0664 {} \;
- Setup a PHP test page:
echo "<?php phpinfo(); ?>" >> /var/www/html/phpinfo.php
- At this point, we should be able to test our server. Go ahead and open up an internet browser and enter the following address:
http://{ipaddress}/phpinfo.php
- Once done go ahead and delete the file on the server:
rm /var/www/html/phpinfo.php
- Now we need to install SSL support so that we can enable HTTPS later:
sudo yum install -y mod24_ssl
- Finally, restart the service to enable these components:
sudo service httpd restart
Next Steps
Once you have done the steps above you will have a LAMP instance with the following components setup and running:
- Apache Web Server version 2.4
- PHP 5.6
- MySQL 5.5
To use different software releases, you will need to look up the components associated yum packages. Then all you need to do is adjust the commands to use a particular version.
Further Reading
In addition, you can always check out some more of our articles to learn more:
To create an AWS Ec2 instance you can do so by following these steps:
[sgmb id=”1″]