PHP的Symfony和CodeIgniter框架的Nginx重寫規(guī)則配置
Symfony
Symfony國(guó)外很流行的php框架,目前國(guó)內(nèi)用的相對(duì)較少,但是一定會(huì)在國(guó)內(nèi)火起來(lá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; # 改成你對(duì)應(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,即被很多人簡(jiǎn)稱為CI的高人氣PHP框架,其中文社區(qū)也比較活躍,來(lái)看一下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; # 改成對(duì)應(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ù)庫(kù)查詢緩存優(yōu)化的方法
- CI框架AR數(shù)據(jù)庫(kù)操作常用函數(shù)總結(jié)
- CI框架數(shù)據(jù)庫(kù)查詢之join用法分析
- CI框架出現(xiàn)mysql數(shù)據(jù)庫(kù)連接資源無(wú)法釋放的解決方法
- CI框架中數(shù)據(jù)庫(kù)操作函數(shù)$this->db->where()相關(guān)用法總結(jié)
- CI框架入門示例之?dāng)?shù)據(jù)庫(kù)取數(shù)據(jù)完整實(shí)現(xiàn)方法
- CI框架表單驗(yàn)證實(shí)例詳解
- CodeIgniter框架常見用法工作總結(jié)
相關(guān)文章
詳解nginx高并發(fā)場(chǎng)景下的優(yōu)化
這篇文章主要介紹了詳解nginx高并發(fā)場(chǎng)景下的優(yōu)化,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-09-09
Nginx geoip模塊實(shí)現(xiàn)地區(qū)性負(fù)載均衡
相信做過(guò)awstats的都用過(guò)開源的geoip.dat ip數(shù)據(jù)庫(kù),剛好nginx wiki上有g(shù)eoip 模塊,這樣就可以實(shí)現(xiàn)地區(qū)性的負(fù)載均衡,但是maxmind 的ip數(shù)據(jù)庫(kù)對(duì)中國(guó)的支持不算太好,不過(guò)現(xiàn)在也不錯(cuò)了~2010-12-12
解決Nginx網(wǎng)關(guān)超時(shí)出現(xiàn)504 GATEWAY TIMEOUT的問(wèn)題
這篇文章主要給大家介紹了如何解決Nginx網(wǎng)關(guān)超時(shí)出現(xiàn)504 GATEWAY TIMEOUT的問(wèn)題,文章通過(guò)代碼示例和圖文結(jié)合介紹的非常詳細(xì),有遇到相同問(wèn)題的朋友可以參考閱讀本文2023-11-11
nginx中狀態(tài)統(tǒng)計(jì)的實(shí)現(xiàn)
本文主要介紹了nginx中狀態(tài)統(tǒng)計(jì)的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-04-04
Nginx Rewrite使用場(chǎng)景及代碼案例詳解
這篇文章主要介紹了Nginx Rewrite使用場(chǎng)景及代碼案例詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-08-08

