centos7.2源码安装Apache2.4

ps:学了这么久计算机了一直是想到什么查什么,下次又要用时又忘了.总是这样无休止的循环下去,今天终于决定改变一下了,写个博客做个总结吧.

centos7.2源码安装Apache2.4


以前总是用yum安装软件,因为yum工具非常方便会帮你把依赖软件也一起装了,后来发现yum也不是那么好用,有时候死活装不上软件…..


服务器环境是centos7.2(目前最新),由于服务器重装后,现在服务器非常干净什么也没有先来做一些准备吧.

  • 安装相关软件包gcc gcc++ zlib zlib-devel
yum -y install gcc gcc++ zlib zlib-devel#如果报错可以试试一个一个的安装
  • 1

下载所需软件源码包

可以使用linux的wget下载也可以在本地左面环境下载好了上传到服务器解

压软件包使用tar -xf 软件包

 tar -xf  httpd-2.4.25.tar.gz #先用cd命令切换到软件包所在的目录,用ls命令查看当前目录内容
  • 1

开始安装

安装apr

 cd apr-1.5.2#进入解压的软件包目录里面
 /*编译安装*/
 ./configure --prefix=/usr/local/apr/
 make && make install
  • 1
  • 2
  • 3
  • 4

安装apr-Util

 cd apr-1.5.4#进入解压的软件包目录里面
 /*编译安装*/
 ./configure --prefix=/usr/local/apr-util/  --with-apr=/usr/local/apr/ 
 make && make install


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

安装pcrel

 cd pcre-8.40#进入解压的软件包目录里面
 /*编译安装*/
 ./configure --prefix=/usr/local/pcre/
 make && make install
  • 1
  • 2
  • 3
  • 4

安装Apache

 cd httpd-2.4.25#进入解压的软件包目录里面
 /*编译安装*/
 ./configure --prefix=/usr/local/apache24/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/
 make && make install
  • 1
  • 2
  • 3
  • 4

启动Apache

cd /usr/local/apache24/bin/
./apachectl start #开启:start 停止:stop 重启:restart
systemctl stop firewalld.service #顺便把防火墙关了
systemctl disable firewalld.service#不让防火墙开机自启动

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
添加Apache自启动
cp /usr/local/apache24/bin/apachectl /etc/rc.d/init.d/httpd
vim /etc/rc.d/init.d/httpd #编辑httpd文件
  • 1
  • 2
  • 3
#!/bin/sh下面添加以下两句后保存
#chkconfig: 345 70 70
#description: apache
  • 1
  • 2
chkconfig: 2345 70 60中的2345是指脚本的运行级别,即在2345这4种模式下都可以运行,234都是文本界面,5是图形界面X,70是指脚本将来的启动顺序号,如果别的程序的启动顺序号比70小(比如44、45),则脚本需要等这些程序都启动以后才启动。60是指系统关闭时,脚本的停止顺序号


把Apache添加到系统服务并自启
chkconfig --add httpd #加入系统服务
chkconfig httpd on #开机自启
  • 1
  • 2

这样就可以使用systemctl start|stop|restart httpd 启动|关|重启Apache服务了


配置文件在Apache的安装目录(也就是安装Apache时–prefix=xxxx所指定的目录)下的conf目录下的httpd.conf

vim /usr/local/apache24/conf/httpd.conf#修改Apache配置文件
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值