已启用指向域名 Debian Apache 站点的问题

已启用指向域名 Debian Apache 站点的问题

好吧,我正在尝试向我的服务器添加一个额外的域。

在 etc/apache2/sites-available/ 我有这样的文件

# This tell apache to enable this vhost for all ports

ServerName  example.com
        ServerAlias www.example.com 
        DocumentRoot /var/www/example-com
    # Optional, allow override in .htaccess files
    <Directory /var/www/example-com>
            Options FollowSymLinks
            AllowOverride All
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/example-com/
    <Directory "/usr/lib/cgi-bin/example-com/">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    # optional, log accesses and errors to a different file
    ErrorLog /var/log/apache2/example-error.log
    CustomLog /var/log/apache2/example-access.log combined

(我从我的域名将其更改为 example.com)

然后我运行了 a2ensite,它说一切正常。我重新加载了 apache,但当我进入我的域时,它仍然只是指向常规默认目录。有什么想法为什么它没有进入我指定的目录?

谢谢

答案1

您的配置中没有<VirtualHost *:80>部分。是不是拼写错误?请按以下方式将配置放入部分中:

<VirtualHost *:80>
    ServerName  example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example-com
    # Optional, allow override in .htaccess files
    <Directory /var/www/example-com>
            Options FollowSymLinks
            AllowOverride All
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/example-com/
    <Directory "/usr/lib/cgi-bin/example-com/">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    # optional, log accesses and errors to a different file
    ErrorLog /var/log/apache2/example-error.log
    CustomLog /var/log/apache2/example-access.log combined
</VirtualHost>

然后重新加载 apache 并查看问题是否已修复。

相关内容