rpm -qa httpd 检查httpd 是否存在
下载apache
wget -q http://mirror.bit.edu.cn/apache/httpd/httpd-2.2.27.tar.gz
解压httpd
tar zxvf httpd-2.4.43.tar.gz
安装依赖:
# yum install zlib zlib-devel -y
进入apache目录
# cd httpd-2.4.43
编译
# ./configure
如果报错configure: error: APR not found. Please read the documentation
安装 apr 和 apr-util
yum list apr*
查看位数 32 还是 64
getconf LONG_BIT
arch
yum install apr-devel.x86_64
yum install apr-util-devel.x86_64
再次进入apache目录 编译
./configure
默认安装在 /usr/local/apach2 目录下 进入bin目录
# /usr/local/apache2/bin/apachectl start
如果报错:
AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, Set the ‘ServerName’ directive globally to suppress this message
进入 apache2/conf 目录下
cd /usr/local/apache2/conf/
修改conf/httpd.conf
ServerName,去掉#注释,然后修改值为localhost:80
ServerName localhost:80
开启apache
# /usr/local/apache2/bin/apachectl start
再次报错:
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
检查80端口被什么程序占用:
netstat -lnp|grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 22757/nginx: master
经过查看 发现是nginx
停止nginx
/usr/local/nginx/sbin/nginx -s stop
最后启动apache
/usr/local/apache2/bin/apachectl start
成功!