Installation of LAMP Server on Amazon Linux EC2

0
240
LAMP-EC2

These steps will help you to install Apache web server with PHP and MySQL on Amazon Linux EC2 instance.

Important

This installation will not work on Ubuntu or Red Hat Enterprise Linux instance.

Prerequisites

Your Instance is configured with security group to allow SSH (port 22), HTTP (port 80), and HTTPS (port 443) connections.

Steps are following:

  1. Login to Shell
  2. Update the packages.[ec2-user ~]$ sudo yum update -y
  3. [ec2-user ~]$ sudo yum install -y httpd24 php70 mysql56-server php70-mysqlnd
  4. Start the web server.[ec2-user ~]$ sudo service httpd start
  5. Use the chkconfig command to configure the Apache web server to start at each system boot.[ec2-user ~]$ sudo chkconfig httpd on

Setup database server

There are following steps to setup the database server

  1. Start the MySQL server.[ec2-user ~]$ sudo service mysqld start
  2. Run mysql_secure_installation.[ec2-user ~]$ sudo mysql_secure_installation
    1. When prompted, type a password for the root account.
      1. Enter the current root password. By default root account does not have password set. In that case Press Enter.
      2. Type Y to set a password, and type a secure password twice.
    2. Press Y to remove the anonymous user accounts.
    3. Press  Y to disable the remote root login.
    4. Press Y to remove the test database.
    5. Press Y to reload the privilege tables and save your changes.
  3. If you want the MySQL server to start at every boot, type the following command.[ec2-user ~]$ sudo chkconfig mysqld on

Installation of phpMyAdmin

phpMyAdmin is database management tool by which you can view and edit the MySQL databases on your Server. These are following steps to install phpMyAdmin on Amazon Linux EC2 instance.

  1. Log in to EC2 instance using SSH.
  2. Install the dependencies.[ec2-user ~]$ sudo yum install php70-mbstring.x86_64 php70-zip.x86_64 -y
  3. Restart Apache Server.[ec2-user ~]$ sudo service httpd restart
  4. Navigate to root directory at /var/www/html.[ec2-user ~]$ cd /var/www/html
  5. Download source package for the latest phpMyAdmin release from https://www.phpmyadmin.net/downloads.[ec2-user html]$ wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz
  6. Create a phpMyAdmin folder and extract the package using the following command.[ec2-user html]$ mkdir phpMyAdmin && tar -xvzf phpMyAdmin-latest-all-languages.tar.gz -C phpMyAdmin --strip-components 1
  7. Delete the phpMyAdmin-latest-all-languages.tar.gz tarball.[ec2-user html]$ rm phpMyAdmin-latest-all-languages.tar.gz
  8. If the MySQL server is not running, start it now.[ec2-user ~]$ sudo service mysqld start
  9. Access the URL of your web server.

LEAVE A REPLY

Please enter your comment!
Please enter your name here