Apache模組壓縮和緩衝設定

來源:互聯網
上載者:User

標籤:install   cli   apach   安裝環境   css   tar   執行   figure   lis   

1.壓縮功能的開啟
yum remove httpd //卸載原有的Apache檔案
cd /opt/LAMP
tar xzvf httpd-2.4.2.tar.gz -C /opt //手工編譯安裝httpd
tar xzvf apr-1.4.6.tar.gz -C /opt //支援Apache上層應用跨平台,提供底層介面庫
tar xzvf apr-util-1.4.1.tar.gz -C /opt
cd /opt
cp -R apr-1.4.6/ /opt/httpd-2.4.2/srclib/apr
cp -R apr-util-1.4.1/ /opt/httpd-2.4.2/srclib/apr-util
yum install -y gcc gcc-c++ pcre pcre-devel zlib-devel //安裝環境軟體包(pcre : 一個Perl庫,支援Regex)
cd /opt/httpd-2.4.2
./configure \
--prefix=/usr/local/httpd \
--enable-deflate \
--enable-so \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi
make && make install

grep -v "#" /usr/local/httpd/bin/apachectl > /etc/init.d/httpd //啟動指令碼
vim /etc/init.d/httpd 在檔案最前面插入下面的行
#!/bin/sh

chkconfig:2345 85 15description:Apache is a World Wide Web server.

chmod +x /etc/init.d/httpd
chkconfig --add httpd
chkconfig --list httpd
chkconfig --level 35 httpd on //給指令碼執行許可權及開機自啟動
ln -s /usr/local/httpd/conf/httpd.conf /etc/httpd.conf //建立軟串連便於管理
vim /etc/httpd.conf


cd /usr/local/httpd/bin
./apachectl -t //檢查httpd.conf的文法

vim /etc/httpd.conf
LoadModule deflate_module modules/mod_deflate.so //開啟壓縮功能模組


在檔案末尾插入如下資訊
<IFModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript //可壓縮檔類型
DeflateCompressionLevel 9 //壓縮比
SetOutputFilter DEFLATE //支援壓縮模組的類型(DEFLATE)
</IfModule>
./apachectl -t -D DUMP_MODULES | grep "deflate" //檢查壓縮功能模組是否開啟

2.緩衝設定
./configure \
--prefix=/usr/local/httpd \
--enable-deflate \
--enable-expires \
--enable-so \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi
make && make install
grep -v "#" /usr/local/httpd/bin/apachectl > /etc/init.d/httpd
vim /etc/init.d/httpd 在檔案最前面插入下面的行
#!/bin/sh

chkconfig:2345 85 15description:Apache is a World Wide Web server.

chmod +x /etc/init.d/httpd
chkconfig --add httpd
chkconfig --list httpd
chkconfig --level 35 httpd on //給指令碼執行許可權及開機自啟動
ln -s /usr/local/httpd/conf/httpd.conf /etc/httpd.conf
vim /etc/httpd.conf


LoadModule expires_module modules/mod_expires.so //開啟緩衝功能模組

在檔案末尾插入如下資訊

</IfModule>
<IFModule mod_deflate.c>
ExpiresActive On
ExpiresDefault "access plus 50 seconds"
</IfModule>

cd /usr/local/httpd/bin
./apachectl –t //檢查文法是否正確

Apache模組壓縮和緩衝設定

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.