Installing LAMP Stack on Ubuntu Instance
Deploying Play Framework in EC2 - part # 2
kamarul kawnayeen
Preface
This is the second part of deploying playframewok in EC2 tutorial series. In the
previous part, I’ve showed how to setup a virtual server on AWS. I setup ubuntu
14.04 LTS there. In this part I’m going to complete setting up LAMP stack.
Considering LAMP, I will use :-
➢ Apache as web server
➢ MySQL as database
➢ PHP as programming language
First, we are going to configure corresponding security
group. The security group acts as a firewall allowing you to
choose which protocols and ports are open to computers
over the internet.
Configuring Security Group
select your instance & check the security group associated with it
click “Security Groups” from left panel and select the
one associated with your instance
Click on Inbound and then Click Edit
Add this 4 rules.
The Custom TCP
Rule (port 9000)
will be needed for
play application
Setting up Apache
Connect with your remote server using terminal & update your ubuntu
sudo apt-get update
sudo apt-get dist-upgrade
Install apache using the following command :
sudo apt-get install apache2
Now, we have to enable .htaccess file. To do so we have to edit the “000-
default.conf” file at “/etc/apache2/sites-available/” directory
So, move to the sites-available directory and execute the following command
sudo nano 000-default.conf
look for /var/www/html directory and make sure it contains AllowOverride
All
save & exit the nano editor via CTRL-X, “y” and Enter
Enable the rewrite module in Apache :
sudo a2enmod rewrite
Install PHP 5
sudo apt-get install libapache2-mod-php5
Restart Apache
sudo /etc/init.d/apache2 restart
Type the ip address of your instance & check
whether apache is running
Allow ubuntu user to work with the /var/www/html directory:
sudo adduser ubuntu www-data
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R g+rw /var/www/html
Now we are going to test php installation. Go to the /var/www/html directory
and create a file name phptest.php
cd /var/www/html
sudo vi phptest.php
hit i key to enter insert mode and just call the phpinfo() function
hit esc to exit insert mode and type :wq to save and quit vi editor
type
ip address of your
instance/html/phptest.
php
at your browser to test
php
Installing MySQL
try
sudo apt-get install mysql-server
sudo apt-get install php5-mysql
Installing PHPMyAdmin
sudo apt-get install phpmyadmin
select apache2 web server
select yes while asking for configuring database for phpmyadmin
Enter password of database’s administrative user and hit Ok
Enter password for phpmyadmin (optional)
Confirming the password
Now we have to link phpmyadmin at /var/www/html directory
sudo ln -s /usr/share/phpmyadmin /var/www/html
check out phpmyadmin
at your browser

Installing Lamp Stack on Ubuntu Instance

  • 1.
    Installing LAMP Stackon Ubuntu Instance Deploying Play Framework in EC2 - part # 2 kamarul kawnayeen
  • 2.
    Preface This is thesecond part of deploying playframewok in EC2 tutorial series. In the previous part, I’ve showed how to setup a virtual server on AWS. I setup ubuntu 14.04 LTS there. In this part I’m going to complete setting up LAMP stack. Considering LAMP, I will use :- ➢ Apache as web server ➢ MySQL as database ➢ PHP as programming language
  • 3.
    First, we aregoing to configure corresponding security group. The security group acts as a firewall allowing you to choose which protocols and ports are open to computers over the internet. Configuring Security Group
  • 4.
    select your instance& check the security group associated with it
  • 5.
    click “Security Groups”from left panel and select the one associated with your instance
  • 6.
    Click on Inboundand then Click Edit
  • 7.
    Add this 4rules. The Custom TCP Rule (port 9000) will be needed for play application
  • 8.
  • 9.
    Connect with yourremote server using terminal & update your ubuntu sudo apt-get update sudo apt-get dist-upgrade
  • 10.
    Install apache usingthe following command : sudo apt-get install apache2
  • 11.
    Now, we haveto enable .htaccess file. To do so we have to edit the “000- default.conf” file at “/etc/apache2/sites-available/” directory So, move to the sites-available directory and execute the following command sudo nano 000-default.conf
  • 12.
    look for /var/www/htmldirectory and make sure it contains AllowOverride All save & exit the nano editor via CTRL-X, “y” and Enter
  • 13.
    Enable the rewritemodule in Apache : sudo a2enmod rewrite Install PHP 5 sudo apt-get install libapache2-mod-php5 Restart Apache sudo /etc/init.d/apache2 restart
  • 14.
    Type the ipaddress of your instance & check whether apache is running
  • 15.
    Allow ubuntu userto work with the /var/www/html directory: sudo adduser ubuntu www-data sudo chown -R www-data:www-data /var/www/html sudo chmod -R g+rw /var/www/html
  • 16.
    Now we aregoing to test php installation. Go to the /var/www/html directory and create a file name phptest.php cd /var/www/html sudo vi phptest.php
  • 17.
    hit i keyto enter insert mode and just call the phpinfo() function hit esc to exit insert mode and type :wq to save and quit vi editor
  • 18.
    type ip address ofyour instance/html/phptest. php at your browser to test php
  • 19.
  • 20.
    try sudo apt-get installmysql-server sudo apt-get install php5-mysql
  • 21.
  • 22.
  • 23.
  • 24.
    select yes whileasking for configuring database for phpmyadmin
  • 25.
    Enter password ofdatabase’s administrative user and hit Ok
  • 26.
    Enter password forphpmyadmin (optional)
  • 27.
  • 28.
    Now we haveto link phpmyadmin at /var/www/html directory sudo ln -s /usr/share/phpmyadmin /var/www/html
  • 29.