Linux基础服务篇,源码构建Apache-WEB服务器
1.下载源码包百度输入包名httpd-2.2.27.tar.gz
2.wget下载:http://archive.apache.org/dist/httpd/httpd-2.2.27.tar.gz
3.解压下载文件
A: tar -xzf httpd-2.2.27.tar.gz 以tar.gz结尾的安装包
B: tar -jxf httpd-2.2.27.tar.bz2 以tar.bz2结尾的安装包
4.yum install apr apr-util apr-devel apr-util-devel #首先安装APR
5../configure –prefix=/usr/local/apache2 #安装到user/local/apache2文件夹目录下
./configure --prefix=/usr/local/apache --enable-so --enable-rewrite 使用此条命令编译
6.这个时候报错安装gcc或者gcc-c++
yum list gcc-c++
yum install gcc-c++
7.Make
8.Make install
9.修改/usr/local/apache2/conf下的httpd.conf
编辑LISTEN 80
10.源码包安装Apache默认发布目录为:/usr/local/apache2/htdocs/下有一个网页index.html
使用vi index.html填入一下测试代码
<html><body><h1>it works!</h1></body></html>
11.ps -ef |grep http #检测服务是否启动
/usr/local/apache2/bin/apachectl start #启动 报错不管
/usr/local/apache/bin/apachectl restart #使用此条命令进行启动Apache
12.ps -ef |grep httpd #检测服务是否启动
13.netstat -an |grep 80
netstat -ntl |grep 80
14.浏览器输入IP打开网页,如果打不开考虑是不是防火墙
/etc/init.d/iptables status
/etc/init.d/iptables stop
centos7关闭防火墙操作命令如下
systemctl stop firewalld
然后再打开网页就成功了