1、准备条件
1、httpd-2.4.34.tar.gz (最好是最新版本的,不要低于2.2版以下)
(下载地址:http://mirrors.shu.edu.cn/apache//httpd/httpd-2.4.34.tar.gz)
2、关闭selinux
setenforce 0 #临时关闭
vim /etc/selinux/config #永久关闭
把SELINUX=enforcing
改为SELINUX=disabled
3、关闭firewalld
systemctl stop firewalld #关闭firewalld
systemctl disable firewalld #开机自动关闭 firewalld
2、下载Apache
[root@jack711 ~]#cd /usr/local/src
[root@jack711 src]# wget http://mirrors.shu.edu.cn/apache//httpd/httpd-2.4.34.tar.gz
3、解压httpd-2.4.34.tar.gz
[root@jack711 src]#tar -zvxf httpd-2.4.34.tar.gz
4、安装依赖软件
[root@jack711 src]#yum -y install apr apr-devel apr-util apr-util-devel pcre pcre-devel
5、预编译
[root@jack711 src]#cd /usr/local/httpd-2.4.34
[root@jack711 httpd-2.4.34]#./configure -prefix=/usr/local/apache -enable-so -enable-rewrite -disable-proxy
prefix=/usr/local/apache #安装地址
enable-so
enable-rewrite
disable-proxy #跳过错误
6、编译安装
[root@jack711 httpd-2.4.34]#make &&make install
7、开机自启动
1、将apachectl添加到/etc/rc.d/init.d目录下,并改名为httpd
[root@jack711 ~]#cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd
/etc/rc.d/init.d/httpd和/etc/init.d/httpd是映射都一样
2、编辑/etc/init.d/httpd文件,在第二行添加两行:
chkconfig: 2345 70 40 #前面加“#”号
description:apache #前面加“#”号
3、把Apache服务添加为系统服务
chkconfig -add httpd
chkconfig httpd on
4、通过systemctl控制开启关闭
systemctl start httpd
systemctl stop httpd
systemctl status httpd