ubuntu18无法启动ApacheJob for apache2.service failed because the control process exited with error code.

最近在完成Linux课程作业:LAMP框架的搭建,遇到了一个困扰了我几天的问题:Apache2.4服务器无法正常启动,经过各种百度和bing搜索,终于解决了问题,感谢这次经历使自己加深了对ubuntu的理解。

1.错误描述:

当我启动或重启Apache2时,

$ 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.

通过help查看错误 

apache2 --help

显示错误原因是

(13)Permission denied: AH00072: make_sock: could not bind to address [::]:80
(13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs

大意是说http协议要调用的80端口被占用了,我们可以修改端口为8080。同时我在StackOverflow上查到了一篇解决此问题的文章,感觉答主的回答很有趣,和大家分享一下https://askubuntu.com/questions/338218/why-am-i-getting-permission-denied-make-sock-could-not-bind-to-address-when

解决办法为

sudo vim /etc/apache2/ports.conf

进入设置端口的ports.conf文件,文件内容如下

  1# If you just change the port or add more ports here, you will likely also
  2 # have to change the VirtualHost statement in
  3 # /etc/apache2/sites-enabled/000-default.conf
  4 
  5 Listen 8080  #在此处将原端口80改为了8080
  6 
  7 <IfModule ssl_module>
  8         Listen 443
  9 </IfModule>
 10 
 11 <IfModule mod_gnutls.c>
 12         Listen 443
 13 </IfModule>
 14 
 15 # vim: syntax=apache ts=4 sw=4 sts=4 sr noet

保存后重启apache2

sudo /etc/init.d/apache2 start

正常启动

[ ok ] Starting apache2 (via systemctl): apache2.service.

 

  • 12
    点赞
  • 32
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值