Installing Apache2, PHP, MySQL and phpMyAdmin on Ubuntu - 8.04, 9.04 or 9.10
In this tutorial we are going to show you how to setup your own Ubuntu based web server, It includes the installation and basic configuration of following open source softwares -
- Apache2 web server
- PHP
- MySQL
- phpMyAdmin
So follow the stepwise commands (along with screenshots) given below.
Open the terminal and type the following command-
|
sudo apt-get install lamp-server^ |

and press enter, after installation mysql will ask you for the root password.

Testing Apache server:-
Open mozilla or any other web browser and type the following in the address bar - http://localhost/. If everything is working fine you will see the following message in your browser as shown below.

Your installation for MySQL, Apache2 & PHP is now complete.
Executing PHP:-
For executing a PHP file on web server you will have to save the php file in '/var/www' directory. To execute this php code you will have to type the following in your browser - http://localhost/myphpfile.php where myphpfile.php is the name of your php file.
Example:
Open the terminal and write:
|
sudo gedit /var/www/testing.php |
This will open a blank document in a new window and while saving while be saved in /var/www directory with filename as testing.php.
Copy paste the following php code in the blank document
<?php
phpinfo();
?>
Now open your web browser and type type the following url in your web browser - http://localhost/testing.php.

Testing MySQL:-
Just write this in terminal :-
|
$ mysql- u root -p |
and it will prompt you for the mysql root password. After correctly entering the root password which you had given earlier you will be able to access mysql.

Now write the following command in the terminal
|
mysql> \q |
to exit the mysql.
So till now we have successfully installed and configured and tested Apache2, PHP and MySQL.
phpMyAdmin provides a graphical interface for database administration tasks.
To install phpMyAdmin open the terminal and type the following command
|
sudo apt-get install libapache2-mod-auth-mysql phpmyadmin |
1) During the installation you will be prompted to select your web server for automatic configuration. Use the space bar to select apache2 and then hit <Enter>.

2) Next you’ll be prompted for the password for MySQL’s administrator. Enter the MySQL root password that you created earlier in the installation. Hit <Tab> to select Ok and hit <Enter>.
3) Next you’ll be prompted to create an application password for phpMyAdmin to talk to MySQL. If you leave it blank, a random password will be generated for you.
After configuring the password, the installation will be complete.
Testing phpMyAdmin:-
Open your web browser and run the following url - http://localhost/phpmyadmin/

And you can start using your phpMyAdmin through the browser. phpMyAdmin is a web based application for database that runs on PHP.
Post your comments and suggestions related to this tutorial here - http://www.botskool.com/forums/computer-programming/linux/unix
- 860 reads


Recent comments
2 days 10 hours ago
6 days 13 hours ago
2 weeks 1 day ago
2 weeks 1 day ago
2 weeks 4 days ago