Home directory websites using vhost

Needs / Issues

  • Develop websites located inside home directory;
  • No need for special (root/web server) privileges to develop sites;
  • Websites are referenced with DNS, not aliases.


  • Administrator / Power user;
  • Developer user.

Initial Setting

  • Apache 2.2 (or newer).


  • In a shell session (as user):

    Apache logo

    1. Create your "root" directory
      mkdir ~/public_html
      This is where the site will be hosted.
    2. Make sure the Apache user can access that root directory:
      namei -l ~/public_html
      All directories in the output list should be at least executable by the Apache user.
  • In a shell session (as root):
    1. Enable VHosts in Apache's configuration:
      vi /etc/httpd/conf/httpd.conf
      Uncomment the following line:
      NameVirtualHost *:80
    2. Create an Apache configuration file for your website:
      vi /etc/httpd/conf.d/YOUR_WEBSITE.conf
      Have it contain:
      <VirtualHost *:80>

        ServerName YOUR_WEBSITE.localhost

        DocumentRoot /home/YOUR_USERNAME/public_html
        <Directory "/home/YOUR_USERNAME/public_html">
          AllowOverride All
          Order Allow,Deny
          Allow from All

        ErrorLog logs/YOUR_WEBSITE.localhost-error_log
        CustomLog logs/YOUR_WEBSITE.localhost-access_log common

    3. Restart the web server:
      service httpd restart
    4. Add a local DNS entry to your website:
      vi /etc/hosts
      Add the following line:  YOUR_WEBSITE.localhost
  • In your web browser:
    1. Browse to the URL you created:

    2. You should be served your new website.

Should these steps not work for you, please let me know.