问题
I have set up yii2 using composer. i have modified front end and backend in apache to display as alieses - yii2f
and yii2b
. I am trying to access gii using url yii2f/index.php/gii
but i keep hetting following error
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' => []
]
My config file i have modified is 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'],
],
],
],
....
I had to uncomment following from Module.php
.
/*if (Yii::$app instanceof \yii\web\Application && !$this->checkAccess()) {
throw new ForbiddenHttpException('You are not allowed to access this page.');
}*/
2nd Question
Once i am in th gii page and i click on any link it redirects me to /yii2f/gii/model
with error message
File does not exist: /opt/html/yii-2.0/frontend/web/gii, referer: http://portal-test/yii2f/index.php/gii
来源:https://stackoverflow.com/questions/29260299/yii2-access-denied-to-gii