我目前正在使用 Passenger 在 Dreamhost 上运行一个 Django 站点。我想在当前保存我的静态文件的“公共(public)”目录中运行一个 Wordpress 博客(这是我认为它应该存在的地方)。由于 Django 当前拥有所有的/*,我被告知我需要将 Location 条目添加到我的 apache2 服务器的 httpd.conf 中。我尝试了位置和目录,但无法让它们工作。下面的代码片段基本上是我以多种不同方式输入的内容。
<Directory /home/user/domain/public/blog/>
Order allow,deny
allow from all
</Directory>
我还尝试添加 AllowOverride All 以 try catch 博客文件夹中的 htaccess 文件,但没有成功。我对使用 apache 非常陌生(第一次),任何人都可以指出正确的方向让/blog/显示 wordpress 站点而不是 404 页面。
最佳答案
尝试添加 Apache Alias 指令:
Alias /blog/ /home/user/domain/public/blog/
“别名”将与您的“目录”指令一起使用。
注意:我在将 django 加载到 apache 中的 wsgi 配置之前列出了这些。 (我不知道这是否重要,但它可能。)
编辑: 在我的主 httpd.配置文件我
LoadModule wsgi_module modules/mod_wsgi.so
我假设那里有“DocumentRoot”和“Directory”指令。
下一步:在我的虚拟主机中
<VirtualHost *:80>
Alias /blog/ /home/user/domain/public/blog/
<FilesMatch \.(?i:gif|jpe?g|png|ico)$>
Order allow,deny
allow from all
</FilesMatch>
<FilesMatch \.(?i:css|jst|js|txt|htm|html)$>
Options Indexes FollowSymLinks MultiViews
Order allow,deny
allow from all
</FilesMatch>
<Directory /home/user/domain/public/blog/>
Order allow,deny
allow from all
</Directory>
也许我的 FilesMatch 指令真的发挥了作用(我以前可能错过了)
调试 如果你不能让它继续下去,你可能想在 apache 中启用更详细的 httpd 日志记录输出,看看你是否能让它告诉你它不满意的地方。 您可以通过将 'LogLevel' 指令从 'warn' 更改为 debug
LogLevel debug
现在
tail -f /path/to/you/apache/error_logs
关于django - apache2 允许访问子目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20898065/