设为首页 加入收藏

TOP

Linux 安装Httpd服务(三)
2023-07-23 13:35:49 】 浏览:55
Tags:Linux 安装 Httpd 服务
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
  1. 将三者一并编译并安装
    --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启动

  • apachectl启动:apachectl是httpd服务自带的一个脚本

systemctl enable|disable httpd.service

systemctl {start|stop|restart|status|reload} httpd.service

apachectl start|stop|restart|configtest

service httpd configtest
首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇linux包管理器rpm和dpkg的使用说明 下一篇lnmp部署

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目