顯示具有 Apache 標籤的文章。 顯示所有文章
顯示具有 Apache 標籤的文章。 顯示所有文章

Apache Rewrite HTTP to HTTPS




RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]



Ref: https://www.sslshopper.com/apache-redirect-http-to-https.html

Apache & MySQL Connection Setting


Apache
  1. 檢查Apache 版本及運行腳本
    httpd -v, httpd -l
  2. 設定Apache22/extra/httpd-mpm.conf
  3. 找到腳本設定
    
        StartServers          5
        MinSpareServers       5
        MaxSpareServers       10
        MaxClients            1000 (150改1000)
        MaxRequestsPerChild   2000 (0改2000)
  4. 重啟Apache
    

MySQL
  1. 找到my.cnf
  2. 在[mysqld]下加入 max_connections = 1000
  3. 重啟MySQL

參考
合理設置apache-httpd的最大連接數






Codeigniter Upload PowerPoint Error

Codeigniter Version 2.1.3

Change system code

/system/libraries/Upload.php

Line: 1078
$this->file_type = $matches[1];
Change to
$this->file_type = ($matches[1] == 'application/vnd.ms-office' ? $file['type'] : $matches[1]);

Line: 1091
$this->file_type = $matches[1];
Change to
$this->file_type = ($matches[1] == 'application/vnd.ms-office' ? $file['type'] : $matches[1]);

Line: 1109
$this->file_type = $matches[1];
Change to
$this->file_type = ($matches[1] == 'application/vnd.ms-office' ? $file['type'] : $matches[1]);

Add Mine Type in Application mimes.php

add .pptx in /application/config/mimes.php
'pptx' => array('application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/zip'),

FreeBSD Apache install Streaming Module H264 and FLV

安裝 mod_flvx
下載 mod_flvx
https://github.com/osantana/mod_flvx
解壓縮進入資料夾下指令apxs -c -i ./mod_flvx.c
mod_flvs.so 會安裝到 /usr/local/libexec/apache22/ 底下


安裝mod_h264_streaming
下載mod_h264_streaming
http://h264.code-shop.com/download/apache_mod_h264_streaming-2.2.7.tar.gz
解壓縮進入資料夾
修改以下兩個檔權限為700
configure
install-sh

下指令產出文件
./configure --with-apxs=`which apxs`
make
下指令安裝
make install


到 /usr/local/etc/apache22/httpd.conf 加入以下指令
或到 /usr/local/etc/apache22/Includes 自訂一個.conf資料檔,
如: mod_streaming.conf
加入以下指令

# FLV
LoadModule flvx_module modules/mod_flvx.so 
AddHandler flv-stream .flv

# MP4
LoadModule h264_streaming_module libexec/apache22/mod_h264_streaming.so
AddHandler h264-streaming.extensions .mp4



W3C驗證, GZIP驗證



測試網站HTML, CSS是否正確符合WWW規範.
http://validator.w3.org/


測試網站是否開啟GZIP
http://www.gidnetwork.com/tools/gzip-test.php

Apache 設定網頁快取, 壓縮

為了幫首頁減肥, 
除了更改HTML, CSS, JavaScript外
還要壓縮這些檔


今天我們要設定 Apache 的快取和壓縮
確定以下模組有安裝

mod_deflate.so
mod_expires.so
mod_headers.so


然後網站目錄的 .htaccess 加入以下
# 這裡設定快取的類型和快取時間

<IfModule mod_expires.c>
        ExpiresActive On
        ExpiresByType image/gif A604800
        ExpiresByType image/png A604800
        ExpiresByType image/jpg A604800
        ExpiresByType image/jpeg A604800
        ExpiresByType image/x-icon A604800
        ExpiresByType application/x-javascript A604800
        ExpiresByType application/javascript A604800
        ExpiresByType text/javascript A604800
        ExpiresByType text/css A604800
        ExpiresByType text/html A604800
</IfModule>
# 這裡設定壓縮
<IfModule mod_deflate.c>
        SetOutputFilter DEFLATE
        AddOutputFilterByType DEFLATE text/html text/css image/gif image/jpg image/jpeg image/png application/x-javascript text/javascript application/javascript
</ifModule>

Apache Rewrite LIMIT TIME

設定某時間後才能進入網頁
我們要用到Apache RewriteCond

Code:

RewriteEngine On
RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY}%{TIME_HOUR}%{TIME_MIN} <201204270000 
RewriteRule ^.*$ http://www.google.com/ [R,L]