安裝Apache web伺服器

來源:互聯網
上載者:User

標籤:安裝apache web

█安裝Apache2.4.23

●新增模組:

mod_proxy_fcgi(可提供fcgi代理)

mod_ratelimit(限制使用者寬頻)

mod_request(請求模組,對請求做過濾)

mod_remoteip(匹配用戶端的IP地址)

對於基於IP的存取控制做了修改,不再支援allow,deny,order機制,而是統一使用require進行

●新增新特性:

MPM支援在運行時裝載,不過要開啟這種特性,在編譯安裝時要啟用--enable-mpms-shared=all   --with-mpm=event

支援event

支援非同步讀寫

在每個模組及每個目錄上指定記錄層級

增強版的運算式分析器

每請求配置:<If>,<Elseif>

毫秒層級的keepalive timeout

基於FQDN的虛擬機器不再需要NameVirtualHost指令

支援使用自訂變數

●安裝環境:centos7.2,關閉selinux

1、編譯安裝Apache2.4.23

下載源碼包:

http-2.4.23.tar.gz

apr-1.5.2.tar.gz(可移植運行庫,用來實現Apache內部組件對作業系統的使用,提高系統的可移植性)

apr-util-1.5.4.tar.gz

zlib-1.2.8.tar.gz

pcre-8.39.tar.gz

①安裝apr

tar zxf apr-1.5.2.tar.gz

cd apr-1.5.2/

./configure --prefix=/usr/local/apr

make && make install

②安裝apr-util

tar zxf apr-util-1.5.4.tar.gz

cd apr-util-1.5.4.tar.gz

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

make && make install

③安裝zlib

tar zxf zlib-1.2.8.tar.gz

cd zlib-1.2.8/

./configure --prefix=/usr/local/zlib

make && make install

④安裝pcre

tar zxf pcre-8.39.tar.gz

cd pcre-8.39/

./configure --prefix=/usr/local/pcre

make && make install

⑤安裝openssl(centos7內建版本openssl-1.0.1e,版本過低 )

下載openssl:wget  https://www.openssl.org/source/openssl-1.0.1u.tar.gz

tar zxf openssl-1.0.1u.tar.gz

cd openssl-1.0.1u/

./config -fPIC --prefix=/usr/local/openssl enable-shared

make && make install

mv /usr/bin/openssl /usr/bin/openssl.1.0.1u

ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl

⑥安裝Apache2.4.34

tar zxf httpd-2.4.23.tar.gz

cd httpd-2.4.23/

./configure --prefix=/usr/local/http-2.4.23 --enable-so --enable-cgi --enable-cgid --enable-ssl --with-ssl --with-ssl=/usr/local/openssl --enable-rewrite --with-pcre=/usr/local/pcre --with-z=/usr/local/zlib --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 --enable-proxy --enable-proxy-fcgi --enable-expires --enable-deflate

★註:相關參數解釋

--enable-so:支援動態共用模組(即開啟DSO支援)

--enable-cgi:啟用cgi

--enable-cgid:MPM:使用的是event或worker要啟用cgid

--enable-ssl:支援ssl

--with-ssl=/usr/local/openssl:指定ssl安裝位置

--enable-rewrite:支援url重寫

--with-pcre=/usr/local/pcre:支援pcre

--with-z=/usr/local/zlib:使用zlib壓縮庫

--with-apr=/usr/local/apr:指定apr的安裝路徑

--with-apr-util=/usr/local/apr-util:指定apr-util的安裝路徑

--enable-modules=most:明確指定要靜態編譯到httpd二進位檔案的模組,<MODULE-LIST>為空白格分割的模組名列表、all或者most,all表示包含所有模組,most表示包含大部分常用模組

--enable-mods-shared=most:明確指定要以DSO方式編譯的模組,<MODULE-LIST>為空白格分割的模組名列表、all或者most,all表示包含所有模組,most表示包含大部分常用模組

--enable-mpms-shared=all:啟用MPM所有支援的模式,這樣event、worker、prefork就會以模組化的方式安裝,要用那個就在httpd.conf裡配置就好了

--with-mpm=event:指定啟用的mpm模式,預設使用event模式,在Apache的早期版本2.0預設prefork,2.2版本是worker,2.4版本是event

--enable-expires:啟用或通過設定檔控制HTTP的"Expires:"和"Cache-Control:"頭內容,即對網站圖片、js、css等內容,提供用戶端瀏覽器緩衝的設定

--enable-deflate:提供對內容的壓縮傳輸編碼支援,一般是html、js、css等內容的網站。使用此參數會大大提高傳輸速度,提升訪問者訪問的體驗

make && make install

●最佳化http程式執行路徑

ln -s /usr/local/http-2.4.23/bin/* /usr/local/bin/

●修改設定檔httpd.conf,設定其中的ServerName值

比如:ServerName www.test.com

●開啟Apache伺服器

/usr/local/http-2.4.23/bin/apachectl start

●開機後自動啟動

 cp /usr/local/http-2.4.23/bin/apachectl /etc/init.d/httpd

●編輯/etc/init.d/httpd檔案,在首行下面加入:

#chkconfig: 35 85 15

#description: apache-2.4.23

●將Apache加入開機自動啟動

chkconfig --add httpd

chkconfig httpd on

●啟動編譯好的Apache 2.4.23

service httpd start

netstat -anplt | grep 80

2、yum安裝Apache

更新本機服務:yum update

安裝Apache:yum -y install apache

啟動Apache:service httpd start

本文出自 “營運” 部落格,請務必保留此出處http://cherryliang.blog.51cto.com/12911935/1937345

安裝Apache web伺服器

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.