Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
install LAMP stack in Amazon AMI
  1. Update packages
$ sudo yum update -y
  1. Install Apache, mysql and php.
$ sudo yum update http24 php70 mysql56-server php70-mysqlnd -y
  1. Start the Apache Web Server.
$ sudo service httpd start
  1. Use the chkconfig command to configure the Apache web server to start at each system boot.
$ sudo chkconfig httpd on

Reference

Tutorial: Install a LAMP Web Server with the Amazon Linux AMI

  1. Add user to apache group.
$ sudo usermod -a -G apache ec2-user
  1. Logout to instance. And Login to verify your membership. You are a member if you see apache when running 'groups' command
$ exit
$ ssh -i some.pem ec2-user@domain.com
$ groups
ec2-user wheels apache
  1. Change the group ownership of /var/www and its contents to the apache group.
$ sudo chown -R ec2-user:apache /var/www
  1. To add group write permissions and to set the group ID on future subdirectories, change the directory permissions of /var/www and its subdirectories.
$ sudo chmod 2775 /var/www
$ find /var/www -type d -exec sudo chmod 2775 {} \;
  1. To add group write permissions, recursively change the file permissions of /var/www and its subdirectories:
$ find /var/www -type f -exec sudo chmod 0664 {} \;

Reference

Tutorial: Install a LAMP Web Server with the Amazon Linux AMI

  1. Start the MySQL server.
$ sudo service mysqld start
  1. Run mysql_secure_installation. And type Y for all prompts.
$ sudo mysql_secure_installation
  1. (Optional) If you do not plan to use the MySQL server right away, stop it. You can restart it when you need it again.
$ sudo service mysqld stop
  1. (Optional) If you want the MySQL server to start at every boot, type the following command.
$ sudo chkconfig mysqld on

Reference

Tutorial: Install a LAMP Web Server with the Amazon Linux AMI

Note: Running phpmyadmin in a non secure http connection is not recommended as username and password are not encrypted.

  1. Install the required dependencies.
$ sudo yum install php70-mbstring.x86_64 php70-zip.x86_64 -y
  1. Restart Apache.
$ sudo service httpd restart
  1. Navigate to the Apache document root at /var/www/html.
$ cd /var/www/html
  1. Select a source package for the latest phpMyAdmin release from https://www.phpmyadmin.net/downloads. To download the file directly to your instance, copy the link and paste it into a wget command, as in this example:
$ wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz
  1. Create a phpMyAdmin folder and extract the package into it using the following command.
$ mkdir phpMyAdmin && tar -xvzf phpMyAdmin-latest-all-languages.tar.gz -C phpMyAdmin --strip-components 1
  1. Delete the phpMyAdmin-latest-all-languages.tar.gz tarball.
$ rm phpMyAdmin-latest-all-languages.tar.gz
  1. (Optional) If the MySQL server is not running, start it now.
$ sudo service mysqld start
  1. In a web browser, type the URL of your phpMyAdmin installation. This URL is the public DNS address (or the public IP address) of your instance followed by a forward slash and the name of your installation directory. For example: http://my.public.dns.amazonaws.com/phpMyAdmin

Reference

Tutorial: Install a LAMP Web Server with the Amazon Linux AMI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment