Centos8 源码安装Apache

1、系统版本

cat /etc/redhat-release

Centos8 源码安装Apache

其它系统版本可参考

2、下载Apache2.2

官网地址:http://httpd.apache.org/download.cgi

Centos8 源码安装Apache

2.1 xshell6上传httpd-2.4.46.tar.gz包

Centos8 源码安装Apache

2.2 解压缩

tar -zxvf httpd-2.4.46.tar.gz

Centos8 源码安装Apache

Centos8 源码安装Apache

3、编译安装httpd

进入httpd-2.4.46文件夹

Centos8 源码安装Apache

cd httpd-2.4.46

输入安装命令:

 ./configure --prefix=/opt/httpd --enable-module=shared

Centos8 源码安装Apache

缺少APR环境包

3.1安装APR

安装命令:

yum -y install apr-devel apr-util-devel

Centos8 源码安装Apache

重新执行安装Apache命令  ./configure --prefix=/opt/httpd --enable-module=shared

Centos8 源码安装Apache

缺少gcc编辑器环境

3.2 gcc安装命令:

yum -y install gcc automake autoconf libtool make

yum -y install gcc gcc-c++

Centos8 源码安装Apache

重新执行安装Apache命令 ./configure --prefix=/opt/httpd --enable-module=shared

缺少pcer环境

Centos8 源码安装Apache

3.3pcre安装命令:

dnf -y install pcre-devel

Centos8 源码安装Apache

重新执行安装Apache命令 ./configure --prefix=/opt/httpd --enable-module=shared

如下图所示安装完成

Centos8 源码安装Apache

4、make编译

输入命令:make

Centos8 源码安装Apache

缺少redhat环境

4.1 安装redhat

dnf -y install redhat-rpm-config

Centos8 源码安装Apache重新make编译

Centos8 源码安装Apache

4.2执行make install 安装命令

make install

Centos8 源码安装Apache

5、启动Apache

输入命令:/opt/httpd/bin/apachectl start

Centos8 源码安装Apache

需要修改apache地址

 

进入Apache安装路径,编辑httpd.conf文件,搜索"#ServerName",添加ServerName 192.168.xx.xxx:80(服务器电脑IP地址),wq保存

Centos8 源码安装Apache

Centos8 源码安装Apache

 

重启Apache

/opt/httpd/bin/apachectl restart

网址输入:192.168.11.194:80

如果网页不能打开,查看防火墙80端口时候开放

firewall-cmd --query-port=80/tcp

Centos8 源码安装Apache

no表示没有开发80端口

开启80端口

firewall-cmd --zone=public --add-port=80/tcp --permanent

Centos8 源码安装Apache

重启防火墙

firewall-cmd --reload

Centos8 源码安装Apache

Centos8 源码安装Apache

80端口已开放,打开网址192.168.11.194:80

Centos8 源码安装Apache