具有通用文件的多个站点的 Apache 设置

发布于 2024-08-11 10:20:17 字数 1160 浏览 2 评论 0原文

我有大约 50 个网站,除了 CSS 和图像之外,它们都使用完全相同的文件,目前我每次创建新网站并上传不同的 css 和图像时都会复制这些文件。

我想要做的是将每个虚拟主机设置为具有相同的DocumentRoot,然后为CSS和图像添加AliasMatch文件夹例如:

#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>

别名非常适合定制文件,但由于权限错误而无法访问公共文件:

[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

这是当前的服务器设置,我认为这可能是问题的一部分(以前的服务器管理设置):

  • Apache(Apache /2.2.14 (Unix)
  • PHP 5.2.11
  • CentOS 4.8 i686 标准
  • PHP 5 处理程序是 dso
  • Apache suEXEC 有

什么建议吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

清风无影 2024-08-18 10:20:17

看来默认情况下 public_html 文件夹的权限为 750,我更改为 755 并更新了 open_basedir 限制,一切都开始正常工作。

我只需要确保每个站点仍然可以拥有 .htaccess。

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.

暮年 2024-08-18 10:20:17

听起来好像 AliasMatch 不是问题所在,错误消息指向您的 htaccess 文件。你检查过权限吗?它属于哪个用户?

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?

一城柳絮吹成雪 2024-08-18 10:20:17

另一种解决方案是在每个域上创建指向公共文件所在文件夹的符号链接。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文