在启用我的网站后,我一直在努力让 Apache2 重新启动,直到我偶然发现了这一点帖子:Ubuntu 16.04 中 Apache2 重启失败我尝试了评论中列出的解决方案之一,建议注释掉两行日志。
我已经完成了此操作,现在 Apache2 再次启动,但我担心我的日志文件将不再被重新记录在我想要的位置。为什么当日志行未被注释掉时,apache 无法运行?
请参阅以下我当前的配置,其中日志行已被注释掉:
DocumentRoot /var/www/html/example.com/public_html
<Directory />
Options FollowSymLinks
AllowOverride All
Order Deny,Allow
Deny from All
</Directory>
<Directory /var/www/html/example.com/public_html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
allow from all
</Directory>
#ErrorLog /var/www/html/example.com/log/error.log
#CustomLog /var/www/html/example.com/log/access.log combined
当没有注释掉行时,我收到以下错误:
Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.
当我运行“systemctl status apache2.service”时,我得到以下信息:
● apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) (Result: exit-code) since Tue 2017-01-24 10:08:36 EST; 1h 29min ago
Docs: man:systemd-sysv-generator(8)
Process: 23552 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
Process: 28665 ExecReload=/etc/init.d/apache2 reload (code=exited, status=1/FAILURE)
Process: 28148 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/apache2.service
├─28163 /usr/sbin/apache2 -k start
├─28513 /usr/sbin/apache2 -k start
├─28514 /usr/sbin/apache2 -k start
├─28515 /usr/sbin/apache2 -k start
├─28516 /usr/sbin/apache2 -k start
├─28517 /usr/sbin/apache2 -k start
└─28524 /usr/sbin/apache2 -k start
Jan 24 11:34:43 kbo1.kidbo.co apache2[28665]: * Reloading Apache httpd web server apache2
Jan 24 11:34:43 drop1.example.com apache2[28665]: *
Jan 24 11:34:43 drop1.example.com apache2[28665]: * The apache2 configtest failed. Not doing anything.
Jan 24 11:34:43 drop1.example.como apache2[28665]: Output of config test was:
Jan 24 11:34:43 drop1.example.com apache2[28665]: (2)No such file or directory: AH02291: Cannot access directory '/var/www/html/example.com/log/' for error log of vhost defined at /etc/apache2/sites-enabled/example.com.conf:1
Jan 24 11:34:43 drop1.example.com apache2[28665]: AH00014: Configuration check failed
Jan 24 11:34:43 drop1.example.com apache2[28665]: Action 'configtest' failed.
Jan 24 11:34:43 drop1.example.com apache2[28665]: The Apache error log may have more information.
Jan 24 11:34:43 drop1.example.com systemd[1]: apache2.service: Control process exited, code=exited status=1
答案1
的输出systemctl status apache2.service
包含下一个错误消息:
Jan 24 11:34:43 drop1.example.com apache2[28665]: (2)No such file or directory: AH02291: Cannot access directory '/var/www/html/example.com/log/' for error log of vhost defined at /etc/apache2/sites-enabled/example.com.conf:1
这意味着,您必须创建所需的日志目录,但它并不存在。
sudo mkdir /var/www/html/example.com/log/
sudo systemctl restart apache2.service