I have started working with Ubuntu 11.10 and my first task was to install PHP, Apache and MySQL in that. This is because without these three things computer is useless for PHP Developer.
So Here I am sharing this article which shows how to install PHP, MySQL and Apache and configure with each other. This would be very useful for newbies, who have just jumped into web developing.
Before starting make sure that you have root privileges, because for some steps you need to use sudo, which will ask for the root credentials. Also we will use apt-get to download the packages. If you are not sure about sudo and apt-get then have a look at these articles. sudo and apt-get
In nutshell here are the steps which we will follow in this article:
Before starting make sure that you have root privileges.
- Install MySQL
- Install Apache
- Install PHP
- Configure PHP with MySQL
Here we will complete this whole from terminal itself. You can start your terminal using Alt+Ctrl+T.
Install MySQL
You need to execute below command to get it done.
After downloading the package it will ask for the MySQL root password. It is recommoded to set the MySQL root password.
Install Apache
After installing this apache just type http://localhost or http://127.0.0.1 in your browser and you will see that apache is installed in your machine.

Please note that, Apache’s default document root is /var/www on Ubuntu, and the configuration file is /etc/apache2/apache2.conf.
Additional configurations are stored in subdirectories of the /etc/apache2 directory such as /etc/apache2/mods-enabled (for Apache modules), /etc/apache2/sites-enabled (for virtual hosts), and /etc/apache2/conf.d.
Install PHP
Above line shows that you have installed PHP and Apache PHP Module. After this you must need to restart your Apache web server. You need to execute below command for the same:

The document root of the default web site is /var/www. now we will create a small PHP file (phpinfo.php) in that directory and execute in a browser. We will display phpinfo() in that file so we can gets lots of details about our setup.
You can create that file using below command, I am assuming that you are familiar with creating files and editing using vi editor.
Now we can access the http://127.0.0.1/phpinfo.php to see that php is installed and configured with apache and our php is running as a apache module. We can find this information from the server api line in the phpinfo page.
Configure PHP with MySQL
Now as we can see that we have installed PHP, Apache and configured as well. But you can see that we still do not have MySQL support for this PHP installation.
Now its time to get the MySQL support in PHP. You remember that first step in which we have installed MySQL.
So let’s configure the MySQL and PHP. You have to execute below steps to get this done.
Along with the MySQL extenstion we might need other extenstions also, so here we will install those all together. Have a look at below command for the same.
Now after all above packages gets installed you need must have to restart the apache web server to see all the PHP supports we just added.
Execute below command to restart the apache.

Ok now you are ready to start with the PHP project in your machine. Enjoy ;)
Hope this is much clear to you and successful for you as with me. Share your thought here by comments. Subscribe to our feed, follow us and like us to get all latest updates and freebies
Pingback: MMDA chief calls for summer interns | Google Alert
Pingback: Install LAMP in two easy steps | Expert PHP Developer