新聞中心
Apache HTTP Server(簡稱Apache)是Apache軟件基金會的一個(gè)開放源碼的網(wǎng)頁服務(wù)器,可以在大多數(shù)計(jì)算機(jī)操作系統(tǒng)中運(yùn)行,由于其多平臺和安全性被廣泛使用,是最流行的Web服務(wù)器端軟件之一,下面為大家分享一下如何通過源碼編譯的方式安裝apache2.4。

公司主營業(yè)務(wù):成都網(wǎng)站建設(shè)、網(wǎng)站制作、移動網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。創(chuàng)新互聯(lián)公司是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會用頭腦與智慧不斷的給客戶帶來驚喜。創(chuàng)新互聯(lián)公司推出天橋免費(fèi)做網(wǎng)站回饋大家。
本文檔使用的源碼包地址 鏈接:https://pan.baidu.com/s/110RWf3VC8J3oJhgYq5jU2w 提取碼:pdc0
實(shí)戰(zhàn)
[root@Jaking12 ~]# yum install -y gcc pcre pcre-devel expat-devel bzip2 openssl-devel zlib* libtool
[root@Jaking12 src]# rz
[root@Jaking12 src]# tar xvf apr-1.7.0.tar.gz
[root@Jaking12 src]# ls
apr-1.7.0 apr-1.7.0.tar.gz
[root@Jaking12 src]# cd apr-1.7.0
[root@Jaking12 apr-1.7.0]# ./configure --prefix=/usr/local/apr
[root@Jaking12 apr-1.7.0]# make
[root@Jaking12 apr-1.7.0]# make install
[root@Jaking12 apr-1.7.0]# cd ..
[root@Jaking12 src]# rz
rz waiting to receive.
zmodem trl+C ?
100% 541 KB 541 KB/s 00:00:01 0 Errors..
[root@Jaking12 src]# ls
apr-1.7.0 apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz
[root@Jaking12 src]# tar xf apr-util-1.6.1.tar.gz
[root@Jaking12 src]# ls
apr-1.7.0 apr-1.7.0.tar.gz apr-util-1.6.1 apr-util-1.6.1.tar.gz
[root@Jaking12 src]# cd apr-util-1.6.1
[root@Jaking12 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@Jaking12 apr-util-1.6.1]# make
[root@Jaking12 apr-util-1.6.1]# make install
更多的選項(xiàng)可以通過./configure --help 了解
官方的編譯選項(xiàng)文檔http://httpd.apache.org/docs/current/programs/configure.html
--prefix=/usr/local/apache
--sysconfdir=/etc/httpd // 指定配置文件在安裝在哪個(gè)路徑。如不指定,配置文件就在程序安裝的目錄;如指定/etc目錄
--with-apr=/usr/local/apr // 指定依賴的apr路徑。注意必須指明路徑,否則編譯時(shí)會自動去找/usr下的apr,而不是編譯的高版本apr,下同
--with-apr-util=/usr/local/apr-util
--with-mpm=MPM //指定默認(rèn)的 [prefork | worker | event] 如3種MPM模塊都編譯了,則通過此項(xiàng)指定默認(rèn)使用哪種
--with-pcre //依賴pcre庫用于解決正則表達(dá)式問題。 ## 安裝 pcre-devel(兼容Perl的正則表達(dá)式庫)
--enable-so //打開 so 模塊,啟用動態(tài)裝載模塊功能
--enable-ssl //啟用ssl功能。注意要先安裝,https使用
--enable-cgi //啟用cgi功能,為非線程方式工作的mpm使用
--enable-cgid //以線程工作(worker/event)的mpm使用
--enable-rewrite //支持 URL 重寫
--enable-zlib //通用壓縮機(jī)制
--enable-module=most //[ all | most | ……] 指定啟用哪些模塊。可指定具體的模塊名,也可使用all表示啟用所有模塊,most表示啟用大多數(shù)常用模塊。
一般使用most即可
--enable-mpms-shared=all //啟用MPM支持的模式,啟用哪種mpm(prefork,worker,event),使用worker或event時(shí)要另外一種方式編譯php(編譯時(shí)使用了–enable-maintainer-zts選項(xiàng))
--enable-deflate //傳輸壓縮機(jī)制,節(jié)約帶寬提供對內(nèi)容的壓縮傳輸編碼支持一般是html、js、css等內(nèi)容的站點(diǎn)。使用此參數(shù)會大大
提高傳輸速度提升訪問者訪問的體驗(yàn)。在生產(chǎn)環(huán)境中這是apache調(diào)優(yōu)的一個(gè)重要選項(xiàng)之一
[root@Jaking12 apr-util-1.6.1]# cd ..
[root@Jaking12 src]# rz
rz waiting to receive.
zmodem trl+C ?
100% 8983 KB 8983 KB/s 00:00:01 0 Errors
[root@Jaking12 src]# ls
apr-1.7.0 apr-1.7.0.tar.gz apr-util-1.6.1 apr-util-1.6.1.tar.gz httpd-2.4.39.tar.gz
[root@Jaking12 src]# tar xf httpd-2.4.39.tar.gz
[root@Jaking12 src]# ls
apr-1.7.0 apr-util-1.6.1 httpd-2.4.39
apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.39.tar.gz
[root@Jaking12 src]# cd httpd-2.4.39
[root@Jaking12 httpd-2.4.39]# ./configure --prefix=/usr/local/apache24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-mpm=event
[root@Jaking12 httpd-2.4.39]# make
[root@Jaking12 httpd-2.4.39]# make install
所有組件 /usr/local/apache24
主配置文件 /usr/local/apache24/conf
啟動腳本 /usr/local/apache24/bin/apachectl
[root@Jaking12 httpd-2.4.39]# ls /usr/local/apache24/
bin build cgi-bin conf error htdocs icons include logs man manual modules
[root@Jaking12 httpd-2.4.39]# ls /usr/local/apache24/conf/
extra httpd.conf magic mime.types original
[root@Jaking12 httpd-2.4.39]# ls /usr/local/apache24/bin/
ab apxs dbmmanage envvars-std htcacheclean htdigest httpd logresolve
apachectl checkgid envvars fcgistarter htdbm htpasswd httxt2dbm rotatelogs
[root@Jaking12 httpd-2.4.39]# ll /usr/local/apache24/bin/apachectl
-rwxr-xr-x 1 root dip 3440 Mar 10 16:45 /usr/local/apache24/bin/apachectl
啟動 apache2.4
[root@Jaking12 httpd-2.4.39]# /usr/local/apache24/bin/apachectl
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::250:56ff:fe2c:fe97%ens33. Set the 'ServerName' directive globally to suppress this message 這是一個(gè)提示,問題不大 (⊙o⊙)…
重啟 apache2.4
[root@Jaking12 httpd-2.4.39]# /usr/local/apache24/bin/apachectl graceful
查看 apache2.4 相關(guān)信息
[root@Jaking12 httpd-2.4.39]# netstat -pantul | grep 80
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 807/sshd
tcp6 0 0 :::80 :::* LISTEN 35199/httpd
tcp6 0 0 :::22 :::* LISTEN 807/sshd
[root@Jaking12 httpd-2.4.39]# grep DocumentRoot /usr/local/apache24/conf/httpd.conf
# DocumentRoot: The directory out of which you will serve your
DocumentRoot "/usr/local/apache24/htdocs"
# access content that does not live under the DocumentRoot.
[root@Jaking12 httpd-2.4.39]# ls /usr/local/apache24/htdocs
index.html
[root@Jaking12 httpd-2.4.39]# cat /usr/local/apache24/htdocs/index.html
It works!
源碼編譯 apache2.4源碼編譯 apache2.4
自定義首頁內(nèi)容
[root@Jaking12 httpd-2.4.39]# vim /usr/local/apache24/htdocs/index.html
It works!
Hello World!
源碼編譯 apache2.4源碼編譯 apache2.4
設(shè)置文件共享服務(wù)
[root@Jaking12 httpd-2.4.39]# cd /usr/local/apache24/htdocs/
[root@Jaking12 htdocs]# ls
index.html
[root@Jaking12 htdocs]# touch file{1..10}
[root@Jaking12 htdocs]# ls
file1 file10 file2 file3 file4 file5 file6 file7 file8 file9 index.html
[root@Jaking12 htdocs]# mv index.html index.html.bak
[root@Jaking12 htdocs]# ls
file1 file10 file2 file3 file4 file5 file6 file7 file8 file9 index.html.bak
源碼編譯 apache2.4源碼編譯 apache2.4
總結(jié)
至此,實(shí)戰(zhàn)演示源碼編譯 apache2.4完畢。
名稱欄目:如何通過源碼編譯的方式安裝apache2.4
網(wǎng)站URL:http://www.dlmjj.cn/article/cdhjpch.html


咨詢
建站咨詢
