Userdir Module – Per user directory for apache

In a development environment, one has often struggled with giving appropriate permissions to users for developing websites on a shared Apache & MYSQL environment. Below is a quick way to let people develop sites in their own home directories and carry their permissions into their folders. The below process also allows users to FTP into their home directories using their own credentials. The configuration steps are applicable to the following development environment.

  1. Development Environment
    1. Operating System – Ubuntu 12.04 LTS (Recommendation – update and upgrade to 12.04.02)
    2. Apache 2.2
    3. Proftpd
    4. hostname: test
    5. IP address:
    6. Local username: infraadvisory
  2. Configuration
    1. Basic installation of required software
      1. sudo apt-get update && upgrade
      2. sudo apt-get install apache2 proftpd
      3. sudo service apache2 restart
      4. Open a browser and check if apache is installed by typing : It should show ‘ It Works’
      5. If you also want to install MySQL run the following commands
        1. sudo apt-get install mysql-server-5.5 php5 phpmyadmin
        2. Enter relevant password for root for MySQL and select no for configuring a database.
        3. You can configure a data base by typing: and
        4. Entering user id – root & pwd – whatever you kept while installing MySQL
    2. Enabling ‘userdir’ module
      1. sudo a2enmod userdir
      2. The above command will enable the per user functionality for publishing sites
    3. Creating public_html folder and assigning permissions
      1. mkdir ~/public_html && chmod 0755 ~/public_html
      2. The above command will create a public_html folder in the user’s home directory
      3. In single command above we have created a folder and given permissions
      4. Now html files will be served through this directory by typing the following url:
    4. Serving PHP files
      1. sudo nano /etc/apache2/mods-available/php5.conf
      2. Comment out by putting a # in the 4th last line in the file (php_admin_value  engine Off – should be commented out)
      3. Press Cntl O and then Cntl X to exit nano
      4. sudo service apache2 restart
  3. Test
    1. Fireup Filezilla and enter hostname as :, Username as: infraadvisory & relevant password, port 22 and click on Quick Connect
    2. You should be able to connect to the FTP server and see public_html folder.
    3. Copy your website in public_html
    4. Fire up a browser and enter the url: You should get the index.php or default.php in the browser.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s