Thursday, February 24, 2011

How to enable PHP in Apache per user directory configuration on Ubuntu 10.10

   If you want to  do web application development on Ubuntu systems,  enabling per user directory configuration on Apache web server is a good idea.  You can  make a  directory on your home folder visible  to the web server and  view it via web browser.
   Let us start with  apache installation

$ sudo apt-get install apache2

  By default apache serves pages from  /var/www/
If you  invoke on a browser, you can view web pages stored in
/var/www . However , if you want to put a new  html page at /var/www , you need  root access.   You can make a directory in your home folder visible to the server and access this directory via  ( Substitute username with your actual login name.) . For achieving this, do the following steps.
  $ sudo a2enmod userdir
        Enabling module userdir.
        Run '/etc/init.d/apache2 restart' to activate new configuration!

Now restart  apache
$ sudo /etc/init.d/apache2 restart

 Userdir   mod  will  make public_html  folder   in your home directory available on  web server.  You can create public_html   folder in your home folder and develop  your web applications.
    If you are developing  PHP applications , you have to enable php support  for per user directory configuration.
For enabling php,
sudo vi /etc/apache2/mods-available/php5.conf

Look for the lines that look like

and change them to look like:

 then restart apache.
sudo /etc/init.d/apache2 restart



CraigT said...

What changes are made in the configuration file between the final two screenshots (just before the restart at the very end of the document) - I can't see any difference.

Anonymous said...

He had comment out all the lines with the use of # character.