linux(Redhat7)安装Apache

1.下载apache安装包以及安装依赖的包(apr、apr-util、pcre)
wget https://mirrors.cnnic.cn/apache/httpd/httpd-2.4.37.tar.gz
wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz
wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz
wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.zip
2.解压安装
tar -zxvf http-2.4.34.tar.gz
tar -zxvf apr-1.5.2.tar.gz
tar -zxvf apr-util-1.3.12.tar.gz
unzip pcre-8.10.zip
3.进入相应的目录
cd apr-1.5.2
./configure --prefix=/usr/local/apr/
make
make install
cd ../
cd apr-util-1.3.12
./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/
make
make install
cd ../

cd pcre-8.10
./configure --prefix=/usr/local/pcre/
make
make install
cd ../
注:g++编译错误可以参考 https://www.cnblogs.com/byf-soft/p/10134756.html
cd httpd-2.4.37
./configure --prefix=/usr/local/apache/ --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/
make
make install
cd /usr/local/apache/conf
vi httpd.conf
打开ServerName 地址改为本机地址 我的地址是192.168.48.133:80
cd ../bin
./apachectl start

打开浏览器访问http://192.168.48.133:80

如果不能访问 在本机curl http://192.168.48.133:80
若是可以显示页面信息,则有可能是防火墙的原因
关闭防火墙
systemctl stop firewalld(暂时关闭)
重新打开浏览器访问http://192.168.48.133:80












相关文章