PHP的Symfony和CodeIgniter框架的Nginx重寫規(guī)則配置
更新時間:2016年01月14日 09:17:39 投稿:goldensun
這篇文章主要介紹了PHP的Symfony和CodeIgniter框架的Nginx重寫規(guī)則配置,文中截取配置中關(guān)鍵的一些rewrite寫法進行講解,需要的朋友可以參考下
Symfony
Symfony國外很流行的php框架,目前國內(nèi)用的相對較少,但是一定會在國內(nèi)火起來. nginx重寫規(guī)則如下
server {
server_name jb51.net www.fzitv.net;
root /data/site/www.fzitv.net;
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.fzitv.net_error.log;
}
重啟nginx即可
CodeIgniter
CodeIgniter,即被很多人簡稱為CI的高人氣PHP框架,其中文社區(qū)也比較活躍,來看一下CI的rewrite寫法:
server {
listen 80;
server_name jb51.net www.fzitv.net;
root /data/site/www.fzitv.net;
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.fzitv.net/"; $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ù)完整實現(xiàn)方法
- CI框架表單驗證實例詳解
- CodeIgniter框架常見用法工作總結(jié)
相關(guān)文章
Centos7.3 安裝部署Nginx并配置https的方法步驟
這篇文章主要介紹了Centos7.3 安裝部署Nginx并配置https的方法步驟,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04
在Nginx服務(wù)器中配置mod_proxy反向代理的方法
這篇文章主要介紹了在Nginx服務(wù)器中配置mod_proxy反向代理的方法,Nginx服務(wù)器最大的特點就是作高性能反向代理使用,需要的朋友可以參考下2015-07-07

