Installing a LAMP Web Server on AWS EC2 ubuntu instance
Execute following command to update ubuntu
Ubuntu is based on Debian, which uses apt not yum which is what Red Hat uses. The Debian equivalent of:
Ubuntu is based on Debian, which uses apt not yum which is what Red Hat uses. The Debian equivalent of:
yum update -y
Would be:
sudo apt-get update
once ubuntu has been updated, run following command to install complete LAMP stack on ubuntu, enter yes or ‘y’ when prompted followed by your MySQL password for root user twice, take note of this password for connecting you your databases later.
once ubuntu has been updated, run following command to install complete LAMP stack on ubuntu, enter yes or ‘y’ when prompted followed by your MySQL password for root user twice, take note of this password for connecting you your databases later.
1. Install Apache
sudo apt-get install apache2
To test your web server. In a web browser, enter the public DNS address (or the public IP address) of your instance; you should see the Apache test page
2. Install PHP
sudo apt-get install php5 libapache2-mod-php5
3. Install MySQL
sudo apt-get install mysql-server
4. Install phpMyAdmin
sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
Enter ‘y’ when prompted then select apache2 when prompted followed by no when asked to use default databases.
After the installation has finished you will need to execute a few commands to allow for you to access /phpmyadmin in your browser, you will need to add phpmyadmin to the apache configuration by executing the following command.
sudo nano /etc/apache2/apache2.confThis will bring up the apache2 config file, use ‘CTRL’ + ‘V’ on mac to scroll to the bottom of the file. Once you have done that paste the following and hit ‘CTRL’ + ‘X’ to exit then enter ‘y’ to save then exit.
# Include web access to phpmyadmin
Include /etc/phpmyadmin/apache.conf
Restart apache for changes to take effect.
sudo service apache2 restart
If the following step went off without a hitch you should be able to see the following screens.
In a web browser, enter the URL of your
phpMyAdmin
installation. This URL is the public DNS address of your instance followed by a forward slash and phpmyadmin. For example:http://my.public.dns.amazonaws.com
/phpmyadmin
You should see the phpMyAdmin login page.
To test your LAMP web server
If your server is installed and running, and your file permissions are set correctly, your
ec2-user
account should be able to create a simple PHP file in the /var/www/html
directory that will be available from the Internet.- Create a simple PHP file in the Apache document root.
[ec2-user ~]$
echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php
TipIf you get a "Permission denied
" error when trying to run this command, try logging out and logging back in again to pick up the proper group permissions that you configured in To set file permissions. - In a web browser, enter the URL of the file you just created. This URL is the public DNS address of your instance followed by a forward slash and the file name. For example:
http://
my.public.dns.amazonaws.com
/phpinfo.phpYou should see the PHP information page. - Delete the
phpinfo.php
file. Although this can be useful information to you, it should not be broadcast to the Internet for security reasons.
[ec2-user ~]$
rm /var/www/html/phpinfo.php
Finally to start your web development you need version controller, i used to be filezilla, here is the video how to configure filezilla.
How to Use Filezilla with Amazon Web Services EC2
How to Use Filezilla with Amazon Web Services EC2
How to completely remove PHP?
sudo apt-get remove apache2*
sudo apt-get remove phpmyadmin
sudo apt-get remove mysql-server
sudo apt-get remove php.*
chmod 600 path/to/yourkeyname.pem
ssh -i path/to/yourkeyname.pem ubuntu@54.213.166.232
sudo apt-get update
sudo apt-get install lamp-server^
sudo apt-get install phpmyadmin
sudo nano /etc/apache2/apache2.conf
# Include web access to phpmyadmin
Include /etc/phpmyadmin/apache.conf
sudo service apache2 restart
Since you didn't choose an answer, maybe the problem is still open and it is similar to mine (PHP is not working - therefore phpmyadmin doesn't work).
I upgraded from 15.10 to 16.04 yesterday and also got PHP7 (instead of 5) in the process. localhost worked for me, but the public_html directory in my home directory didn't.
Problem was the upgrade of PHP (in localhost I had an html-document which loaded perfectly, but PHP didn't work as expected). I had to edit /etc/apache2/mods-enabled/php7.conf where PHP was disabled ( line 23: php_admin_value engine Off ) just had to make it a comment (with the editor of your choice add a "#" at the start of the line):
# php_admin_value engine Off
and restart the apache: sudo service apache2 restart
Comments
Post a Comment