Job for apache2.service failed because the control process exited with error code

环境:Ubuntu 16.04.1 + Django  1.11.15 + Apache 2.4.18 + python 3.5

 

此篇文章内容提到的第几步,对照以下链接中的步骤

  百度云的ubuntu16.04.1部署Apache服务器+Django项目

 

将项目搭建到云主机上,第四步重启apache报的错

 

报错信息:

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

  按照提示,使用journalctl -xe打开错误日志

  显示如下:

-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit apache2.service has begun starting up.
Aug 08 10:41:17 instance-4xi7rrkf apache2[10930]:  * Starting Apache httpd web server apache2
Aug 08 10:41:17 instance-4xi7rrkf apache2[10930]:  *
Aug 08 10:41:17 instance-4xi7rrkf apache2[10930]:  * The apache2 configtest failed.
Aug 08 10:41:17 instance-4xi7rrkf apache2[10930]: Output of config test was:
Aug 08 10:41:17 instance-4xi7rrkf apache2[10930]: apache2: Syntax error on line 219 of /etc/apache2/apache
Aug 08 10:41:17 instance-4xi7rrkf apache2[10930]: Action 'configtest' failed.
Aug 08 10:41:17 instance-4xi7rrkf apache2[10930]: The Apache error log may have more information.
Aug 08 10:41:17 instance-4xi7rrkf systemd[1]: apache2.service: Control process exited, code=exited status=
Aug 08 10:41:17 instance-4xi7rrkf systemd[1]: Failed to start LSB: Apache2 web server.
-- Subject: Unit apache2.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit apache2.service has failed.
-- 
-- The result is failed.
Aug 08 10:41:17 instance-4xi7rrkf systemd[1]: apache2.service: Unit entered failed state.
Aug 08 10:41:17 instance-4xi7rrkf systemd[1]: apache2.service: Failed with result 'exit-code'.
Aug 08 10:41:22 instance-4xi7rrkf sshd[10964]: Connection closed by 5.188.218.246 port 34880 [preauth]


 

  按照错误提示:说是 /etc/apache2/apache.conf文件的219行配置出错

  打开提示文件,找到第219行:

    (vim显示行号:按下esc键,输入 (:set nu))  

218 # Include the virtual host configurations:
219 IncludeOptional sites-enabled/*.conf

  将219行的配置文件改为:  tip.conf为第二步的网络配置文件名

218 # Include the virtual host configurations:
219 IncludeOptional sites-enabled/tip.conf

 

这个时候 apache服务就可以重启了

  赶紧打开网站:

  报错如下:

  

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at [no address given] to inform them of the time this error occurred,
and the actions you performed just before this error.
More information about this error may be available in the server error log.
Apache/2.4.18 (Ubuntu) Server at www.py6web.com Port 80

  

查看apache2的错误日志

 

这个时候切换到 :cd /var/log/apache2

就会发现文件夹下多了两个错误日志文件

root@instance-4xi7rrkf:/var/log/apache2# ls
access.log  django-tip-error.log  error.log  other_vhosts_access.log  tip-django.log

打开错误日志,查看错误信息:

[Wed Aug 08 10:49:22.535845 2018] [wsgi:error] [pid 11109:tid 140181583668992] [client 106.121.68.131:64773]     import pymysql
[Wed Aug 08 10:49:22.535881 2018] [wsgi:error] [pid 11109:tid 140181583668992] [client 106.121.68.131:64773] ImportError: No module named 'pymysql'

很明显少了个pymysql模块 使用pip3 install pymysql安装后,网站就可以正常访问了(其他同样信息,也执行此操作,最好切换到root用户下)

切换root用户 :   sudo su

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不止于python

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值