linux apache24 使用,Linux下安装Apache 服务器并使用systemctl命令进行控制

安装依赖:

yum install gcc expat-devel openssl-devel pcre pcre-devel libxm12-devel libtool

额外依赖:安装包放在/usr/local/src

cd /usr/local/src

mkdir /usr/local/dependence #新建依赖文件夹

1.apr-1.7.0:

cd /usr/local/src

wget https://mirror.bit.edu.cn/apache//apr/apr-1.7.0.tar.gz

tar -zxvf apr-1.7.0.tar.gz

编译安装:

cd apr-1.7.0

./configure --prefix=/usr/local/dependence/apr # 我的编译安装地址

make

make install

如果报错:rm: cannot remove `libtoolT': No such file or directory

在configure里面 把RM='$RM'改为RM='$RM  -f' 即可

2.apr-util-1.6.1:

cd /usr/local/src

wget https://mirror.bit.edu.cn/apache//apr/apr-util-1.6.1.tar.gz

tar -zxvf apr-util-1.6.1.tar.gz

编译安装:

cd apr-util-1.6.1

./configure --prefix=/usr/local/dependence/apr-util --with-apr=/usr/local/dependence/apr #我的编译安装地址

make

make install

如果上述两个链接失效,那么进官网查看最新版本 :https://apr.apache.org/download.cgi

下载Apache源码:官网地址:https://httpd.apache.org/download.cgi#apache24

cd /usr/local/src

wget https://mirror.bit.edu.cn/apache//httpd/httpd-2.4.43.tar.gz

tar -zxvf httpd-2.4.43.tar.gz

我下载的地址为 /usr/local/src

进行编译安装:注意--with-apr=路径(为你安装apr的路径)

cd httpd-2.4.43

./configure --prefix=/usr/local/apache/ --with-apr=/usr/local/dependence/apr/ --with-apr-util=/usr/local/dependence/apr-util/ --enable-so --enable-ssl --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support

make

make install

进入Apache下的bin目录

cd /usr/local/apache/bin

打开httpd服务

./apachectl start

如果报错:

22a6917ad6226d0f32e2133e38a65b79.png

去/usr/local/apache/conf文件下 修改配置文件,为其添加域名即可

cd /usr/local/apache/conf

vim httpd.conf

b8e5b0d8e7ab88597ef43b49c587063d.png

再次启动

使用systemctl进行控制httpd服务

1.找到apachectl所在文件路径

find / -name apachectl

94b876179c78277157efcea93ee933f0.png

2.将其拷贝到/etc/rc.d/init.d目录下,并且重新命名为httpd (服务名称)

cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd

3.在相应的启动级别如3,5中加入链接

ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc3.d/S61httpd

4.修改配置文件httpd,在#!/bin/sh下面添加两行

cd /etc/rc.d/init.d

vim httpd

38b956ef6989726b2d8061f65df51810.png

5.保存后执行

chkconfig --add httpd

如果报错error reading information on service httpd : No such file or directory

chkconfig httpd on

6.查看系统服务

chkconfig --list

7.使用systemctl控制httpd服务

(1)查看状态

systemctl status httpd

(2)停止服务

systemctl stop httpd

(3)启动服务

systemctl start httpd

(4)重启服务

systemctl restart httpd

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值