美文网首页
yii在Apache环境正常访问,在nginx环境报404,gi

yii在Apache环境正常访问,在nginx环境报404,gi

作者: 亚妮先森 | 来源:发表于2020-01-13 18:05 被阅读0次

默认项目的伪静态是阿帕奇使用的,也就是web目录下的.htaccess文件;

nginx不回去读取这个配置文件的,所以要另外设置伪静态,

location / {

        try_files $uri $uri/ /index.php$is_args$args;

}

gii访问403是因为默认只允许本地访问,也就是127.0.0.1;

config/web.php中找到

$config['bootstrap'][] = 'gii';

    $config['modules']['gii'] = [

        'class' => 'yii\gii\Module',

        // uncomment the following to add your IP if you are not connecting from localhost.

        //'allowedIPs' => ['127.0.0.1', '::1'],

    ];

改成:

$config['bootstrap'][] = 'gii';

    $config['modules']['gii'] = [

        'class' => 'yii\gii\Module',

        // uncomment the following to add your IP if you are not connecting from localhost.

        'allowedIPs' => ['127.0.0.1', '::1','180.140.114.77'],

    ];

第五行去掉注释,在末尾加上自己电脑的ip地址即可

相关文章

网友评论

      本文标题:yii在Apache环境正常访问,在nginx环境报404,gi

      本文链接:https://www.haomeiwen.com/subject/myjnactx.html