nginx完美支持yii2框架

时间:2022-10-05 07:58:10

 

nginx完美支持yii2框架

server {
listen 80;
server_name www.peita.net peita.net;
# default_server;
access_log /data/wwwlogs/www.peita.net_nginx.log combined;
index index.html index.htm index.php;
include /usr/local/nginx/conf/wordpress.conf;
root /data/wwwroot/pet/backend/web;
if ($host != www.peita.net) {
rewrite ^/(.*)$ $scheme://www.peita.net/$1 permanent;
}

location ~ [^/]\.php(/|$) {
#fastcgi_pass remote_php_ip:9000;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
expires 30d;
access_log off;
}
location ~ .*\.(js|css)?$ {
expires 7d;
access_log off;
}
}

 

 

改完后的框架访问路由改为:www.peita.net/控制器/方法名       或者    www.peita.net/控制器/方法名?参数=