这几天一直在弄服务器
我把自己的项目拉倒linux上的时候出现了各种permission denied 500 403 的错误
这些错误都可以设置权限来解决,可是遇到了一个我打死也没有想到会错的问题 404。
前思后想 在windows 上一点问题都没有,为什么到linux 上就会出现404的错误呢,既然
在windows上没有错误 那说明代码肯定是没有问题的,有问题的只是重写配置。于是乎开始
了一场跟重写打仗的日子。
找了好久 总算是找到了 原来我卸载项目路径下的.htaccess 或者 nginx.htaccess 文件没有生效,
我索性就把里面的重写规则放到了server配置里面。 bingo 问题完美解决
下面是我的server配置 yii2.0
server { listen 80; #监听端口 root /home/luo/www/720kfang/backend/web; #项目根目录 # Add index.php to the list if you are using PHP index index.php; server_name backend.720kfang.com; #域名 location / { # Redirect everything that isn't a real file to index.php try_files $uri $uri/ /index.php?$args; #yii2.0的重写 } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ .php$ { include snippets/fastcgi-php.conf; # # # With php7.0-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # With php7.0-fpm: fastcgi_pass unix:/run/php/php7.0-fpm.sock; } }