我使用 Ubuntu 16.02。当我尝试时sudo service apache2 restart,它说:
Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.
Run Code Online (Sandbox Code Playgroud)
然后我输入:journalctl -xe,并请求:
—— -- 单元 apache2.service 已经开始启动。 1 月 11 日 02:30:46 aleksandr-VirtualBox apache2[8177]:/etc/init.d/apache2:1:/etc/apache2/envvars:envvars:未找到 1 月 11 日 02:30:46 aleksandr-VirtualBox apache2[8177]:/etc/init.d/apache2:49:/etc/apache2/envvars:envvars:未找到 1 月 11 日 02:30:46 aleksandr-VirtualBox apache2[8177]:/etc/init.d/apache2:1:/etc/apache2/envvars:envvars:未找到 1 月 11 日 02:30:46 aleksandr-VirtualBox apache2[8177]:/etc/init.d/apache2:49:/etc/apache2/envvars:envvars:未找到 Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]:* 启动 Apache httpd Web 服务器 apache2 1 月 11 日 02:30:46 aleksandr-VirtualBox apache2[8177]:* Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]:* apache2 configtest 失败。 Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]:配置测试的输出是: 1 月 11 日 02:30:46 aleksandr-VirtualBox apache2[8177]:/usr/sbin/apache2ctl:1:/etc/apache2/envvars:envvars:未找到 1 月 11 日 02:30:46 aleksandr-VirtualBox apache2[8177]:/usr/sbin/apache2ctl:49:/etc/apache2/envvars:envvars:未找到 Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]:(2)没有这样的文件或目录:AH02291:无法访问目录“/etc/apache2/logs/”以获取主要错误日志 Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]:AH00014:配置检查失败 Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]:操作“configtest”失败。 Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]:Apache 错误日志可能包含更多信息。 Jan 11 02:30:46 aleksandr-VirtualBox systemd[1]:apache2.service:控制进程退出,代码=退出状态=1 1 月 11 日 02:30:46 aleksandr-VirtualBox sudo[8171]:pam_unix(sudo:session):用户 root 的会话已关闭 Jan 11 02:30:46 aleksandr-VirtualBox systemd[1]:无法启动 LSB:Apache2 Web 服务器。 -- 主题:单元 apache2.service 失败 -- 定义者:systemd -- 支持:http://lists.freedesktop.org/mailman/listinfo/systemd-devel —— -- 单元 apache2.service 失败。 —— -- 结果失败。 Jan 11 02:30:46 aleksandr-VirtualBox systemd[1]:apache2.service:单元进入失败状态。 1 月 11 日 02:30:46 aleksandr-VirtualBox systemd[1]:apache2.service:失败,结果为“退出代码”。 Jan 11 02:33:09 aleksandr-VirtualBox dhclient[792]: DHCPREQUEST of 192.168.56.101 on enp0s8 to 192.168.56.100 port 67 (xid=0x204f076f) Jan 11 02:33:09 aleksandr-VirtualBox dhclient[792]:来自 192.168.56.100 的 192.168.56.101 的 DHCPACK 1 月 11 日 02:33:09 aleksandr-VirtualBox NetworkManager[619]:[1484073189.4253] 地址 192.168.56.101 1 月 11 日 02:33:09 aleksandr-VirtualBox NetworkManager [619]:[1484073189.4260] plen 24 (255.255.255.0) 1 月 11 日 02:33:09 aleksandr-VirtualBox NetworkManager[619]:[1484073189.4266] 服务器标识符 192.168.56.100 1 月 11 日 02:33:09 aleksandr-VirtualBox NetworkManager[619]:[1484073189.4273] 租用时间 1200 Jan 11 02:33:09 aleksandr-VirtualBox NetworkManager[619]:[1484073189.4279] dhcp4(enp0s8):状态改变绑定->绑定 1 月 11 日 02:33:09 aleksandr-VirtualBox dbus[590]:[system] 通过 systemd 激活:service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' Jan 11 02:33:09 aleksandr-VirtualBox systemd[1]:启动网络管理器脚本调度服务... -- 主题:Unit NetworkManager-dispatcher.service 已经开始启动 -- 定义者:systemd - 支持: —— -- Unit NetworkManager-dispatcher.service 已经开始启动。 Jan 11 02:33:09 aleksandr-VirtualBox dhclient[792]:绑定到 192.168.56.101——559 秒后更新。 Jan 11 02:33:09 aleksandr-VirtualBox dbus[590]: [system] 成功激活服务“org.freedesktop.nm_dispatcher” Jan 11 02:33:09 aleksandr-VirtualBox systemd[1]:启动网络管理器脚本调度服务。 -- 主题:Unit NetworkManager-dispatcher.service 已经完成启动 -- 定义者:systemd - 支持: —— -- Unit NetworkManager-dispatcher.service 已经启动完毕。 —— -- 启动结果完成。 1 月 11 日 02:33:09 aleksandr-VirtualBox nm-dispatcher[8205]:req:1 'dhcp4-change' [enp0s8]:新请求(1 个脚本) Jan 11 02:33:09 aleksandr-VirtualBox nm-dispatcher[8205]: req:1 'dhcp4-change' [enp0s8]: 开始运行有序脚本...
当systemctl status apache2.service它最需要时:
* apache2.service - LSB:Apache2 Web 服务器
已加载:已加载(/etc/init.d/apache2;坏;供应商预设:已启用)
插入:/lib/systemd/system/apache2.service.d
`-apache2-systemd.conf
活动:自 2017 年 1 月 11 日星期三 02:30:46 +08 起失败(结果:退出代码);33 分钟前
文档:man:systemd-sysv-generator(8)
进程:8023 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
进程:2236 ExecReload=/etc/init.d/apache2 reload (code=exited, status=0/SUCCESS)
进程:8177 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)
1 月 11 日 02:30:46 aleksandr-VirtualBox apache2[8177]:/usr/sbin/apache2ctl:1:/etc/apache2/envvars:envvars:未找到
1 月 11 日 02:30:46 aleksandr-VirtualBox apache2[8177]:/usr/sbin/apache2ctl:49:/etc/apache2/envvars:envvars:未找到
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]:(2)没有这样的文件或目录:AH02291:无法访问目录“/etc/apache2/logs/”以获取主要错误日志
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]:AH00014:配置检查失败
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]:操作“configtest”失败。
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]:Apache 错误日志可能包含更多信息。
Jan 11 02:30:46 aleksandr-VirtualBox systemd[1]:apache2.service:控制进程退出,代码=退出状态=1
Jan 11 02:30:46 aleksandr-VirtualBox systemd[1]:无法启动 LSB:Apache2 Web 服务器。
Jan 11 02:30:46 aleksandr-VirtualBox systemd[1]:apache2.service:单元进入失败状态。
1 月 11 日 02:30:46 aleksandr-VirtualBox systemd[1]:apache2.service:失败,结果为“退出代码”。
怎么了?中断在哪里?请帮忙!
有两个错误:
1.出于某种原因,您/etc/apache2/envvars丢失了:
来自journalctl -xe:
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /etc/init.d/apache2: 1: /etc/apache2/envvars: envvars: not found
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /etc/init.d/apache2: 49: /etc/apache2/envvars: envvars: not found
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /etc/init.d/apache2: 1: /etc/apache2/envvars: envvars: not found
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /etc/init.d/apache2: 49: /etc/apache2/envvars: envvars: not found
...
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /usr/sbin/apache2ctl: 1: /etc/apache2/envvars: envvars: not found
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /usr/sbin/apache2ctl: 49: /etc/apache2/envvars: envvars: not found
Run Code Online (Sandbox Code Playgroud)来自systemctl status apache2.service:
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /usr/sbin/apache2ctl: 1: /etc/apache2/envvars: envvars: not found
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /usr/sbin/apache2ctl: 49: /etc/apache2/envvars: envvars: not found
Run Code Online (Sandbox Code Playgroud)在我的系统中,此文件具有下一个权限:
$ ls -l /etc/apache2/envvars
-rw-r--r-- 1 root root 1782 ??? 19 2016 envvars
Run Code Online (Sandbox Code Playgroud)
其内容 ( $ cat /etc/apache2/envvars) 为:
# envvars - default environment variables for apache2ctl
# this won't be correct after changing uid
unset HOME
# for supporting multiple apache2 instances
if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then
SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}"
else
SUFFIX=
fi
# Since there is no sane way to get the parsed apache2 config in scripts, some
# settings are defined via environment variables and then used in apache2ctl,
# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
# temporary state file location. This might be changed to /run in Wheezy+1
export APACHE_PID_FILE=/var/run/apache2/apache2$SUFFIX.pid
export APACHE_RUN_DIR=/var/run/apache2$SUFFIX
export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX
# Only /var/log/apache2 is handled by /etc/logrotate.d/apache2.
export APACHE_LOG_DIR=/var/log/apache2$SUFFIX
## The locale used by some modules like mod_dav
export LANG=C
## Uncomment the following line to use the system default locale instead:
#. /etc/default/locale
export LANG
## The command to get the status for 'apache2ctl status'.
## Some packages providing 'www-browser' need '--dump' instead of '-dump'.
#export APACHE_LYNX='www-browser -dump'
## If you need a higher file descriptor limit, uncomment and adjust the
## following line (default is 8192):
#APACHE_ULIMIT_MAX_FILES='ulimit -n 65536'
## If you would like to pass arguments to the web server, add them below
## to the APACHE_ARGUMENTS environment.
#export APACHE_ARGUMENTS=''
## Enable the debug mode for maintainer scripts.
## This will produce a verbose output on package installations of web server mod ules and web application
## installations which interact with Apache
#export APACHE2_MAINTSCRIPT_DEBUG=1
Run Code Online (Sandbox Code Playgroud)
您可以手动创建它:sudo nano /etc/apache2/envvars,将上面的内容粘贴到里面,保存ctrl+o并退出ctrl+ x。
2.在你的系统中,文件夹/etc/apache2/logs也不见了:
来自journalctl -xe:
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: (2)No such file or directory: AH02291: Cannot access directory '/etc/apache2/logs/' for main error log
Run Code Online (Sandbox Code Playgroud)来自systemctl status apache2.service:
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: (2)No such file or directory: AH02291: Cannot access directory '/etc/apache2/logs/' for main error log
Run Code Online (Sandbox Code Playgroud)这不是默认的日志文件夹,它是在您的自定义配置中定义的,并且必须创建:
$ sudo mkdir /etc/apache2/logs
Run Code Online (Sandbox Code Playgroud)
小智 5
我删除了sites-available 中的.conf 文件,并没有删除sites-enabled 中的链接文件。
现在我删除了启用站点的所有文件
重新启动 apache2 服务器(sudo service apache2 restart)
为我工作
希望这可以帮助某人:)
小智 5
我有同样的问题。我遇到了同样的错误sudo service apache2 restart并跑sudo systemctl status apache2.service了,红线是Failed to start LSB: Apache2 web server.
运行以下命令:
sudo apache2ctl configtest
Run Code Online (Sandbox Code Playgroud)
它会检查错误(我认为是语法错误),然后您可以调试错误。
| 归档时间: |
|
| 查看次数: |
112514 次 |
| 最近记录: |