Apache / httpd 未在启动时自动启动

Mik*_*icz 12 linux configuration httpd amazon-ec2 apache-2.2

我在 Amazon Linux AMI 版本 2012.03 上安装了 apache2。我可以手动启动它就好了,使用/etc/init.d/httpd start. 但是,它不会在机器启动时自动启动。

似乎所有内容都在我的 rc*.d 目录中正确配置。这是结果find /etc/rc.d -name "*httpd*" | xargs ls -l

-rwxr-xr-x 1 root root 3371 Feb 16  2012 /etc/rc.d/init.d/httpd
lrwxrwxrwx 1 root root   15 Apr 14  2012 /etc/rc.d/rc0.d/K15httpd -> ../init.d/httpd
lrwxrwxrwx 1 root root   15 Apr 14  2012 /etc/rc.d/rc1.d/K15httpd -> ../init.d/httpd
lrwxrwxrwx 1 root root   15 Apr 14  2012 /etc/rc.d/rc2.d/K15httpd -> ../init.d/httpd
lrwxrwxrwx 1 root root   15 Apr 14  2012 /etc/rc.d/rc3.d/K15httpd -> ../init.d/httpd
lrwxrwxrwx 1 root root   15 Apr 14  2012 /etc/rc.d/rc4.d/K15httpd -> ../init.d/httpd
lrwxrwxrwx 1 root root   15 Apr 14  2012 /etc/rc.d/rc5.d/K15httpd -> ../init.d/httpd
lrwxrwxrwx 1 root root   15 Apr 14  2012 /etc/rc.d/rc6.d/K15httpd -> ../init.d/httpd
Run Code Online (Sandbox Code Playgroud)

我知道我可以将/etc/init.d/httpd start命令放入/etc/rc.local,但这不是一种解决方法吗?为什么不自动启动?rc*.d 目录中的其他内容在启动时就可以正常启动(mongod、postfix 等)。谢谢!

Jas*_*zze 37

使用 chkconfig 来管理您希望此服务启动的运行级别。

通常chkconfig httpd on 可以完成这项工作。

  • @PaulSheldrake 您是否正在运行使用 systemd 的操作系统?例如,Red Hat 7 系列中的 Linux 现在使用 systemd。在这种情况下,您需要 `systemctl enable httpd` (2认同)

小智 7

您没有任何“S”链接。所有的“K”都只是关机。添加同名链接,只需将 K 替换为 S。

“一般来说,系统启动以字母“S”开头的命令并停止以字母“K”开头的命令。一个较低的级别。以字母“S”开头的命令在所有情况下都运行。

如果使用 chkconfig,请参阅“man chkconfig”。对于您的情况:

chkconfig --level 2345 httpd on
Run Code Online (Sandbox Code Playgroud)

应该做。