从网上下载apache的源码包,例如/usr/local/src/httpd-2.2.34.tar.gz,解压到目录/usr/local/src/httpd-2.2.34,编译并安装,假如安装到/usr/local/apache目录中,将其设置为开机启动,并且可以使用service启动和关闭。
1.找到httpd-2.2.34/build/rpm/httpd.init并移动:mv /usr/local/src/httpd-2.2.34/build/rpm/httpd.init /etc/rc.d/init.d/httpd
2.打开/etc/rc.d/init.d/httpd并修改:
httpd=${HTTPD-/usr/local/apache/bin/httpd} #红色部分原为/usr/sbin
pidfile=${PIDFILE-/usr/local/apache/logs/${prog}.pid} #红色部分原为/var/logs/
CONFFILE=/usr/local/apache/conf/httpd.conf #红色部分原为/etc/httpd/conf
3.运行:
chkconfig --add httpd #注意要在/etc/rc.d/init.d目录下运行
chkconfig –level 2345 httpd on #设置为开机启动,
chkconfg –list #可以看到httpd已经添加到开机启动,且2345为on
4.分别运行service httpd start和service httpd stop,如果能够正常启动/关闭httpd并没有错误提示说明设置正确,重新启动linux系统检测httpd是否正常运行
时间: 2024-10-27 05:27:34