views:

216

answers:

3

I have approx 50 sites that all use the exact same files other than CSS and IMAGES, i currently duplicate the files each time i create a new site and upload different css and images.

What I want do so set up each vhost to have the same DocumentRoot then add AliasMatch for the css and images folders e.g:

#Common Files VHOST
<VirtualHost xxx.xxx.xxx.xxx:80>
    ServerName commonfiles.com
    ServerAlias www.commonfiles.com
    DocumentRoot /home/commonfiles/public_html
</VirtualHost>

#Sample vhost for 1 of the 50 sites.
<VirtualHost xxx.xxx.xxx.xxx:80>
    ServerName mytest.com
    ServerAlias www.mytest.com
    DocumentRoot /home/commonfiles/public_html
    ......
    AliasMatch /css/(.*) /home/ftpuser/public_html/mycss/$1
</VirtualHost>

The alias works perfectly for the bespoke files but the common files cant be accessed because of permission errors:

[Mon Nov 16 09:31:01 2009] [crit] [client xxx.xxx.xxx.xxx] (13)Permission denied: /home/commonfiles/public_html/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable

This is the current server setup which I think may be part of the problem (Previous Server Admin Set this up):

  • Apache(Apache/2.2.14 (Unix)
  • PHP 5.2.11
  • CentOS 4.8 i686 standard
  • PHP 5 Handler is dso
  • Apache suEXEC is on

Any suggestions?

A: 

It doesn't sound like the AliasMatch is the problem, the error message is pointing to your htaccess file. Have you checked that for permissions? Wbich user does it belong to?

Pekka
Yeah the alias match is fine, Example: /home/commonfiles/public_html/.htaccess has 644 commonfiles:commonfiles
Lizard
Try giving the whole directory 644. Does that help?
Pekka
Changing directory to 644 didn't help, so as a test i set .htaccess and public_html to 777 this then gave me a seperate error `PHP Fatal error: Can't load /home/commonfiles/public_html/index.php, open_basedir restriction. in Unknown on line 0`
Lizard
I just added the correct path to php_admin_value open_basedir "/home/ftpuser:/usr/lib/php:/usr/local/lib/php:/tmp:/home/commonfiles" ANd with 777 permissions it is working
Lizard
It appears that others needs to have execute permissions, in order for this to work, what permissions should I be using?
Lizard
I don't think you need execute permissions for others. Read permissions should work fine. The open_basedir restriction should be a different matter. Check your php.ini, is there an open_basedir configured? If so, try turning it off.
Pekka
+1  A: 

It appears that by default the the public_html folder has permissions of 750, I changed to 755 and updated the open_basedir restrictions and all started to work great.

I just have to make sure that I can still have a .htaccess per site.

Lizard
Maybe you wanna flag this as the answer and edit your OQ?
ChrisR
I would but you have to wait 48 hours before you can accept your own answer
Lizard
A: 

Another solution would be to create symbolic links on each domain pointing to the folder where the common files reside.

facildelembrar