Ubuntu: Installing Apache, PHP, MySQL & phpMyAdmin

Here are step-by-step commands about installing apache, php, mysql, and phpmyadmin on ubuntu.

1) Open Terminal
– Press:

CTRL + ALT + T

2) Install Apache
– In terminal, type:

sudo apt-get install apache2

– To test if Apache installation, Open browser and type:

http://localhost

– It should show text: It Works!

3) Install PHP
– In terminal, type:

sudo apt-get install php5 libapache2-mod-php5

4) Install MySQL
– In terminal, type:

sudo apt-get install mysql-server

– You will be asked for mysql root password. Keep your desired password and press ENTER (or press TAB to select OK and presee ENTER)

5) Install phpMyAdmin
– In terminal, type:

sudo apt-get install phpmyadmin

– You will be asked for Web server configuration. Press SPACE key to select ‘apache2’ and press TAB to select ‘Ok’ and then press ENTER.
– Then, you will be asked for phpMyAdmin Configuration. Press TAB to select ‘No’.
– Type the following in terminal:

sudo cp /etc/phpmyadmin/apache.conf /etc/apache2/conf.d

6) Restart Apache
Type either of the following in terminal:

sudo service apache2 restart

or,

sudo /etc/init.d/apache2 restart

7) Test PHP and phpMyAdmin
Open browser and type:

http://localhost/phpmyadmin

– A login screen should appear.
– Login with your database username and password. The username should be ‘root’ and password is the one that you entered while installing MySQL in step #4 above.

Your should put your PHP files in /var/www/ directory.

Hope it helps. Thanks.