Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to set up an Apache Virtual Host for local development on a fresh install of Ubuntu 11.04. Here's my virtual host config inside /sites-available:

<VirtualHost *:80>
ServerName morpho.local
ServerAlias www.morpho.local
ServerAdmin webmaster@localhost
DocumentRoot /home/james/projects/morpho

# Log file
CustomLog /var/log/apache2/morpho.local-access.log combined
</VirtualHost>

I've added the symlink in /sites-enabled and restarted Apache. The document root contains a dummy "Hello World" index.html and nothing else. The www-data user is the owner of the directory and the index.html.

I get a 403 Forbidden when I browse to morpho.local, and this line is written (twice) to the Apache error log:

(13)Permission denied: /home/james/projects/.htaccess pcfg_openfile: 
  unable to check htaccess file, ensure it is readable

This seems weird to me, because it's looking for a .htaccess file one directory up from the document root. Just to see what would happen, I created a .htaccess in that directory, and gave it 777 permissions and set owner and group to www-data. Same error in the log.

My guess is that I've missed something I need to do with permissions, but the fact that it's looking for a .htaccess one directory back is confusing.

Again, this is a fresh Ubuntu/Apache install and I haven't configured anything besides this single Virtual Host.


Edit: I got it working by setting the x permission on my dev folder, /home/james/projects. This allowed the www-data Apache user to see inside the directory. I'll try ghm1014's setup from the answers because that seems like a better solution. Although it seems like it would still require the x permission in order for www-data to follow the symlink, so I don't know if it gets around having to set that or not.

Thanks for your answers, regardless.

share|improve this question

2 Answers 2

You have to give permissions to access the document root in your configuration. Put something like this inside the VirtualHost entry.

<Directory />
    Order allow,deny
    Allow from all
</Directory> 
share|improve this answer

Home directory is not a good directory to place www-doc files. Since /home/ directory has no x permissions (navigate) to other users. Adding this permission means any user will be able to see your personal information. I would recommend this:

  • Make a directory anywhere where apache can read:

    mkdir /var/www/html/

  • Then create a symlink to your real directory:

    ln -s /home/james/projects/morpho /var/www/html/

  • Change your DocumentRoot and add follow symlink option

    DocumentRoot /home/james/projects/morpho

    Options FollowSymLinks

share|improve this answer
    
It's not a big deal to set the 'x' permission on my working directory, as this is my personal local machine and there are no other users. I'll try your setup though just because it seems cleaner. –  James Jun 20 '11 at 21:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.