Saturday, January 12, 2013

PHP installation On Linux

divtag Online Web Tutorials

Users who are new in Linux(Ubuntu)

Open up the Terminal (Application->Accessories->Terminal) and type (or copy paste)
     sudo su root
With the help of above command you can switch from normal user to root. Now by next time you don't need to use commands with "sudo". Instead of using sudo you can directly use commands who needs privilege for example :
If you are installing apache on your system then use simply "apt-get install apache2" instead of "sudo apt-get install apache2".


apt-get install apache2


apt-get install php5 libapache2-mod-php5
Type the following code in Terminal to restart Apache.
/etc/init.d/apache2 restart


Now type following command in your amazing terminal to install Mysql Server
apt-get install mysql-server
During the installation please provide username and password for Mysql server .After giving the all required mysql server is now installed on the machine.


phpMyAdmin provides web interface for Mysql through which you can update your database easily. Copy/paste the following line into Terminal:
  1. apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
  2. After that is installed our next task is to get PHP to work with MySQL. To do this we will need to open a file entitled php.ini. To open it type the following:
    gedit /etc/php5/apache2/php.ini
    Now we are going to have to uncomment the following line by taking out the semicolon (;).
    Change this line:
    //to look like this
  3. After that need to execute this command below for changing phpMyadmin folder to var/www
    ln -s /usr/share/phpmyadmin/ /var/www/phpmyadmin
  4. Now just restart Apache and you are all set!
    /etc/init.d/apache2 restart

STEP 5 : TEST Apache/ PHP

  1. In the terminal copy/paste the following line:
    gedit /var/www/testphp.php
  2. Copy/Paste following line into the testphp.php file:

    <?php phpinfo(); ?> 
    Save and close the file.
  3. Now open you're web browser and type the following into the web address:
  4. You have now installed both Apache and PHP well !!!


  1. Open the terminal and write the following command:
    mysql -u root -p[password]
  2. Now you will be in the mysql server comand prompt. So mysql server also works well !!!

STEP 7 : TEST phpMyAdmin

  1. Open you're web browser and type the following into the web address:
  2. You will get the login window, now use the same user and password which you have configured for mysql server.
  3. You will be now in home page of phpmyadmin. So phpmyadmin also works well !!!

STEP 8 : START/ STOP/ RESTART (apache, mysql)

/etc/init.d/mysql start
/etc/init.d/mysql stop
/etc/init.d/mysql restart

/etc/init.d/apache2 start
/etc/init.d/apache2 stop
/etc/init.d/apache2 restart
To enable apache rewrite modules
sudo a2enmod rewrite
To enable curl
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
sudo gedit /etc/apache2/stites-available/default
make override "All"

STEP 9 : There is no any other step.You are done

Congrats you have now installed both Apache, PHP, mysql servver and phpmyadmin well !!!

No comments:

Post a Comment