以及我试图添加一个额外的域到我的服务器。
在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)
然后我跑了一个网站,它说一切正常。 我重新加载Apache,但仍然当我去我的领域,它只是指向常规的默认目录。 任何想法,为什么不去我指定的目录?
谢谢
在你的configuration中没有<VirtualHost *:80>部分。 这不是错误吗? 以这种方式将您的configuration放在部分中:
<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,看看问题是否得到解决。