wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.23.tar.gz
2.解压安装
tar -zxvf httpd-2.4.23.tar.gz
cd httpd-2.4.23
./confgure --frefix=/uer/local/Apache2
3.解决报错报错checking for APR... no
checking for APR... no
configure: error: APR not found . Please read the documentation
- 安装APR,下载所需软件包,如果此时计算机可以上网,执行命令下载文件:
wget http://archive.apache.org/dist/apr/apr-1.4.5.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
- apr not found问题
tar -zxf apr-1.4.5.tar.gz cd apr-1.4.5 ./configure --prefix=/usr/local/apr make && make install
- APR-util not found问题
tar -zxf apr-util-1.3.12.tar.gz cd apr-util-1.3.12 ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config make && make install
- pcre问题
unzip -o pcre-8.10.zip cd pcre-8.10 ./configure --prefix=/usr/local/pcre make && make install
----编译报错make[1]: *** [pcrecpp.lo] 错误 1,安装gcc-c++,重新编译pcre
yum -y install gcc-c++ ./configure make && make install
./configure --prefix=/usr/local/apache2 --enable-so --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
make install
5.更新iptables防火墙安全策略放开80端口号
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/etc/rc.d/init.d/iptables save
/etc/init.d/iptables restart
6.将Apache加入系统服务开启启动本机是CentOS6.8 防火墙是iptables ,7.0防火墙用的是firewall,具体方法请自行百度
- 添加到init.d目录
grep -v "#" /usr/local/apache2/bin/apachectl > /etc/init.d/apache
- 编辑文件在文件最开始添加
vi /etc/init.d/apache #!/bin/sh #chkconfig:2345 85 15 #description:Apache is a World Wide Web Server.
- 添加执行权限,并添加到系统服务,查看是否加入成功
7.启动服务并测试chmod +x /etc/init.d/apache chkconfig --add apache chkconfig --list
- 启动服务
service apache start 查看80端口确认服务是否启动 netstat -tan
在windows下用浏览器直接访问虚拟机IP,成功网页会输出 It works!
热门评论
不错哈哈不错哈哈不错哈哈