gpt4 book ai didi

php - 在 Apache VirtualHost 中配置别名和目录

转载 作者:搜寻专家 更新时间:2023-10-31 21:31:13 24 4
gpt4 key购买 nike

我有一个现有的子域 subdomain.mysite.com,我使用 SSL。我正在尝试安装 PHPasswordPusher在此子域上,但我不确定如何使用 Apache 正确执行此操作。

我已按照提供的说明进行操作。例如,subdomain.mysite.com 的 DocumentRoot 是 /var/www/subdomain,两个 pwpusher 目录在 /var/www/ppush 中。我已经完全按照安装说明中给出的代码将代码添加到相应的 VirtualHost,并且我已经按照指定的方式编辑代码以指向所有内容的正确目录。但是,当我尝试转到子域上的 Alias 目录时,我收到了 404。 (是的,我重新启动了 Apache。)

如何让给定的 Apache 配置在现有的 VirtualHost 中工作? VirtualHost 的完整代码如下,针对我在上面给出的位置进行了编辑。

<VirtualHost *:80 *:443>
ServerName subdomain.mysite.com

ServerAdmin emailaddress@host.com
DocumentRoot /var/www/subdomain

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

SSLEngine on
SSLProtocol all -SSLv3
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM

SSLCertificateFile /path/to/cert.crt
SSLCertificateKeyFile /path/to/key.key
SSLCertificateChainFile /path/to/cert2.pem

##### PHPasswordPusher #####

Alias /pwpusher/ /var/www/ppush/pwpusher_public/

<Directory /var/www/ppush/pwpusher_public/>
AllowOverride None
Order allow,deny
Allow from all
DirectoryIndex pw.php
</Directory>

<Directory /var/www/ppush/pwpusher_private/>
AllowOverride None
Order deny,allow
Deny from all
</Directory>
</VirtualHost>

最佳答案

*:80 外,所有配置看起来都正常对于 VirtualHost当使用 http:// 打开 URL 时会产生“错误请求”错误(我建议您将 SSL 指令移动到 <VirtualHost *:443> ),但这不是 404 错误的原因。

有点粗糙,但是你可以通过运行来尝试理解Apache真正访问的目录是什么

strace -p $(pgrep apache2 | xargs | sed 's/ / -p /g')

然后打开页面。在最后一行中,您应该看到如下内容:

stat("/var/www/dsd", 0x7fff470d2400) = -1 ENOENT (No such file or directory)

关于php - 在 Apache VirtualHost 中配置别名和目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29871198/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com