Thursday, April 23, 2015

Installing full LAMP stack + phpmyadmin on Ubntu 14.04 LTS AWS EC2 instance

Just a step by step tutorial:

1. sudo apt-get update
2. sudo apt-get install apache2
3. Check if apache installed correctly by visiting your servers public IP address:

http://your-servers-ip

4. sudo apt-get install mysql-server php5-mysql #installing mysql
5. sudo mysql_install_db #create database directory structure
6. sudo mysql_secure_installation #run secure installation (just follow the instructions)
7. sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt php5-curl php5-json #install php and some extensions (optionally), like mcrypt, curl and json

You can view all available php5 extensions by running this command in terminal: 

apt-cache search php5-

8. sudo nano /etc/apache2/mods-enabled/dir.conf #place index.php on the first position (instead of index.html by default)

Finally it should look like  

<IfModule mod_dir.c>
    DirectoryIndex index.php index.html index.cgi index.pl # and so on...
</IfModule>

9. sudo service apache2 restart
10. In order to install phpmyadmin you should have mcrypt php5 module installed and activated

sudo apt-get install php5-mcrypt #downloading mcrypt extension

sudo php5enmod mcrypt #activating mcrypt extension

11. sudo apt-get install phpmyadmin
12. sudo service apache2 restart

Now if you will visit http://your-public-ip/phpmyadmin, phpmyadmin page should appear BUT for me it was 404 not found error. To fix this bug you need to follow steps below:

13. sudo ln -s /usr/share/phpmyadmin /var/www/html #create symlink
14. sudo nano /etc/phpmyadmin/apache.conf #open phpmyadmin apache config file and add this line to the end of a file:

Include /etc/phpmyadmin/apache.conf

15. sudo service apache2 restart #restart apache server and try to visit http://your-public-ip/phpmyadmin

2 comments:

  1. Most comprehensive guide have seen on this topic. I have used it countless times.

    ReplyDelete