系統:
Win 7 ( XAMPP )
程式路徑: E:\www\project_name
phpmyadmin路徑: C:\xampp\phpMyAdmin
目的:
http://localhost 訪問該程式
http://localhost/phpmyadmin 訪問phpmyadmin
解法:
使用Alias ( 我是加在vhost中 )
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "E:\www\project_name"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
Alias /phpmyadmin C:\xampp\phpMyAdmin
<Directory "E:\www\project_name">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
參考資料:
http://stackoverflow.com/questions/5552081/using-a-directory-in-virtualhost-servername
(vhost)解決403 Access Forbidden 錯誤
https://superuser.com/a/714183
Directory 裡面新增 Require all granted
<VirtualHost *:80>
ServerAdmin webmaster@test.example.com
DocumentRoot "C:\test"
ServerName test.example.com
ErrorLog "logs/test.example.com-error.log"
CustomLog "logs/test.example.com-access.log" common
<Directory "C:\test">
Require all granted
</Directory>
</VirtualHost>
2015年5月26日 星期二
2015年1月12日 星期一
apache錯誤:Request exceeded the limit of 10 internal redirects due to probable configuration error.
主機:CentOS
讀取網址 http://localhost
頁面出現錯誤:
500 Internal Server Error
apache error log:
[Mon Jan 12 12:04:40 2015] [error] [client x.x.x.x] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
但是讀取
http://localhost/index.php、http://localhost/index.html、http://localhost/test.php
正常
原因:
httpd.conf 開了Rewrite( LoadModule rewrite_module modules/mod_rewrite.so
)
且
<Directory "/var/www/html">裡面的AllowOverride 被改成All
解法:
把<Directory "/var/www/html">裡面的 AllowOverride 改成None
讀取網址 http://localhost
頁面出現錯誤:
500 Internal Server Error
apache error log:
[Mon Jan 12 12:04:40 2015] [error] [client x.x.x.x] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
但是讀取
http://localhost/index.php、http://localhost/index.html、http://localhost/test.php
正常
原因:
httpd.conf 開了Rewrite( LoadModule rewrite_module modules/mod_rewrite.so
)
且
<Directory "/var/www/html">裡面的AllowOverride 被改成All
解法:
把<Directory "/var/www/html">裡面的 AllowOverride 改成None
2014年10月9日 星期四
long polling時,網頁開完後重新整理不出來
在使用 https://github.com/panique/php-long-polling 實做long polling遇到的狀況:
將client/index.html 複製成 client.php並開啟
http://your_domain.com/php-long-polling/client/client.php (注意:client/client.js 的 ajax網址要設成你的domain或 /php-long-polling/server/server.php )
第一次client.php開得出來,但按ctrl+r重新整理頁面後,網頁會轉不出來 ( client/index.html 不會有此問題 )
Blue解法:
通常這樣狀況 表示 你程式 找不到資料 又沒有寫 timeout 變成連線卡住,從前端處理,固定時間取消掉ajax request後重送 ( 不採用 )
但放到我朋友的主機上面卻沒這問題,比較兩個頁面的http標頭發現有以下的差異:
Cookie PHPSESSID=rc65gi80fdvpgoakur3quj04l3
差異:
發現我主機的php.ini設定:
session.auto_start = 1 => 要把他改成零 session.auto_start = 0,重啟apache就可以重刷了
另外的解法: 假如系統php.ini不能更動,且session.auto_start = 1時,把php.ini的值設到.htaccess
http://davidwalsh.name/php-values-htaccess
編輯網站根目錄的.htaccess,加入這行:
php_value session.auto_start 0
#格式是: php_value setting_name setting_value
原因:
http://stackoverflow.com/questions/13213396/no-reply-when-using-flush-session-cookies-and-long-execution-time
大意是說是說 因為第一個session還開著(開300秒),因為不確定之後session的變數會不會改變,所以要等第一個結束才能叫第二個,使用session_write_close()後之後session的變數就會變的可以存取。通常使用session_write_close()在長時間執行的script上。
所以在long polling 的server.php那邊要加 session_write_close() 就可以了.
另外:
使用session_commit() 也可以
http://blog.chacuo.net/168.html
檢查:
root@localhost:/var/lib/php5# ls
modules sess_tbdko1s1d8l8anhsjfurnq7ob4 sess_es3qrrebadlckj80gsjnv5hh27 sess_tbdko1s1d8l8anhsjfurnq7ob4
sess_14qeiqp5n44ba5nvdr4jdrfcp4
root@localhost:/var/lib/php5# lsof sess_tbdko1s1d8l8anhsjfurnq7ob4
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
apache2 30364 www-data 16uW REG 202,0 0 43458 sess_tbdko1s1d8l8anhsjfurnq7ob4
apache2 30367 www-data 16u REG 202,0 0 43458 sess_tbdko1s1d8l8anhsjfurnq7ob4
apache2 30368 www-data 16u REG 202,0 0 43458 sess_tbdko1s1d8l8anhsjfurnq7ob4
apache2 30375 www-data 16u REG 202,0 0 43458 sess_tbdko1s1d8l8anhsjfurnq7ob4
apache2 30377 www-data 16u REG 202,0 0 43458 sess_tbdko1s1d8l8anhsjfurnq7ob4
apache2 30378 www-data 16u REG 202,0 0 43458 sess_tbdko1s1d8l8anhsjfurnq7ob4
apache2 30382 www-data 16u REG 202,0 0 43458 sess_tbdko1s1d8l8anhsjfurnq7ob4
測試後 跟推測一樣,每執行一次就被卡住一次process
將client/index.html 複製成 client.php並開啟
http://your_domain.com/php-long-polling/client/client.php (注意:client/client.js 的 ajax網址要設成你的domain或 /php-long-polling/server/server.php )
第一次client.php開得出來,但按ctrl+r重新整理頁面後,網頁會轉不出來 ( client/index.html 不會有此問題 )
Blue解法:
通常這樣狀況 表示 你程式 找不到資料 又沒有寫 timeout 變成連線卡住,從前端處理,固定時間取消掉ajax request後重送 ( 不採用 )
但放到我朋友的主機上面卻沒這問題,比較兩個頁面的http標頭發現有以下的差異:
Cookie PHPSESSID=rc65gi80fdvpgoakur3quj04l3
差異:
發現我主機的php.ini設定:
另外的解法: 假如系統php.ini不能更動,且session.auto_start = 1時,把php.ini的值設到.htaccess
http://davidwalsh.name/php-values-htaccess
編輯網站根目錄的.htaccess,加入這行:
php_value session.auto_start 0
#格式是: php_value setting_name setting_value
原因:
http://stackoverflow.com/questions/13213396/no-reply-when-using-flush-session-cookies-and-long-execution-time
大意是說是說 因為第一個session還開著(開300秒),因為不確定之後session的變數會不會改變,所以要等第一個結束才能叫第二個,使用session_write_close()後之後session的變數就會變的可以存取。通常使用session_write_close()在長時間執行的script上。
所以在long polling 的server.php那邊要加 session_write_close() 就可以了.
另外:
使用session_commit() 也可以
http://blog.chacuo.net/168.html
檢查:
root@localhost:/var/lib/php5# ls
modules sess_tbdko1s1d8l8anhsjfurnq7ob4 sess_es3qrrebadlckj80gsjnv5hh27 sess_tbdko1s1d8l8anhsjfurnq7ob4
sess_14qeiqp5n44ba5nvdr4jdrfcp4
root@localhost:/var/lib/php5# lsof sess_tbdko1s1d8l8anhsjfurnq7ob4
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
apache2 30364 www-data 16uW REG 202,0 0 43458 sess_tbdko1s1d8l8anhsjfurnq7ob4
apache2 30367 www-data 16u REG 202,0 0 43458 sess_tbdko1s1d8l8anhsjfurnq7ob4
apache2 30368 www-data 16u REG 202,0 0 43458 sess_tbdko1s1d8l8anhsjfurnq7ob4
apache2 30375 www-data 16u REG 202,0 0 43458 sess_tbdko1s1d8l8anhsjfurnq7ob4
apache2 30377 www-data 16u REG 202,0 0 43458 sess_tbdko1s1d8l8anhsjfurnq7ob4
apache2 30378 www-data 16u REG 202,0 0 43458 sess_tbdko1s1d8l8anhsjfurnq7ob4
apache2 30382 www-data 16u REG 202,0 0 43458 sess_tbdko1s1d8l8anhsjfurnq7ob4
測試後 跟推測一樣,每執行一次就被卡住一次process
2012年9月26日 星期三
[Apache] 在URL中刪除目錄
http://lmgtfy.com/?q=url+rewrite+remove+folder
http://stackoverflow.com/questions/1314279/mod-rewrite-in-expression-engine-removing-directory-in-url
使用下面規則把目錄去掉
http://stackoverflow.com/questions/1314279/mod-rewrite-in-expression-engine-removing-directory-in-url
使用下面規則把目錄去掉
#RewriteEngine on #可能需要打開
#RewriteBase /
RewriteCond %{THE_REQUEST} ^GET\ /website/
RewriteRule ^website/(.*) /$1 [L,R=301]
RewriteRule !^website/ website%{REQUEST_URI}
2012年9月4日 星期二
CodeIgniter URL-rewrite
http://www.codeigniter.org.tw/user_guide/general/urls.html
以下是將除了像是 index.php、captcha(資料夾)、images、admin、swf檔(使用.*為任意檔名)、css檔、js檔 的全部 HTTP request 都會被當成是 request index.php 檔案。 ( ex. pond.php => index.php/pond.php )
以下是將除了像是 index.php、captcha(資料夾)、images、admin、swf檔(使用.*為任意檔名)、css檔、js檔 的全部 HTTP request 都會被當成是 request index.php 檔案。 ( ex. pond.php => index.php/pond.php )
RewriteEngine on RewriteBase / RewriteCond $1 !^(index\.php|captcha|images|admin|.*\.swf|.*\.css|.*\.js|.*\.xml|.*\.jpg|$) RewriteRule ^(.*)$ index.php/$1 [L,QSA]
訂閱:
文章 (Atom)