我有 ubuntu 12.04 with apache
。本地主机运行良好。但今天我想设置一个虚拟主机。设置虚拟主机后,我通过执行此命令 sudo /etc/init.d/apache2 restart 重新启动服务器,它显示了类似以下错误
apache2: Syntax error on line 237 of /etc/apache2/apache2.conf: Could not open configuration file /etc/apache2/sites-enabled/testsite.com: No such file or directory
Action 'configtest' failed.
The Apache error log may have more information.
...fail!
我不知道错误是什么,我尝试通过谷歌来解决该错误。但我无法解决这个问题。
这是位于 (/etc/apache2/sites-available) ServerAdmin webmaster@localhost 的 apache2 配置的默认文件
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
现在,当我在浏览器上打开 localhost 时,它会显示Oops! Google Chrome could not connect to localhost
答案1
您必须从 /etc/apache2/sites-enabled 文件中删除看似虚假的链接。
您可以使用以下方式执行此操作:
$ sudo rm /etc/apache2/sites-enabled/testsite.com
答案2
我建议删除该网站(sudo a2dissite testsite.com),然后重新启动 apache,然后启用该网站(sudo a2ensite testsite.com),然后再次重新启动。(sudo service apache2 restart)