How to setup apache2 virtualhosts on your home directory on ubuntu 14.04?

47,455

When you use any non-standard directories with apache you need to also edit /etc/apache2/apache2.conf, and add in a <Directory /bla/bla> stanza so that apache knows it is OK to access the area. Just copy the existing /var/www or /var/www/html one. For example (from another question, and for a different location):

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

<Directory /media/newhd/test_web/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>
Share:
47,455

Related videos on Youtube

Vinicius Santana
Author by

Vinicius Santana

Web developer passionate about the future

Updated on September 18, 2022

Comments

  • Vinicius Santana
    Vinicius Santana over 1 year

    I am trying to setup my apache2 virtualhost to run applications from an apps directory on my home directory.

    home/myusername/apps/application1
    

    Here are the steps there I am currently doing:

    1) Creating the directories and adding an index.html file to it.

    home/myusername/apps/application1/index.html
    

    2) Granting Permissions to the directories.

    sudo chown -R $USER:$USER /home/myusername/apps/application1
    
    sudo chmod -R 755 /home/myusername/apps
    

    3) Creating the virtual host file

    sudo touch /etc/apache2/sites-enabled/application1.app.conf
    
    <VirtualHost *:80>    
        ServerAdmin webmaster@localhost
        DocumentRoot /home/myusername/application1
        ServerName application1.app
        ServerAlias www.application1.app
    
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
    

    4) Activate the host

    sudo a2ensite application1.app
    

    5) Restart Apache

    sudo service apache2 restart
    

    6) Adding the domain to the host file

    127.0.0.1    application1.app
    

    After doing all this, when I type the address on the browser application1.app I get the following 403.

    Forbidden
    You don't have permission to access / on this server.
    Apache/2.4.7 (Ubuntu) Server at application1.app Port 80
    

    Any ideas on what I am doing wrong? Thanks all.

  • Vinicius Santana
    Vinicius Santana about 9 years
    Yeah. That's right.. I figured out.. the instructions were on the apache2 landing page. Thanks tough. Voting up. ;)
  • ATutorMe
    ATutorMe almost 9 years
    There's a typo in the above answer, I tried to edit it but needs at least 6 characters to make an edit, and I don't have enough reputation to post a comment. /etc/apache2/apcahe2.conf should be /etc/apache2/apache2.conf