How to install apache, php, mysql and phpmyadmin in Ubuntu

Recommended Ubuntu book

Installing LAMP (Linux, Apache, Mysql, Php) in Ubuntu is pretty easy. Follow the following steps.

 

Open the terminal window and type:


sudo apt-get install apache2

This would install apache, which you could test by typing http://localhost/ in the browser. It will give you a successful message if it works.


sudo apt-get install php5 libapache2-mod-php5

This would install the latest stable version of php5 and apache mod. Now lets create a sample php file to see if it works:


sudo gedit /var/www/phpinfo.php

Once the new gedit window opens, type:



Save the file and restart apache for php to kick in:


sudo /etc/init.d/apache2 restart

Now go to http://localhost/phpinfo.php in the browser and it should show all the php settings.

We still need mysql, these commands will install it:


sudo apt-get install mysql-server

Next, we need apache mode, php5-mysql and phpmyadmin (if you want, it gets pretty handy):


sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin

Next, enable mysql in for php by editing php.ini file:


sudo gedit /etc/php5/apache2/php.ini

and uncomment the line


;extension=msql.so

by removing ‘;’ symbol in the beginning. Save the file and restart apache again:


sudo /etc/init.d/apache2 restart

Now navigate to http://localhost/phpmyadmin in your browser to start setting up the databases.

That’s it.


4 Responses to “How to install apache, php, mysql and phpmyadmin in Ubuntu