httpd服务没有自动启动

我在RedHat服务器上从源代码编译Apache和PHP,但在这样做的时候,我忘了安装httpd作为服务。

用于编译Apache 2.4.7的文件

文件来编译apache 2.4.7

用于编译Apache 2.4.7的命令

 ./configure --prefix=/etc/apache247 --with-included-apr --with-pcre --enable-so --enable-rewrite=shared --with-layout=Apache --enable-modules=most --enable-mods-shared=all; 

Apache 2.4.7的目录

apache 2.4.7目录

init.d脚本启动Apache 2.4.7

我发现这个脚本在stackoverflow。 这不是我的,也不是官方的。

有些用户告诉我,在apache文件夹中有一个脚本,但我没有find。

init.d apache脚本

如果你喜欢的文字:

 #!/bin/sh ### BEGIN INIT INFO # Provides: apache247 # Required-Start: $all # Required-Stop: $all # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: apache247 # Description: Start apache247 ### END INIT INFO case "$1" in start) echo "Starting Apache ..." # Change the location to your specific location /etc/apache247/bin/apachectl start ;; stop) echo "Stopping Apache ..." # Change the location to your specific location /etc/apache247/bin/apachectl stop ;; graceful) echo "Restarting Apache gracefully..." # Change the location to your specific location /etc/apache247/bin/apachectl graceful ;; restart) echo "Restarting Apache ..." # Change the location to your specific location /etc/apache247/bin/apachectl restart ;; *) echo "Usage: '$0' {start|stop|restart|graceful}" exit 64 ;; esac exit 0 

运行ntsysv

我使用这个命令来检查RedHat上的服务。 所以,我把init.d脚本放在正确的文件夹 – /etc/init.d/ ,但是apache2脚本没有出现在这里。

在这里输入图像说明

而且我重启服务器后,apache没有自动启动。

那么,什么是错的?

我不知道在什么日志我得到这个启动脚本的错误。


这听起来像你需要用chkconfig --add apache247注册init脚本。 然后你可以用chkconfig apache247 on将它标记为默认的运行级别。 重新启动应该validation这将按预期工作。

/etc/apache247/bin/apachectl安装了apache吗?

因为那个脚本在那个文件夹上查看apache。

如果没有安装在该path上,只需编辑init文件将其指向正确的文件夹即可。