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 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.
1 Answer
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> 2