日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

Linux下编译安装Apache httpd 2.4

發布時間:2023/12/19 linux 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux下编译安装Apache httpd 2.4 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Apache是世界使用排名第一的Web服務器軟件。它可以運行在幾乎所有廣泛使用的計算機平臺上,由于其跨平臺和安全性被廣泛使用,是最流行的Web服務器端軟件之一。當前Apache版本為2.4,本文主要描述基于CentOS 6.5以源碼方式安裝Apache httpd。

一、編譯安裝的優勢

源碼的編譯安裝一般由3個步驟組成:配置(configure),通常依賴gcc編譯器,binutils,glibc。配置軟件特性,檢查編譯環境,生成 Makefile文件編譯(make)安裝(make install)優勢自定義軟件功能優化編譯參數,提高性能解決不必要的軟件間依賴方便清理與卸載configure是一個可執行腳本,它有很多選項,在待安裝的源碼路徑下使用命令./configure –-help輸出詳細的選項列表。 常用的選項 --prefix該選項是配置安裝的路徑,如果不配置該選項,安裝后可執行文件默認放在/usr /local/bin,庫文件默認放在/usr/local/lib,配置文件默認放在/usr/local/etc,其它的資源文件放在/usr /local/share如果配置--prefix,如: ./configure --prefix=/usr/local/test則可以把所有資源文件放在/usr/local/test的路徑中,不會雜亂。用了—prefix選項的另一個好處是卸載軟件或移植軟件。當某個安裝的軟件不再需要時,只須簡單的刪除該安裝目錄,就可以把軟件卸載得干干凈凈;移植軟件只需拷貝整個目錄到另外一個機器即可(相同的操作系統)。當然要卸載程序,也可以在原來的make目錄下用一次make uninstall,但前提是make文件指定過uninstall。

二、httpd的版本

版本:httpd-1.3httpd-2.0httpd-2.2httpd-2.4

三、httpd 2.4的新特性

1) MPM支持運行時裝載--enable-mpms-shared=all --with-mpm=prefork|worker|event 2) 支持event MPM 3) 異步讀寫支持 4) 支持每模塊及每目錄分別使用不同的日志級別 5) 支持per-request(即支持<If>, <ElseIf>, and <Else>條件判斷) 6) 增強版的表達式分析器; 7) 支持毫秒級keepalive timeout; 8) 基于FQDN(域名)的虛擬主機不再需要NameVirtualHost; 9) 支持用戶使用自定義變量; 新增一些模塊:mod_proxy_fcgi, mod_ratelimit, mod_request, mod_remoteip修改了一些配置機制:不再支持使用order, allow, deny來實現基于IP的訪問控制;

四、編譯安裝httpd 2.4

1、依賴關系 httpd依賴于apr, apr-utilapr全稱為apache portable runtime,能實現httpd跨平臺運行httpd-2.4 依賴于1.4+及以上版本的aprapr-1.5.0.tar.bz2apr-util-1.5.3.tar.bz2httpd-2.4.9.tar.bz2pcre-devel包openssl-devel2、編譯安裝 # yum install gcc# yum install pcre-devel# tar xf apr-1.5.0.tar.bz2# cd apr-1.5.0# ./configure --prefix=/usr/local/apr (--prefix指定apr安裝的目錄)# make# make install# tar xf apr-util-1.5.3.tar.bz2# cd apr-util-1.5.3# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr# make && make install ###該項被漏掉,補充@20160714# tar xf httpd-2.4.9.tar.bz2以下為幾個主要的配置項--sysconfdir=/etc/httpd24 指定配置文件路徑 --enable-so 啟動模塊動態裝卸載 --enable-ssl 編譯ssl模塊 --enable-cgi 支持cgi機制(能夠讓靜態web服務器能夠解析動態請求的一個協議) --enable-rewrite 支持url重寫 --Author : Leshami --with-zlib 支持數據包壓縮 --Blog : http://blog.csdn.net/leshami --with-pcre 支持正則表達式 --with-apr=/usr/local/apr 指明依賴的apr所在目錄 --with-apr-util=/usr/local/apr-util/ 指明依賴的apr-util所在的目錄 --enable-modules=most 啟用的模塊 --enable-mpms-shared=all 以共享方式編譯的模塊 --with-mpm=prefork 指明httpd的工作方式為prefork # cd httpd-2.4.9# ./configure \--with-apr=/usr/local/apr \ --with-apr-util=/usr/local/apr-util \ --prefix=/usr/local/apache \ --sysconfdir=/etc/httpd24 \ --enable-so \ --enable-ssl \ --enable-cgi \ --enable-rewrite \ --with-zlib \ --with-pcre \ --with-mpm=prefork \ --enable-modules=most \ --enable-mpms-shared=all # make # make install

五、配置http2.4啟動及停止

1、修改端口號修改端口號使得與2.2版本使用不同的端口,可以同時運行,修改后如下# cat /etc/httpd24/httpd.conf |grep Listen |grep -v ^#Listen 80802、啟動與停止# /usr/local/apache/bin/apachectl start# netstat -nltp|grep 80tcp 0 0 :::8080 :::* LISTEN 17365/httpd # /usr/local/apache/bin/apachectl statusNot FoundThe requested URL /server-status was not found on this server.通過修改httpd.conf,增加如下配置# grep server-stat /etc/httpd24/httpd.conf -A5<Location /server-status>SetHandler server-status# Order deny,allow# Deny from allAllow from 192.168.21.157 192.168.21.10</Location># /usr/local/apache/bin/apachectl restart# /usr/local/apache/bin/apachectl statusApache Server Status for localhost (via 127.0.0.1)Server Version: Apache/2.4.9 (Unix)Server MPM: prefork..........# /usr/local/apache/bin/apachectl stop3、配置自啟動文件 可以通過復制2.2版本的啟動文件,修改相關路徑后將2.4版作為單獨服務運行,如下注啟動文件pid文件位置要配置成與/usr/local/apache/bin/apachectl -V看到的pid位置一致查看pid位置# /usr/local/apache/bin/apachectl -V|grep pid-D DEFAULT_PIDLOG="logs/httpd.pid"# cp /etc/init.d/httpd /etc/init.d/httpd24 # vi /etc/init.d/httpd24 # diff /etc/init.d/httpd /etc/init.d/httpd24 26,27c26,27< if [ -f /etc/sysconfig/httpd ]; then< . /etc/sysconfig/httpd---> if [ -f /etc/httpd24 ]; then> . /etc/httpd2442,46c42,46< apachectl=/usr/sbin/apachectl< httpd=${HTTPD-/usr/sbin/httpd}< prog=httpd< pidfile=${PIDFILE-/var/run/httpd/httpd.pid}< lockfile=${LOCKFILE-/var/lock/subsys/httpd}---> apachectl=/usr/local/apache/bin/apachectl> httpd=${HTTPD-/usr/local/apache/bin/httpd}> prog=httpd24> pidfile=${PIDFILE-/usr/local/apache/logs/httpd.pid}> lockfile=${LOCKFILE-/var/lock/subsys/httpd24}# service httpd24 startStarting httpd24: [ OK ]# service httpd24 statushttpd (pid 15641) is running...# netstat -nltp|grep 80tcp 0 0 :::80 :::* LISTEN 15677/httpd ###2.2版httpd tcp 0 0 :::8080 :::* LISTEN 15641/httpd ###2.4版httpd可以通過復制apachectl文件生成服務腳本 # cp /usr/local/apache/bin/apachectl /etc/init.d/httpd249# service httpd249 start# service httpd249 statusELinks: Connection refused ###該方式無法查看到狀態 [root@orasrv1 bin]# netstat -nltp|grep 80tcp 0 0 :::8080 :::* LISTEN 15999/httpd 最后將配置文件添加到服務,以下為http24為例# chkconfig --add httpd24# chkconfig httpd24 on

六、配置man手冊

vi /etc/man.configMANPATH /usr/local/apache/man

七、驗證

# echo "This is a apached 2.4.9 version">>/usr/local/apache/htdocs/index.html # curl http://192.168.21.10:8080 <html><body><h1>It works!</h1></body></html> This is a apached 2.4.9 version

總結

以上是生活随笔為你收集整理的Linux下编译安装Apache httpd 2.4的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。