bsp; /apps/httpd24/man
(5)设置开机自动启动
[root@centos7 ~]# vim /etc/rc.d/rc.local
[root@centos7 ~]# /apps/httpd24/bin/apachectl start
[root@centos7 ~]# chmod +x /etc/rc.d/rc.local
(6)创建service unit文件(CentOS 7 以上版本)
[root@centos7 ~]# vim /usr/lib/systemd/system/httpd24.service
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)
[Service]
Type=forking
#EnvironmentFile=/etc/sysconfig/httpd
ExecStart=/apps/httpd24/bin/apachectl start
#ExecStart=/apps/httpd24/bin/httpd $OPTIONS -k start
ExecReload=/apps/httpd24/bin/apachectl graceful
#ExecReload=/apps/httpd24/bin/httpd $OPTIONS -k graceful
ExecStop=/apps/httpd24/bin/apachectl stop
KillSignal=SIGCONT
PrivateTmp=true
[Install]
WantedBy=multi-user.target
创建启动脚本(CentOS 6 以前版本)
#自定义启动脚本(参考httpd-2.2的服务脚本)
[root@centos6 ~]# cp /etc/rc.d/init.d/httpd /etc/rc.d/init.d/httpd24
[root@centos6 ~]# vim /etc/rc.d/init.d/httpd24
apachectl=/apps/httpd24/bin/apachectl
httpd=${HTTPD-/apps/httpd24/bin/httpd}
pidfile=${PIDFILE-/apps/httpd24/logs/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd24}
[root@centos6 ~]# chkconfig -add httpd24
[root@centos6 ~]# chkconfig -list httpd24
编译安装httpd-2.4方法二
将apr和httpd一起进行编译安装。
1.将apr 和apr-util源码与httpd 源码合并
tar xf apr-1.7.0.tar.bz2
tar xf apr-util-1.6.1.tar.bz2
tar xf httpd-2.4.54.tar.bz2
mv apr-1.7.0 httpd-2.4.54/srclib/apr
mv apr-util-1.6.1 httpd-2.4.54/srclib/apr-util
ls httpd-2.4.54/srclib/
apr apr-util Makefile.in
- 将三者一并编译并安装
--with-included-apr
cd httpd-2.4.54/
./configure \
--prefix=/apps/httpd24 \
--enable-so \
--enable-ssl \
--enable-cgi \
--enable-rewrite \
--with-zlib \
--with-pcre \
--with-included-apr \
--enable-modules=most \
--enable-mpms-shared=all \
--with-mpm=prefork
make -j 4 && make install
安装后的配置和方法一相同。
安装完httpd服务后,启动httpd服务的方法
systemctl enable|disable httpd.service
systemctl {start|stop|restart|status|reload} httpd.service
apachectl start|stop|restart|configtest
service httpd configtest