我使用composer设置了yii2。我在apache中修改了前端和后端,以显示为alieses - yii2f
和yii2b
。我正在尝试使用网址yii2f/index.php/gii
访问gii,但我一直在追踪错误
2015-03-25 15:42:10 [172.16.0.85][-][-][warning][yii\gii\Module::checkAccess] Access to Gii is denied due to IP address restriction. The requested IP is 172.16.0.85
2015-03-25 15:42:10 [172.16.0.85][-][-][error][yii\web\HttpException:403] exception 'yii\web\ForbiddenHttpException' with message 'You are not allowed to access this page.' in /opt/html/yii-2.0/vendor/yiisoft/yii2-gii/Module.php:112
Stack trace:
#0 /opt/html/yii-2.0/vendor/yiisoft/yii2/base/Controller.php(139): yii\gii\Module->beforeAction(Object(yii\base\InlineAction))
#1 /opt/html/yii-2.0/vendor/yiisoft/yii2/base/Module.php(455): yii\base\Controller->runAction('index', Array)
#2 /opt/html/yii-2.0/vendor/yiisoft/yii2/web/Application.php(83): yii\base\Module->runAction('gii/default/ind...', Array)
#3 /opt/html/yii-2.0/vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#4 /opt/html/yii-2.0/frontend/web/index.php(18): yii\base\Application->run()
#5 {main}
2015-03-25 15:42:10 [172.16.0.85][-][-][warning][yii\debug\Module::checkAccess] Access to debugger is denied due to IP address restriction. The requesting IP address is 172.16.0.85
in /opt/html/yii-2.0/frontend/views/layouts/main.php:74
2015-03-25 15:42:10 [172.16.0.85][-][-][info][application] $_COOKIE = [
'PHPSESSID' => '9fmtgldc4krsjeggqo9q2tafk1'
'_csrf' => 'f2dfc7f1516406f041cef38518ae78a76f51f05ec36dab48e2d9ffc77264682ca:2:{i:0;s:5:\"_csrf\";i:1;s:32:\"GECpwLgY_TPEr_GGf7IXSvq2TIKVzK-t\";}'
]
$_SESSION = [
'__flash' => []
]
我修改的配置文件是common/config/main-local.php
if (!YII_ENV_TEST) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module';
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = 'yii\gii\Module';
}
return [
'bootstrap' => ['gii'],
'modules' => [
'gii' => 'yii\gii\Module',
'allowedIPs' => ['127.0.0.1', '::1','172.16.0.85'] //allowing ip's
],
'modules' => [
'gii' => [
'class' => 'yii\gii\Module', //adding gii module
'allowedIPs' => ['127.0.0.1', '::1','172.16.0.85'] //allowing ip's
],
],
'components' => [
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
....
我必须从Module.php
取消注释。
/*if (Yii::$app instanceof \yii\web\Application && !$this->checkAccess()) {
throw new ForbiddenHttpException('You are not allowed to access this page.');
}*/
第二个问题
一旦我进入了gii页面,我点击了任何链接,它将我重定向到/yii2f/gii/model
并显示错误消息
File does not exist: /opt/html/yii-2.0/frontend/web/gii, referer: http://portal-test/yii2f/index.php/gii