1:獲取安裝包 建立一個目錄 用來掛載宿主機上共享文件裏的 apache安裝包。
2:而後解壓 httpd 、apr、apr-util 壓縮包 到 /opt 目錄下
3:將目錄下的 apr、apr-util 複製到httpd目錄下的srclib目錄下 並命名爲apr、apr-util
4: 用yum 安裝 gcc gcc-c++ make perl pcre-devel expat-devel libxml2-devel 環境html
# mount.cifs //192.168.100.1/gx /gx # tar xzvf httpd-2.4.2.tar.gz -C /opt # tar xzvf apr-1.4.6.tar.gz -C /opt (支持Apache上層應用跨平臺,提供底層接口庫) # tar xzvf apr-util-1.4.1.tar.gz -C /opt # cp -R apr-1.4.6 /opt/httpd-2.4.2/srclib/apr # cp -R apr-util-1.4.1 /opt/httpd-2.4.2/srclib/apr-util # yum install gcc gcc-c++ make perl pcre-devel expat-devel libxml2-devel -y
5 :編譯&&編譯安裝
前端
# cd /opt/httpd-2.4.2 # ./configure \ --prefix=/usr/local/apache \ --enable-so \ --enable-rewrite \ --enable-mods-shared=most \ --with-mpm=worker \ --disable-cgid \ --disable-cgi # make && make install
6:過濾apachectl的# 重定向保存到/etc/init.d/httpd中 (啓動腳本)linux
# grep -v "#" /usr/local/apache/bin/apachectl > /etc/init.d/httpd # vi /etc/init.d/httpd 在開頭插入下面 #!/bin/sh # chkconfig:2345 85 15 # description:Apache is a World Wide Web server.
7:給httpd腳本開啓執行權限、添加服務 c++
# chmod +x /etc/init.d/httpd //給httpd開啓執行權限 # chkconfig --add httpd //添加httpd服務 # chkconfig --list httpd //查看httpd服務 # chkconfig --level 35 httpd on //把httpd服務的3 5開啓
8:給httpd.conf 建立一個軟鏈接 方便管理 web
# ln -s /usr/local/apache/conf/httpd.conf /etc/httpd.conf # vim /etc/httpd.conf Listen:192.168.100.111:80 //修改監聽IP ServerName www.yun.com:80 //修改域名
9:重啓httpd服務、關閉防火牆apache
# service httpd stop # service httpd start # service iptables stop # setenforce 0
11:在瀏覽器上輸入以前 設置的監聽IP
vim