2011/10/14

on
XAMPP 安裝後的設定修改 : (  XAMPP官網 )

■VC6版本是用Visual Studio 6編譯的, VC9版本是用Visual Studio 2008編譯的

■■■ Apache httpd.conf
  • ■ fix : htdoc
  • ■ fix :    Options Indexes FollowSymLinks Includes ExecCGI
    Options FollowSymLinks Includes ExecCGI
  • ■. ./xampp/apache/conf/extra/httpd-ssl.conf
  • xampp已經配置好了ssl,只要改 httpd-ssl.conf文件,將DocumentRoot改成現在的目錄即可
■■■ MySql
  • ■ Fix root no password
  • ■ copy phpmyadmin 313 to www direction
  • ■ add 程式用mysql名稱(非 root) to mysql for database admin
■■■ PHPMyAdmin 修改:
  • ■.變更MySql root 密碼,原設空密碼
  • ■修改 x:\xampp\phpmyadmin\config.inc.php檔案內容: - 原
  • $cfg['Servers'][$i]['auth_type']            = 'config';
    $cfg['Servers'][$i]['user']                 = 'root';
    $cfg['Servers'][$i]['password']             = '';
    $cfg['Servers'][$i]['AllowNoPassword']      = true;
  • # ----------------改為:
    $cfg['Servers'][$i]['auth_type']            = 'http';
    $cfg['Servers'][$i]['user']                 = '';
    $cfg['Servers'][$i]['password']             = '';
    $cfg['Servers'][$i]['AllowNoPassword']      = false;
  • ■將原有x:\xampp\phpmyadmin 目錄改名,並copy到自有的www目錄下,目錄名稱不要用phpmyadmin
■■■PHP
  • ■ ;date.timezone = "UTC"
    date.timezone = "Asia/Taipei"
    ;mbstring.func_overload = 0
    mbstring.func_overload = 7
    default_charset = "UTF-8" // default is empty
  • ■ set extension on off ( # )
    ...
    extension=php_dbase.dll
    ...
=====

我想直接啟動XAMPP,但卻不想執行設定(setup)!!!
如果你將XAMPP解壓縮在最上層目錄,像c:\xampp或d:\xampp 等目錄,你可以直接啟動XAMPP。 這表示你不需要事先執行"setup_xampp.bat"。Apache, MySQL 和 Mercury 郵件伺服器將可以正常啟動。 只有 FileZilla 檔案傳輸伺服器無法啟動,因為它需要絕對路徑設定才可以正常執行。 對以上這些方法來說:請不要使用雙層的XAMPP目錄,例如 c:\xampp\xampp ! 你需要的是單獨的xampp資料夾,例如 d:\xampp(\apache 其它等等)。 否則你就必須在啟動前,先執行一次"setup-xampp.bat",來進行路徑的更新動作。

XAMPP的控制中心來自 von www.nat32.com. (並未包含在lite版本中)
.\xampp\xampp-control.exe
其它一些與伺服器相關的檔案:
Apache & MySQL start: .\xampp\xampp_start.exe
Apache & MySQL stop: .\xampp\xampp_stop.exe
Apache start: .\xampp\apache_start.bat
Apache stop: .\xampp\apache_start.bat
MySQL start: .\xampp\mysql_start.bat
MySQL stop: .\xampp\mysql_stop.bat
Mercury Mailserver start: .\xampp\mercury_start.bat
(你只能透過圖型化介面來啟動/停止 Mercury)
FileZilla Server setup: .\xampp\filezilla_setup.bat
FileZilla Server start: .\xampp\filezilla_start.bat
FileZilla Server stop: .\xampp\filezilla_stop.bat
將特定的伺服器安裝為系統服務,( NT 4,2000 和 XP平台)
Apache Dienst install: .\xampp\apache\apache_installservice.bat
Apache Dienst uninstall: .\xampp\apache\apache_uninstallservice.bat
MySQL Dienst install: .\xampp\mysql\mysql_installservice.bat
MySQL Dienst uninstall: .\xampp\mysql\mysql_uninstallservice.bat
FileZilla Dienst (un)install: .\xampp\filezilla_setup.bat

==================================================

■■■ php5的session配置詳解教程 ■■■
http://www.5iphp.com/zh-hans/content/374.html

首先打開php.ini文件,找到session的部分:(分號後面的是註釋)

[Session]
; Handler used to store/retrieve data.
session.save_handler = files ; 這個是session的方式,默認的files就可以了,代表用文件儲存,還有兩種方式,user和memcache。user方式指的是你自己(也就是用戶)定義session的句柄,用於session的存取等,這個可以把session擴展存到數據庫裡,memcache方式,需要你配置好 memcache,還要配置session.save_path。

; Argument passed to save_handler. In the case of files, this is the path where data files are stored.
session.save_path = /tmp ; 這個是session的保存路徑,比如你系統盤是c盤,那麼默認就是c:/tmp,所以如果出現"Warning: open(/tmpsess_cc8b04f146a1e0494bc464305da92ea1, O_RDWR) failed"這樣子的錯誤,你可以修改這個路徑,或者在根目錄下面建立一個tmp的文件夾

; Whether to use cookies.
session.use_cookies = 1 ; sessionid的傳遞方式,默認是cookie,推薦使用

; Name of the session (used as cookie name).
session.name = PHPSESSID ; sessionid的名稱,保存在cookie裡面的,要避免同名

; Initialize session on request startup.
session.auto_start = 0 ; 是否自動啟動session,默認為不是,不需要修改

; Lifetime in seconds of cookie or, if 0, until browser is restarted.
session.cookie_lifetime = 0 ; sessionid的cookie生存時間,0代表直到瀏覽器關閉,cookie才失效

; The path for which the cookie is valid.
session.cookie_path = / ; sessionid的cookie路徑,不需要修改

; The domain for which the cookie is valid.
session.cookie_domain = ; ;sessionid的cookie域名,不需要修改

; Handler used to serialize data. php is the standard serializer of PHP.
session.serialize_handler = php ; 保存data的默認文件名後綴,不需要修改

; Percentual probability that the 'garbage collection' process is started on every session initialization.
session.gc_probability = 1

; After this number of seconds, stored data will be seen as 'garbage' and cleaned up by the garbage collection process.
session.gc_maxlifetime = 1440 ; session文件的保存時間

; Check HTTP Referer to invalidate externally stored URLs containing ids.
session.referer_check = ; How many bytes to read from the file.
session.entropy_length = 0 ; Specified here to create the session id.
session.entropy_file = ;session.entropy_length = 16 ;session.entropy_file = /dev/urandom

; Set to {nocache,private,public} to determine HTTP caching aspects.
session.cache_limiter = nocache ; Document expires after n minutes.
session.cache_expire = 180 ; use transient sid support if enabled by compiling with --enable-trans-sid.
session.use_trans_sid = 1 url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
==================================================
session 的生命週期是多長

1 瀏覽器結束時其生命週期也同時結束,但是檔案仍然存在於 /tmp/(sess_???)
2 下次重新開瀏覽器時會重新分配 sessionID,如果你使用 session_id() 把以前的 ID 帶回來,
則會去讀取殘存在 /tmp 處的 sess_???, 取回你之前所有已經設定的參數
3 可以在 php.ini 裡修改 session 檔案殘存的時間

session.gc_maxlifetime = 1440 ; 默認是 1440 秒,24分鐘
; after this number of seconds, stored
; data will be seen as 'garbage' and
; cleaned up by the gc process

==================================================

使用無限生命期Session的方法
在PHP4.0中加入了對Session的支持,方便了我們很多程序,比如購物車等等!
在很多論壇中,Session也用於處理用戶的登陸,記錄下用戶名和密碼,使得用戶不必每次都輸入自己的用戶名和密碼!但是一般的Session的生命期有限,如果用戶關閉了瀏覽器,就不能保存Session的變量了!那麼怎麼樣可以實現Session的永久生命期呢?
大家知道,Session儲存在服務器端,根據客戶端提供的SessionID來得到這個用戶的文件,然後讀取文件,取得變量的值,SessionID可以使用客戶端的Cookie或者Http1.1協議的Query_String(就是訪問的URL的"?"後面的部分)來傳送給服務器,然後服務器讀取 Session的目錄......

要實現Session的永久生命期,首先需要瞭解一下php.ini關於Session的相關設置(打開php.ini文件,在"[Session]"部分):
1、session.use_cookies:默認的值是"1",代表SessionID使用Cookie來傳遞,反之就是使用Query_String來傳遞;
2、session.name:這個就是SessionID儲存的變量名稱,可能是Cookie,也可能是Query_String來傳遞,默認值"PHPSESSID";
3、session.cookie_lifetime:這個代表SessionID在客戶端Cookie儲存的時間,默認是0,代表瀏覽器一關閉SessionID就作廢......就是因為這個所以Session不能永久使用!
4、session.gc_maxlifetime:這個是Session數據在服務器端儲存的時間,如果超過這個時間,那麼Session數據就自動刪除!
還有很多的設置,不過和本文相關的就是這些了,下面開始講使用永久Session的原理和步驟。

前面說過,服務器通過SessionID來讀取Session的數據,但是一般瀏覽器傳送的SessionID在瀏覽器關閉後就沒有了,那麼我們只需要人為的設置SessionID並且保存下來,不就可以......
如果你擁有服務器的操作權限,那麼設置這個非常非常的簡單,只是需要進行如下的步驟:
1、把"session.use_cookies"設置為1,打開Cookie儲存SessionID,不過默認就是1,一般不用修改;
2、把"session.cookie_lifetime"改為正無窮(當然沒有正無窮的參數,不過999999999和正無窮也沒有什麼區別);
3、把"session.gc_maxlifetime"設置為和"session.cookie_lifetime"一樣的時間;
設置完畢後,打開編輯器,輸入如下的代碼:
------------------------------------------------------------------------------------

session_register('count');
$count++;
echo $count;

------------------------------------------------------------------------------------
然後保存為"session_check.php",用瀏覽器打開"session_check.php",看看顯示的是不是"1",再關閉瀏覽器,然後再打開瀏覽器訪問"session_check.php",如果顯示"2",那麼恭喜了,你已經成功;如果失敗的話,請檢查你前面的設置。

但是如果你沒有服務器的操作權限,那就比較麻煩了,你需要通過PHP程序改寫SessionID來實現永久的Session數據保存。查查 php.net的函數手冊,可以見到有"session_id"這個函數:如果沒有設置參數,那麼將返回當前的SessionID,如果設置了參數,就會將當前的SessionID設置為給出的值......
只要利用永久性的Cookie加上"session_id"函數,就可以實現永久Session數據保存了!
但是為了方便,我們需要知道服務器設置的"session.name",但是一般用戶都沒有權限查看服務器的php.ini設置,不過PHP提供了一個非常好的函數"phpinfo",利用這個可以查看幾乎所有的PHP信息!

■■■

1 意見:

Unknown 提到...

寫得蠻仔細的,謝謝