1、系统版本
cat /etc/redhat-release
其它系统版本可参考
2、下载Apache2.2
官网地址:http://httpd.apache.org/download.cgi
2.1 xshell6上传httpd-2.4.46.tar.gz包
2.2 解压缩
tar -zxvf httpd-2.4.46.tar.gz
3、编译安装httpd
进入httpd-2.4.46文件夹
cd httpd-2.4.46
输入安装命令:
./configure --prefix=/opt/httpd --enable-module=shared
缺少APR环境包
3.1安装APR
安装命令:
yum -y install apr-devel apr-util-devel
重新执行安装Apache命令 ./configure --prefix=/opt/httpd --enable-module=shared
缺少gcc编辑器环境
3.2 gcc安装命令:
yum -y install gcc automake autoconf libtool make
yum -y install gcc gcc-c++
重新执行安装Apache命令 ./configure --prefix=/opt/httpd --enable-module=shared
缺少pcer环境
3.3pcre安装命令:
dnf -y install pcre-devel
重新执行安装Apache命令 ./configure --prefix=/opt/httpd --enable-module=shared
如下图所示安装完成
4、make编译
输入命令:make
缺少redhat环境
4.1 安装redhat
dnf -y install redhat-rpm-config
重新make编译
4.2执行make install 安装命令
make install
5、启动Apache
输入命令:/opt/httpd/bin/apachectl start
需要修改apache地址
进入Apache安装路径,编辑httpd.conf文件,搜索"#ServerName",添加ServerName 192.168.xx.xxx:80(服务器电脑IP地址),wq保存
重启Apache
/opt/httpd/bin/apachectl restart
网址输入:192.168.11.194:80
如果网页不能打开,查看防火墙80端口时候开放
firewall-cmd --query-port=80/tcp
no表示没有开发80端口
开启80端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
重启防火墙
firewall-cmd --reload
80端口已开放,打开网址192.168.11.194:80