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.
Here we will complete this whole from terminal itself. You can start your terminal using Alt+Ctrl+T.
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.
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.
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.
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 ;)
Avinash Zala is leading various projects which deals with the various technology involved with the web. A combination of perfect technical and management skills. Avinash would like to chat with you and convert your imagination into the working system. You can get in touch with him on Facebook and Twitter.
View all posts by: Avinash