安装Apache的时候总是启动不起来,查看日志报的是
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 一 2019-05-06 00:48:38 CST; 7s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 7921 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Process: 7920 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 7920 (code=exited, status=1/FAILURE)
5月 06 00:48:28 hantao.centos.minimal systemd[1]: Starting The Apache HTTP Server...
5月 06 00:48:38 hantao.centos.minimal httpd[7920]: [Mon May 06 00:48:38.323438 2019] [core:error] [pid 7920] (EAI 2)Name or...oring!
5月 06 00:48:38 hantao.centos.minimal httpd[7920]: AH00526: Syntax error on line 1 of /etc/httpd/conf.d/tiki.conf:
5月 06 00:48:38 hantao.centos.minimal httpd[7920]: Missing address for VirtualHost
5月 06 00:48:38 hantao.centos.minimal systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
5月 06 00:48:38 hantao.centos.minimal kill[7921]: kill: cannot find process ""
5月 06 00:48:38 hantao.centos.minimal systemd[1]: httpd.service: control process exited, code=exited status=1
5月 06 00:48:38 hantao.centos.minimal systemd[1]: Failed to start The Apache HTTP Server.
5月 06 00:48:38 hantao.centos.minimal systemd[1]: Unit httpd.service entered failed state.
5月 06 00:48:38 hantao.centos.minimal systemd[1]: httpd.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
运行
# apachectl configtest
Name or service not known: AH00547: Could not resolve host name *: -- ignoring!
AH00526: Syntax error on line 1 of /etc/httpd/conf.d/tiki.conf:
Missing address for VirtualHost
原来是配置文件写错了,上面明确表示出了那个配置文件出了错,是**/etc/httpd/conf.d/tiki.conf**,它的内容是
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/tiki-18.2/
ErrorLog "/var/www/tiki/error_log"
TransferLog "/var/www/tiki/access_log"
<Directory /var/www/tiki-18.1/>
Options FollowSymLinks Indexes
Require all granted
AllowOverride All
allow from all
</Directory>
</VirtualHost>
提示中报的是第一行……很奇怪哪里错了,对比了其他的配置文件,我怀疑是第一行必须是注释的空行,也就是
#
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/tiki-18.2/
ErrorLog "/var/www/tiki/error_log"
TransferLog "/var/www/tiki/access_log"
<Directory /var/www/tiki-18.1/>
Options FollowSymLinks Indexes
Require all granted
AllowOverride All
allow from all
</Directory>
</VirtualHost>
再测试一下
# apachectl configtest
Syntax OK