2010-12-30 06:22

美化 Apache autoindex

因為原始的 auto Index 的頁面實在太醜了
也許五年前看起來還很新潮,但現在已經過時了
所以我自己做的一個 Apache 美化套件

檔案下載:fancy.zip

2010-12-30 06:03

Apache Expires模組(mod_expires) 設定參數

# @version $Id: .htaccess 130 2010-09-29 10:03:56Z jax.hu $

#Options -FollowSymLinks -Indexes #TODO 開發時關閉

# 關閉 Apache Rewrite 模組
<IfModule mod_rewrite.c>
    RewriteEngine off
</IfModule>


# 啟用 Apache mod_expires 模組,來管理 browser 端的 cache 時間
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault A0 
    
    # ExpiresDefault "<base> [plus] {<num> <type>}*"
    # base:[ access | modification ]
    # type:[ years | months | weeks | days | hours | minutes | seconds ]
    
    <FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
        ExpiresDefault "access plus 1 years"
    </FilesMatch>
    
    <FilesMatch "\.(jpg|jpeg|png|gif|swf|txt|xml|js|css)$">
        ExpiresDefault "access plus 7 days"
    </FilesMatch>
</IfModule>

# 關閉 Apache 對檔案的實體標籤
FileETag none

參考來源:
mod_expires - Apache HTTP Server:
mod_expires - Apache 2.2 中文版参考手册:
Apache2 載入 Expires 的模組(mod_expires) 與 設定
ezDIY.org / 使用mod_expires模組來加速網頁瀏覽
2010-12-30 05:54

Apache 壓縮模組(mod_deflate) 設定參數

# @version $Id: .htaccess 130 2010-09-29 10:03:56Z jax.hu $

RewriteEngine on
RewriteRule ^.*$ index.php

php_flag magic_quotes_gpc off
php_flag register_globals on
php_flag output_buffering on


# 啟用 Apache 壓縮模組
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/css 
    AddOutputFilterByType DEFLATE text/javascript 
    AddOutputFilterByType DEFLATE text/js
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/atom_xml
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE application/x-httpd-php
    AddOutputFilterByType DEFLATE application/x-httpd-fastphp
    AddOutputFilterByType DEFLATE application/x-httpd-eruby
    AddOutputFilterByType DEFLATE application/postscript
    AddOutputFilter DEFLATE html htm xml css js svg

    # properly handle requests coming from behind proxies
    <IfModule mod_headers.c>
        Header append Vary User-Agent
    </IfModule>
</IfModule>

參考來源:
mod_deflate - Apache HTTP Server:
mod_deflate - Apache 2.2 中文版参考手册
[Apache] 壓縮你的網頁 – mod_deflate/mod_gzip、ob_gzhandler、zlib | 阿駕零零壹 © 學習筆記:
2010-12-24 01:02

[轉載] Google 氣球

轉載自:robhawkes
實在是太酷了,想儲存起來
2010-12-08 13:45

SVN connection settings for Eclipse

建立 SVN 連結



將現有專案 commit 到 SVN 上



開啟 SVN keywords PS:這個功能是由 client 處理的
選取專案 -> 右鍵 -> 內容



在專案下建立以下內容,然後 commit 到 SVN 上
<?php
// SVN-keywords-test.php
/*
$Id$
$Date$
$Revision$
$Author$
$HeadURL$
*/

參考來源:
Subversion中的关键字替换
关键字替换
如何结合使用 Subversion 和 Eclipse
在eclipse下的SVN插件配置忽略文件和文件夹
2010-12-08 11:42

[Ubuntu] setup SVN base Apache note

# 安裝 Apache & SVN
apt-get install apache2 apache2.2-common apache2-utils apache2-doc libapache2-svn subversion

# 建立 Repositorys 的目錄
mkdir /var/lib/svn

# 建立三個 Repository
svnadmin create /var/lib/svn/repo1
svnadmin create /var/lib/svn/repo2
svnadmin create /var/lib/svn/repo3


# 變更 Repositorys 的權限給 Apache
chown -R www-data:www-data /var/lib/svn

# 啟用 Apache 中的 dav_svn
a2enmod dav_svn

# 設定 SVN 使用者帳號
htpasswd -c /etc/apache2/dav_svn.passwd user1
htpasswd /etc/apache2/dav_svn.passwd user2
htpasswd /etc/apache2/dav_svn.passwd user3


# 編輯 SVN 配置檔
vim /etc/apache2/mods-available/dav_svn.conf
<Location /svn>
  DAV svn
  SVNParentPath /var/lib/svn
  AuthType Basic
  AuthName "Subversion Repository"
  AuthUserFile /etc/apache2/dav_svn.passwd
  AuthzSVNAccessFile /etc/apache2/dav_svn.authz
  <LimitExcept GET PROPFIND OPTIONS REPORT>
    Require valid-user
  </LimitExcept>
</Location>

# 編輯 SVN 資源權限
vim /etc/apache2/dav_svn.authz
# 設定使用者群組
[groups]
group1 = user1,user2
group2 = user1,user3


# 設定全域皆可讀取
[/]
* = r

# 指定 repo1 只有 group1 可以寫入
[repo1:/]
@group1 = rw

# 指定 repo1 中 blog 這個目錄只有 uesr2 可以寫入
[repo1:/blog/]
uesr2 = rw


# 指定 repo2 只有 group2 可以寫入
[repo2:/]
@group2 = rw

# 指定 repo3 只有 user1 可以寫入
[repo3:/]
user1 = rw

# 重新啟動 Apache
/etc/init.d/apache2 restart


參考來源:
Ubuntu - 安裝 SVN (Subversion Server)
Subversion用户,权限管理