![定义虚拟主机后,apache 无法启动](https://linux22.com/image/583908/%E5%AE%9A%E4%B9%89%E8%99%9A%E6%8B%9F%E4%B8%BB%E6%9C%BA%E5%90%8E%EF%BC%8Capache%20%E6%97%A0%E6%B3%95%E5%90%AF%E5%8A%A8.png)
我已经在我的服务器上设置了 virtualnamehosts ,并且在启动 apache 时没有收到任何错误,但是当我检查它是否已启动时,它显示:
httpd dead but pid file exists
谢谢您的帮助。
这是我的配置:
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# NOTE: NameVirtualHost cannot be used without a port specifier
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
#
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html
ServerName mysite.com
ServerAlias www.mysite.com
ErrorLog /var/log/httpd/mysite.com/error_log
CustomLog /var/log/httpd/mysite/access_log common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/savvyParts
ServerName mysite2.com
ServerAlias www.mysite2.com
ErrorLog /var/log/httpd/mysite2.com/error_log
CustomLog /var/log/httpd/mysite2.com/access_log common
</VirtualHost>
答案1
要测试配置的正确性,请使用以下命令;
# service httpd configtest
Syntax OK
我尝试了您的测试配置,但出现了一些路径错误;
# service httpd configtest
Warning: DocumentRoot [/var/www/savvyParts] does not exist
Syntax OK
此后它就无法启动了。
所以首先 检查 DocumentRoot 的路径以及实际存在的路径
如果这不能解决问题,那么您应该提供以下命令的输出;
# cat /var/log/httpd/error_log
[Thu May 10 05:22:00 2012] [notice] Digest: done
[Thu May 10 05:22:00 2012] [notice] SSL FIPS mode disabled
[Thu May 10 05:22:00 2012] [notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.11 mod_ssl/2.2.22 OpenSSL/1.0.0h-fips configured -- resuming normal operations
您还可以以 root 身份从命令行启动 httpd,并观察任何其他启动错误;
# /usr/sbin/httpd
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs