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 LAMP installation and configuration of following open source softwares for web servers-
- Apache2 web server
- PHP Script
- MySQL database server
- phpMyAdmin db UI
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 will ask you to set the root password for mysql. Thats all installation completes flawlessly.
Testing Apache Web 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. " It Works ! "
This indicates that you have successfully installed the Apache, MySQL, phpmyAdmin and Php script is running..
Executing PHP codes or Testing php:-
For executing a PHP file on web server you will have to save the php file in '/var/www' directory. Make a 'myphpfile.php' and 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.
Open the terminal and write:
sudo gedit /var/www/testing.php
This will open a blank document in a new window and while saving , it will be saved in /var/www directory with a filename testing.php.
Copy paste the following php code in the blank document
Now open your web browser and type type the following url in your web browser - http://localhost/testing.php.
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
to exit the mysql.
So till now we have successfully installed and configured and tested Apache2, PHP and MySQL.
phpMyAdmin provides a graphical user interface for MySQL 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.
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 php based web application for MySQL database.
Post your doubt and suggestions related to this tutorial here - http://www.botskool.com/forums/computer-programming/linux/unix