yii2在linux下nginx部署

1.创建域名对应到那个根目录,同时yii2的要加上重新规则,标红的是新加的

server {
listen 80;
server_name yii.lixuefeng.date;
access_log /data/wwwlogs/yii.lixuefeng.date_nginx.log combined;
index index.html index.htm index.php;
include /usr/local/nginx/conf/none.conf;
root /data/wwwroot/yii.lixuefeng.date/advanced/frontend/web;

location / {
# Redirect everything that isn't a real file to index.php
try_files $uri $uri/ /index.php?$args;

}

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;
}
}

2.最后打开yii.lixuefeng.date的时候要加上.index.php才能行,如果美化路由开启后就不要了

您可以选择一种方式赞助本站

支付宝转账赞助

支付宝扫一扫赞助

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

图片 表情