在 Apache VirtualHost 中配置别名和目录

Configuring Alias and Directory inside Apache VirtualHost

我有一个与 SSL 一起使用的现有子域 subdomain.mysite.com。我正在尝试在此子域上安装 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>

除了 VirtualHost*:80 之外,配置的所有内容看起来都正常,当使用 http:// 打开 URL 时会生成 "Bad request" 错误(我建议您将 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)