設定 log 檔大小限制為 1MB
CustomLog "|/usr/sbin/rotatelogs /var/log/httpd/access_log_%Y-%m-%d-%H_%M_%S 1M" combined
ErrorLog "|/usr/sbin/rotatelogs /var/log/httpd/error_log_%Y-%m-%d-%H_%M_%S 1M" combined
apache 官方文件
http://httpd.apache.org/docs/2.2/programs/rotatelogs.html
上輩子做壞事,這輩子寫程式
2015年5月10日 星期日
Apache 壓縮傳輸設定
Apache 2.2 通常就內建有 mod_deflate,編輯 httpd.conf 設定檔開啟 deflate 壓縮功能
1 確認 Apache 有安裝 deflate 模組
…
LoadModule expires_module modules/mod_expires.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so
…
2 將下列設定加入 httpd.conf
<IfModule mod_deflate.c>
DeflateCompressionLevel 6
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript application/javascript application/x-httpd-php
AddOutputFilter DEFLATE js css gif
</IfModule>
(1) 因為 jpg,png,gif 等圖檔本身已被壓縮過,就不需要再壓縮了
(2) DeflateCompressionLevel 壓縮率建議設定 6 就好
3 重新啟動 Apache
1 確認 Apache 有安裝 deflate 模組
…
LoadModule expires_module modules/mod_expires.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so
…
2 將下列設定加入 httpd.conf
<IfModule mod_deflate.c>
DeflateCompressionLevel 6
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript application/javascript application/x-httpd-php
AddOutputFilter DEFLATE js css gif
</IfModule>
(1) 因為 jpg,png,gif 等圖檔本身已被壓縮過,就不需要再壓縮了
(2) DeflateCompressionLevel 壓縮率建議設定 6 就好
3 重新啟動 Apache
Apache 安全性設定
在 httpd.conf 中修改以下設定
1 禁止顯示目錄列表
移除掉 Indexes
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
2 不顯示作業系統及 Apache 版本
ServerSignature Off
3 回傳標頭資訊時,只要顯示 Apache 即可
ServerTokens Prod
1 禁止顯示目錄列表
移除掉 Indexes
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
2 不顯示作業系統及 Apache 版本
ServerSignature Off
3 回傳標頭資訊時,只要顯示 Apache 即可
ServerTokens Prod
2012年9月17日 星期一
如何刪除被 DenyHosts 封鎖的 IP
DenyHosts 是一款阻止暴力破解 SSH 密碼的軟體
/var/lib/denyhosts/hosts-restricted
/var/lib/denyhosts/hosts-root
/var/lib/denyhosts/hosts-valid
/var/lib/denyhosts/users-hosts
注意
ssh 也會記錄被 deny 的 IP ,所以也要檢查 /etc/hosts.deny
接著重新啟動 /etc/init.d/sshd restart
官網
接下來就是記錄如何刪除被 DenyHosts 封鎖的 IP
1 停止 DenyHosts /etc/init.d/denyhosts stop
2 刪除 /etc/hosts.deny 中被封鎖的 IP
3 刪除下列檔案中被封鎖的 IP
/var/lib/denyhosts/hosts/var/lib/denyhosts/hosts-restricted
/var/lib/denyhosts/hosts-root
/var/lib/denyhosts/hosts-valid
/var/lib/denyhosts/users-hosts
4 若要確保某 IP 不會被 DenyHosts 封鎖,可在 /var/lib/denyhosts/allowed-hosts 內加入該 IP
5 重新啟動 DenyHosts /etc/init.d/denyhosts start
注意
ssh 也會記錄被 deny 的 IP ,所以也要檢查 /etc/hosts.deny
接著重新啟動 /etc/init.d/sshd restart
刪除 MySQL binary logs 方法
隨著時間愈久 binary log 也會愈來愈多,而且又佔硬碟空間,之前在刪除 binary log 都是直接把它刪除,但是後來發現這根本不是正確的方式 ...
現在就將正確的刪除方式記錄下來
刪除 binary log 有以下 2 種方式
1 指定的 binary log
例如:
PURGE BINARY LOGS TO 'mysql-bin.010';
PURGE BINARY LOGS BEFORE '2008-04-02 22:46:26';
刪除 bin-log 可以參考下列步驟:
1 在每個 slave 服務器上,使用 SHOW SLAVE STATUS 來檢查它正在讀取哪個 binary log
2 使用 SHOW MASTER LOGS 獲得 master 服務器上 binary log 的清單
3 透過 slave 服務器目前正在讀取的 binary log ,就是目標 binary log
4 接著就可以刪除目標 binary log 以前的 binary log
現在就將正確的刪除方式記錄下來
刪除 binary log 有以下 2 種方式
1 指定的 binary log
2 日期之前的所有 binary log
例如:
PURGE BINARY LOGS TO 'mysql-bin.010';
PURGE BINARY LOGS BEFORE '2008-04-02 22:46:26';
刪除 bin-log 可以參考下列步驟:
1 在每個 slave 服務器上,使用 SHOW SLAVE STATUS 來檢查它正在讀取哪個 binary log
2 使用 SHOW MASTER LOGS 獲得 master 服務器上 binary log 的清單
3 透過 slave 服務器目前正在讀取的 binary log ,就是目標 binary log
4 接著就可以刪除目標 binary log 以前的 binary log
2012年4月12日 星期四
AmfPHP 1.9 相容 PHP 5.3
1 下載 AmfPHP 1.9
http://www.silexlabs.org/amfphp/downloads/
2 strtotime 時區設定
設定 php.ini
;date.timezone =
修改為
date.timezone = "Asia/Taipei"
3 eregi_replace 改成 preg_replace
修改 /amfphp/core/shared/util/MethodTable.php
$comment = eregi_replace(”\n[ \t]+”, “\n”, trim($comment));
$comment = str_replace(”\n”, “\\n”, trim($comment));
$comment = eregi_replace(”[\t ]+”, ” “, trim($comment));
修改為
$comment = preg_replace(”'\n[ \t]+'U”, “\n”, trim($comment));
$comment = str_replace(”\n”, “\\n”, trim($comment));
$comment = preg_replace(”'[\t ]+'U”, ” “, trim($comment));
http://www.silexlabs.org/amfphp/downloads/
2 strtotime 時區設定
設定 php.ini
;date.timezone =
修改為
date.timezone = "Asia/Taipei"
3 eregi_replace 改成 preg_replace
修改 /amfphp/core/shared/util/MethodTable.php
$comment = eregi_replace(”\n[ \t]+”, “\n”, trim($comment));
$comment = str_replace(”\n”, “\\n”, trim($comment));
$comment = eregi_replace(”[\t ]+”, ” “, trim($comment));
修改為
$comment = preg_replace(”'\n[ \t]+'U”, “\n”, trim($comment));
$comment = str_replace(”\n”, “\\n”, trim($comment));
$comment = preg_replace(”'[\t ]+'U”, ” “, trim($comment));
2012年2月22日 星期三
Eclipse PHP 開發套件 PDT 安裝
1 安裝 PHP Development Tools (PDT)
我目前使用的 Eclipse 版本如下圖
點選 Help>Install New Software
套件的位置:Web, XML, Java EE and OSGi Enterprise Development > PHP Development Tools (PDT) SDK Feature 3.0.0.v20110516-1100-77--84_23JBVgSVXO7XGJz0VLa9O
2 設定 PDT 環境
Window -> Preferences -> PHP -> Executables
Window > Preferences > PHP > Debug
訂閱:
意見 (Atom)




