![启动 apache2 时出错“无法访问目录‘/var/log/apache2/’以获取主错误日志”](https://linux22.com/image/1162620/%E5%90%AF%E5%8A%A8%20apache2%20%E6%97%B6%E5%87%BA%E9%94%99%E2%80%9C%E6%97%A0%E6%B3%95%E8%AE%BF%E9%97%AE%E7%9B%AE%E5%BD%95%E2%80%98%2Fvar%2Flog%2Fapache2%2F%E2%80%99%E4%BB%A5%E8%8E%B7%E5%8F%96%E4%B8%BB%E9%94%99%E8%AF%AF%E6%97%A5%E5%BF%97%E2%80%9D.png)
当我运行时sudo service apache2 start
出现此错误:
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 - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2019-01-15 16:20:26 -03; 7min ago
Process: 8101 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
ene 15 16:20:26 pc systemd[1]: Starting The Apache HTTP Server...
ene 15 16:20:26 pc apachectl[8101]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1.
ene 15 16:20:26 pc apachectl[8101]: (2)No such file or directory: AH02291: Cannot access directory '/var/log/apache2/' for main error log
ene 15 16:20:26 pc apachectl[8101]: (2)No such file or directory: AH02291: Cannot access directory '/var/log/apache2/' for error log of vhost
ene 15 16:20:26 pc apachectl[8101]: AH00014: Configuration check failed
ene 15 16:20:26 pc apachectl[8101]: Action 'start' failed.
ene 15 16:20:26 pc apachectl[8101]: The Apache error log may have more information.
ene 15 16:20:26 pc systemd[1]: apache2.service: Control process exited, code=exited status=1
ene 15 16:20:26 pc systemd[1]: apache2.service: Failed with result 'exit-code'.
ene 15 16:20:26 pc systemd[1]: Failed to start The Apache HTTP Server.
我能做什么呢?
答案1
固定的
我刚刚创建了目录并授予它写权限:
sudo mkdir -p /var/log/apache2/
sudo chmod -R 744 /var/log/apache2/