PHP的Symfony和CodeIgniter框架的Nginx重寫規(guī)則配置
Symfony
Symfony國外很流行的php框架,目前國內(nèi)用的相對較少,但是一定會在國內(nèi)火起來. nginx重寫規(guī)則如下
server {
server_name jb51.net www.dbjr.com.cn;
root /data/site/www.dbjr.com.cn;
location / {
# try to serve file directly, fallback to rewrite
try_files $uri @rewriteapp;
}
location @rewriteapp {
# rewrite all to app.php
rewrite ^(.*)$ /app.php/$1 last;
}
location ~ ^/(app|app_dev|config).php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm.sock; # 改成你對應(yīng)的FastCGI
fastcgi_split_path_info ^(.+.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
error_log /data/logs/nginx/www.dbjr.com.cn_error.log;
}
重啟nginx即可
CodeIgniter
CodeIgniter,即被很多人簡稱為CI的高人氣PHP框架,其中文社區(qū)也比較活躍,來看一下CI的rewrite寫法:
server {
listen 80;
server_name jb51.net www.dbjr.com.cn;
root /data/site/www.dbjr.com.cn;
index index.php;
error_log log/error.log;
# set expiration of assets to MAX for caching
location ~* .(ico|css|js|gif|jpe?g|png)(?[0-9]+)?$ {
expires max;
log_not_found off;
}
# main codeigniter rewrite rule
location / {
try_files $uri $uri/ /index.php;
}
# php parsing
location ~ .php$ {
root /data/site/jb51.net/;
try_files $uri =404;
fastcgi_pass unix:/tmp/php5-fpm.sock; # 改成對應(yīng)的FastCGI
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
}
修改CI(CodeIgniter )配置文件config.php
$config['base_url'] = "http://www.dbjr.com.cn/"; $config['index_page'] = ""; $config['uri_protocol'] = "REQUEST_URI";
- CodeIgniter框架URL路由總結(jié)
- Nginx下配置codeigniter框架方法
- CI(CodeIgniter)框架配置
- CI框架數(shù)據(jù)庫查詢緩存優(yōu)化的方法
- CI框架AR數(shù)據(jù)庫操作常用函數(shù)總結(jié)
- CI框架數(shù)據(jù)庫查詢之join用法分析
- CI框架出現(xiàn)mysql數(shù)據(jù)庫連接資源無法釋放的解決方法
- CI框架中數(shù)據(jù)庫操作函數(shù)$this->db->where()相關(guān)用法總結(jié)
- CI框架入門示例之?dāng)?shù)據(jù)庫取數(shù)據(jù)完整實(shí)現(xiàn)方法
- CI框架表單驗(yàn)證實(shí)例詳解
- CodeIgniter框架常見用法工作總結(jié)
相關(guān)文章
Nginx geoip模塊實(shí)現(xiàn)地區(qū)性負(fù)載均衡
相信做過awstats的都用過開源的geoip.dat ip數(shù)據(jù)庫,剛好nginx wiki上有g(shù)eoip 模塊,這樣就可以實(shí)現(xiàn)地區(qū)性的負(fù)載均衡,但是maxmind 的ip數(shù)據(jù)庫對中國的支持不算太好,不過現(xiàn)在也不錯了~2010-12-12
解決Nginx網(wǎng)關(guān)超時出現(xiàn)504 GATEWAY TIMEOUT的問題
這篇文章主要給大家介紹了如何解決Nginx網(wǎng)關(guān)超時出現(xiàn)504 GATEWAY TIMEOUT的問題,文章通過代碼示例和圖文結(jié)合介紹的非常詳細(xì),有遇到相同問題的朋友可以參考閱讀本文2023-11-11
nginx中狀態(tài)統(tǒng)計(jì)的實(shí)現(xiàn)
本文主要介紹了nginx中狀態(tài)統(tǒng)計(jì)的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-04-04

