Yii的Nginx rewrite
如下为nginx yii的重写
?
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 |
server {
set $host_path "/data/site/www.zzvips.com";
access_log /data/logs/nginx/www.zzvips.com_access.log main;
server_name zzvips.com www.zzvips.com;
root $host_path/htdocs;
set $yii_bootstrap "index.php";
# define charset
charset utf-8;
location / {
index index.html $yii_bootstrap;
try_files $uri $uri/ /$yii_bootstrap?$args;
}
# deny access to protected directories
location ~ ^/(protected|framework|themes/w+/views) {
deny all;
}
#avoid processing of calls to unexisting static files by yii
location ~ .(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
try_files $uri =404;
}
# prevent nginx from serving dotfiles (.htaccess, .svn, .git, etc.)
location ~ /. {
deny all;
access_log off;
log_not_found off;
}
# php-fpm configuration using socket
location ~ .php {
fastcgi_split_path_info ^(.+.php)(.*)$;
#yii catches the calls to unexising PHP files
set $fsn /$yii_bootstrap;
if (-f $document_root$fastcgi_script_name){
set $fsn $fastcgi_script_name;
}
fastcgi_pass unix:/tmp/php5-fpm.sock; # 改成你对应的FastCGI
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fsn;
#PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fsn;
## Tweak fastcgi buffers, just in case.
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
} |
配置完了别忘了重启Nginx。
CakePHP的Nginx重写规则
依然简单粗暴,直接上代码例子,nginx重写规则如下
?
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 |
server {
listen 80;
server_name www.zzvips.com;
root /data/site/www.zzvips.com;
index index.php;
access_log /data/logs/nginx/www.zzvips.com_accerss.log;
error_log /data/logs/nginx/www.zzvips.com_error.log;
# main cakephp rewrite rule
location / {
try_files $uri $uri/ /index.php?$uri&$args;
}
location ~ .php$ {
root /data/site/www.zzvips.com;
try_files $uri =404;
fastcgi_pass unix:/tmp/php5-fpm.sock; # 改成你对应的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;
}
} |
重启nginx即可
相关文章
猜你喜欢
- 64M VPS建站:怎样优化以提高网站加载速度? 2025-06-10
- 64M VPS建站:是否适合初学者操作和管理? 2025-06-10
- ASP.NET自助建站系统中的用户注册和登录功能定制方法 2025-06-10
- ASP.NET自助建站系统的域名绑定与解析教程 2025-06-10
- 个人服务器网站搭建:如何选择合适的服务器提供商? 2025-06-10
TA的动态
- 2025-07-10 怎样使用阿里云的安全工具进行服务器漏洞扫描和修复?
- 2025-07-10 怎样使用命令行工具优化Linux云服务器的Ping性能?
- 2025-07-10 怎样使用Xshell连接华为云服务器,实现高效远程管理?
- 2025-07-10 怎样利用云服务器D盘搭建稳定、高效的网站托管环境?
- 2025-07-10 怎样使用阿里云的安全组功能来增强服务器防火墙的安全性?
快网idc优惠网
QQ交流群
您的支持,是我们最大的动力!
热门文章
-
2025-05-29 39
-
thinkphp6使用mysql悲观锁解决商品超卖问题的实现
2025-05-27 81 -
2025-05-29 72
-
2025-05-25 20
-
2025-05-29 44
热门评论

