在Ubuntu 16.04中Apache2重新启动失败


6

我想用domainlocalhost的代替localhost127.0.0.1

我添加了一个配置文件myconfig.confsites-availbale 我也使用sudo a2ensite myconfig.conf

当我apache2使用重新启动服务器时sudo sudo systemctl restart apache2,出现如下错误

Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.

apache2通过卸载将其重新安装,但由于

Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.
invoke-rc.d: initscript apache2, action "start" failed.

sudo的输出 journalctl -xe

May 26 12:42:51 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:42:52 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:42:53 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:42:54 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:42:55 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:42:56 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:42:57 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:42:58 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:42:59 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:00 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:01 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:02 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:03 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:04 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:05 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:06 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:07 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:08 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:09 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:10 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:11 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:12 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:13 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:14 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:15 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:16 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:17 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:18 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:19 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:20 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:21 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:22 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:22 vostro-tbe sudo[16839]:     anuj : TTY=pts/1 ; PWD=/etc/apache2/sites-available ; USER=root ; COMMAND=/bin/journalctl -xe
May 26 12:43:22 vostro-tbe sudo[16839]: pam_unix(sudo:session): session opened for user root by anuj(uid=0)

输出 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: failed (Result: exit-code) since Thu 2016-05-26 12:42:43 IST; 53s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 16781 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)

May 26 12:42:43 vostro-tbe apache2[16781]:  *
May 26 12:42:43 vostro-tbe apache2[16781]:  * The apache2 configtest failed.
May 26 12:42:43 vostro-tbe apache2[16781]: Output of config test was:
May 26 12:42:43 vostro-tbe apache2[16781]: apache2: Syntax error on line 140 of /etc/apache2/apache2.conf: Syntax error on line 2 of /etc/apache2/mods-enabled/php7.0.load: Cannot load /usr/lib/apache2/modules/libphp7.0.so
May 26 12:42:43 vostro-tbe apache2[16781]: Action 'configtest' failed.
May 26 12:42:43 vostro-tbe apache2[16781]: The Apache error log may have more information.
May 26 12:42:43 vostro-tbe systemd[1]: apache2.service: Control process exited, code=exited status=1
May 26 12:42:43 vostro-tbe systemd[1]: Failed to start LSB: Apache2 web server.
May 26 12:42:43 vostro-tbe systemd[1]: apache2.service: Unit entered failed state.
May 26 12:42:43 vostro-tbe systemd[1]: apache2.service: Failed with result 'exit-code'.

输出 sudo apache2ctl configtest

apache2: Syntax error on line 140 of /etc/apache2/apache2.conf: Syntax error on line 2 of /etc/apache2/mods-enabled/php7.0.load: Cannot load /usr/lib/apache2/modules/libphp7.0.so into server: /usr/lib/apache2/modules/libphp7.0.so: cannot open shared object file: No such file or directory
Action 'configtest' failed.
The Apache error log may have more information.

内容 myconfig.conf

<VirtualHost *:80>
    ServerAdmin admin@website.com
    ServerName website.com
    ServerAlias www.website.com
    DocumentRoot /var/www/html/website
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

myconfig.conf中出了点问题。
MKay

更新的问题的内容myconfig.conf
Anuj TBE

Answers:


15

libapache2-mod-php7.0通过运行以下命令安装软件包或禁用PHP7模块

sudo a2dismod php7.0

1
已安装libapache2-mod-php7.0但还是同样的错误上sudo systemctl restart apache2
Anuj TBE

1
尝试禁用php7但仍然存在相同错误
Anuj TBE

解决了!已安装libapache2-mod-php7.0
Anuj TBE

1
也解决了我的问题。在Ubuntu / Kubuntu 16.04.2 LTS Xenial上(使用以前的php5安装)。sudo apt-get install libapache2-mod-php7.0然后apache2ctl configtest(优于journal -xe),最后sudo service apache2 start
user23731

5

我也遇到了同样的问题,其原因是这样的,

我在中创建了虚拟主机example.com.conf etc/apache2/sites-available,因此etc/apache2/sites-enabled当您为特定主机启用虚拟主机时,它在其中创建了链接。

后来我从中删除了文件example.com.conf etc/apache2/sites-available,但是忘记了禁用主机,因此该主机的链接仍然位于etc/apache2/sites-enabled,因此在我的情况下会导致错误,因此我只是从中删除了该链接文件,etc/apache2/sites-enabled然后启动了我的apache。工作。


这工作完美thnks
Killer

在删除conf文件并尝试重新启动之后,这也是我的解决方案。
CSharpened


1

您的问题是您的配置文件中有两行。2个日志路径会导致Apache错误。

我遇到了同样的问题,当我完全删除两个日志文件行时,就可以重新启动apache。


这也解决了我的问题。我的日志文件配置指向不存在的位置。做完后解决mkdir -p /my/log/location/
Renaat De Muynck
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.