httpd-2.4编译安装基本步骤
Httpd-2.4
????1.mpm支持運行dos機制
????2.支持event mpm
????3.支持異步讀寫
????4.支持每模塊及每個目錄分別使用各自的日志級別;
????5.每請求配置;
????6.增強版的表達式分析
????7.支持毫秒級別的keeplive timeout
????8.基于fqdn的虛擬主機不再需要namevirtualhost指令;
????9.支持用戶自定義變量
新模塊:
????1.mod_proxy_fcgi
????2.Mod_ratelimt
????3.Mod_remoteip
????
????修改了一些配置機制;
????不再支持使用order,deny,allow對ip進行訪問控制
????
????httpd依賴于apr,apr-util,apr-icon
????apr:apache portable runtime ?可移植運行庫
安裝過程:
1.先安裝開發環境:
yum?groupinstall?"Development?Tools"?"Server?Platform?Development"?-y yum?install?-y?pcre-devel?zlib-devel要安裝1.4以上版本apr 以及apr-until
????
2.下載安裝apr-1.5.2
[root@localhost?~]#?wget?http://mirrors.hust.edu.cn/apache//apr/apr-1.5.2.tar.gz? tar?-zxvf?apr-1.5.2.tar.gz cd?apr-1.5.2 ./configure?--prefix=/usr/local/apr make? make?install3.下載安裝apr-until-1.5.4
[root@localhost?~]#?wget?http://mirrors.cnnic.cn/apache//apr/apr-util-1.5.4.tar.gz tar?-zxvf?apr-util-1.5.4.tar.gz? cd?apr-util-1.5.4 ./configure?--prefix=/usr/local/apr-util?--with-apr=/usr/local/apr make make?install4.下載http-2.4.17
wget?http://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.17.tar.gz [root@localhost?httpd-2.4.17]#?tar?-zxvf?httpd-2.4.17.tar.gz????????????????????? ??
| --prefix | 指定httpd2.4的安裝路徑 |
| --sysconfdir | 指定配置文件路徑 |
| --enable-so | 啟動sharedobject共享對象 |
| --enable-ssl | 啟用ssl,借助于此可以實現HTTPS訪問 |
| --enable-cgi | 啟用CGI,可以實現CGI腳本執行 |
| --enable-rewrite | 啟用Rewrite重寫,能夠實現諸如301重定向的功能,以來PCRE包 |
| --with-zlib | 啟用zlib壓縮 |
| --with-pcre | 啟用PCRE |
| --with-apr | 指定apr的路徑,httpd2.4依賴apr1.4版本以上,所以要指明 |
| --with-apr-util | 指定apr-util的路徑,同上 |
| --enable-modules | 啟用哪些模塊加載,most盡可能多的 |
| --enable-mpms-shared=all | http2.4上prefork、worker、event是模塊化的,可以動態加載 |
| --with-mpm=prefork | 指明默認的httpd2.4 MPM,即運行在prefork模型下 |
修改系統用戶:
[root@localhost?apache]#?vim?/etc/httpd/httpd.conf #User?daemon #Group?daemonUser?apache Group?apache?編譯安裝網頁存放目錄:/usr/local/apache/htdocs
?ln -sv /usr/local/apache/include/ /usr/include/httpd
? ? ? ??
?啟動服務:添加環境變量,找到apachectl 命令路徑:
vim?/etc/profile.d/httpd.sh export?PATH=/usr/local/apache/bin:$PATH apachectl?start或者用hash -r命令清除搜索記錄:
httpd -M 查看全部模塊
查看系統進程:http已經啟動完畢。
[root@localhost?~]#?ps?aux?|?grep?httpd root??????41702??0.0??0.1??72108??1968??????????Ss???01:15???0:00?/usr/local/apache/bin/httpd?-k?start apache????41703??0.0??0.1??72108??1400??????????S????01:15???0:00?/usr/local/apache/bin/httpd?-k?start apache????41704??0.0??0.1??72108??1400??????????S????01:15???0:00?/usr/local/apache/bin/httpd?-k?start apache????41705??0.0??0.2??72108??2040??????????S????01:15???0:00?/usr/local/apache/bin/httpd?-k?start apache????41706??0.0??0.1??72108??1400??????????S????01:15???0:00?/usr/local/apache/bin/httpd?-k?start apache????41707??0.0??0.2??72108??2032??????????S????01:15???0:00?/usr/local/apache/bin/httpd?-k?start apache????41902??0.0??0.1??72108??1408??????????S????02:03???0:00?/usr/local/apache/bin/httpd?-k?start apache????41903??0.0??0.1??72108??1408??????????S????02:03???0:00?/usr/local/apache/bin/httpd?-k?start apache????41904??0.0??0.1??72108??1408??????????S????02:03???0:00?/usr/local/apache/bin/httpd?-k?start root??????41919??0.0??0.0?103304???888?pts/0????S+???02:06???0:00?grep?httpd [root@localhost?~]## Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/usr/local/apache/logs/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0
STOP_TIMEOUT=${STOP_TIMEOUT-10}
配置:
1:切換使用mpm:
打開配置文檔找到以下模塊位置:
LoadModule?mpm_prefork_module?modules/mod_mpm_prefork.so #LoadModule?mpm_worker_module?modules/mod_mpm_worker.soNAME:prefork,event,worker
2:修改“main”server的DocumentRoot
打開:
[root@localhost ~]# vim /etc/httpd/httpd.conf
找到:
#?DocumentRoot:?The?directory?out?of?which?you?will?serve?your #?documents.?By?default,?all?requests?are?taken?from?this?directory,?but #?symbolic?links?and?aliases?may?be?used?to?point?to?other?locations. # DocumentRoot?"/usr/local/apache/htdocs"?修改兩個主頁目錄 <Directory?"/usr/local/apache/htdocs">???同上,并且一致????????
3:基于ip的訪問控制法則
???????允許所有主機訪問:Require all granted
????????拒絕所有主機訪問:Require all deny
????????控制特定ip訪問:
????????require ip IPADDR:授權指定來源的主機訪問
????????Require not ip IPADDR:拒絕指定來源地址的主機訪問
????????
????????ipADDR:
????????ip:192.168.1.1
????????network/mask 192.168.1.0/24
????????Network/Lenth
????????
????????HostName:
????????FqDN
????????DOMAIN:
4:虛擬主機配置:
基于IP,port和FQDN
基于FQDN不再需要NameVirtualHost指令
(1)需要注釋掉中心主機:
?
#?DocumentRoot:?The?directory?out?of?which?you?will?serve?your #?documents.?By?default,?all?requests?are?taken?from?this?directory,?but #?symbolic?links?and?aliases?may?be?used?to?point?to?other?locations. # #DocumentRoot?"/usr/local/apache/htdocs"? #<Directory?"/usr/local/apache/htdocs">(2)找到配置文件里的以下參數:
(3)進入到extra目錄下:找到httpd-vhosts.conf
[root@localhost?~]#?cd?/etc/httpd/extra/ [root@localhost?extra]#?ls httpd-autoindex.conf??httpd-default.conf??httpd-languages.conf??httpd-mpm.conf?????????????????httpd-ssl.conf??????httpd-vhosts.conf httpd-dav.conf????????httpd-info.conf?????httpd-manual.conf?????httpd-multilang-errordoc.conf??httpd-userdir.conf??proxy-html.conf [root@localhost?extra]#?
打開httpd-vhosts.conf配置文件:
修改參數,以下實例參考:
<VirtualHost?*:80>ServerAdmin?webadmin@a.comDocumentRoot?"/vhost/www.a.com/htdoc/"ServerName?www.a.comServerAlias?a.comErrorLog?"logs/www.a.com-error_log"CustomLog?"logs/www.a.com-access_log"?combined<Directory?"/vhost/www.a.com/htdoc/">Options?NoneAllowOverride?noneRequire?all?granted</Directory> </VirtualHost>修改啟動腳本參數為以下內容: ? ? ? ?
apachectl=/usr/local/apache/bin/apachectl httpd=${HTTPD-/usr/local/apache/bin/httpd} prog=httpd pidfile=${PIDFILE-/usr/local/apache/logs/httpd.pid} lockfile=${LOCKFILE-/var/lock/subsys/httpd} RETVAL=0 STOP_TIMEOUT=${STOP_TIMEOUT-10}轉載于:https://blog.51cto.com/houzhimeng/1703921
總結
以上是生活随笔為你收集整理的httpd-2.4编译安装基本步骤的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: putty network error:
- 下一篇: Redis监控技巧总结