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
然后再打開網頁就成功了