在官網下載 源碼包
html
apr-1.5.1.tar.gzshell
apr-util-1.5.3.tar.gzapache
httpd-2.4.10.tar.gzbash
安裝用戶是root dom
解壓命令 tar -zxvf httpd-2.4.10.tar.gzcurl
源碼安裝 apr ,apr-utiltcp
./configure --prefix=/usr/local/aprui
報錯:rm: cannot remove `libtoolT': No such file or directory url
我直接忽略了,網上看有修改configure 解決這個 問題,此處沒有嘗試spa
make
make install
./configure --prefix=/usr/local/apr-util \
--with-apr=/usr/local/apr
make
make install
4 源碼安裝apache
4.1 安裝
./configure --prefix=/usr/local/apache \ --with-apr=/usr/local/apr \ --with-apr-util=/usr/local/apr-util \ --enable-dav \ --enable-module=so \ --enable-mods-shared=all make make install
4.2 修改原80端口爲8008
備份 cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak
修改點: Listen 8008
ServerName http://localhost:8008
4.3啓動apache
/usr/local/apache/bin/apachectl start
看到 <html><body><h1>It works!</h1></body></html>
成功
4.4配置 apachectl status 命令
備份 cp /usr/local/apache/conf/extra/httpd-info.conf /usr/local/apache/conf/extra/httpd-info.conf.bak 修改httpd-info.conf 整個文件修改以下 # # Get information about the requests being processed by the server # and the configuration of the server. # # Required modules: mod_authz_core, mod_authz_host, # mod_info (for the server-info handler), # mod_status (for the server-status handler) # # Allow server status reports generated by mod_status, # with the URL of http://servername/server-status # Change the ".example.com" to match your domain to enable. <Location /server-status> SetHandler server-status Order deny,allow #Deny from all Allow from all # Require host .example.com # Require ip 127 </Location> # # ExtendedStatus controls whether Apache will generate "full" status # information (ExtendedStatus On) or just basic information (ExtendedStatus # Off) when the "server-status" handler is called. The default is Off. # #ExtendedStatus On ExtendedStatus On <IFModule mod_info.c> <Location /server-info> SetHandler server-info Order deny,allow #Deny from all Allow from all </Location> </IFModule> # # Allow remote server configuration reports, with the URL of # http://servername/server-info (requires that mod_info.c be loaded). # Change the ".example.com" to match your domain to enable. #
修改http.conf
首先檢查文件裏有沒有
LoadModule status_module modules/mod_status.so
若是沒有,須要從新編譯 搜索
mod_status.so 多是./configure 命令和apapche 版本問題
而後修改配置文件,使httpd-info.conf 生效
# Real-time info on requests and configuration #Include conf/extra/httpd-info.conf Include conf/extra/httpd-info.conf
最後修改/usr/local/apache/bin/apachectl
#STATUSURL=" 改成下面 STATUSURL="http://localhost:8008/server-status"
./apachectl status 配置完成
4.5 apache 配置系統服務
# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd # cp /usr/local/apache/bin/apachectl /usr/local/bin/httpd # ln -s /etc/init.d/httpd /etc/rc.d/rc5.d/S61httpd # ln -s /etc/init.d/httpd /etc/rc.d/rc4.d/S61httpd # ln -s /etc/init.d/httpd /etc/rc.d/rc3.d/S61httpd 打開/etc/init.d/httpd文件在#!/bin/bash下面加入 #chkconfig:345 61 61 #description:Apache 執行chkconfig --list |grep httpd 就會出現httpd服務開機運行在345級別註冊服務 chkconfig --add httpd 設置啓動級別 chkconfig --levels 345 httpd on
4.6 在非本機訪問apache 在防火牆打開8008端口
/etc/sysconfig/iptables
添加
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8008 -j ACCEPT
重啓iptable
/etc/init.d/iptables restart
查看iptable 狀態
/etc/init.d/iptables status
完工。
參考了不少網上的資料,謝謝前輩們~~~~