今天嘗試在家裏鏈接公司外部服務器的yii框架的gii功能,提示 php
You are not allowed to access this page. bootstrap
因而花了較長的時間在百度和論壇上尋找yii2 外部pc端訪問gii功能時的配置方法, 大多都是說須要找到main.php文件,而後改變默認的ip訪問地址(127.0.0.1)實現, 可是找了半天無果。 本身官網文檔找了很久解決方案以下:服務器
在文件vendor\yiisoft\yii2-gii\Module.php 中yii2
/**
* @var array the list of IPs that are allowed to access this module.
* Each array element represents a single IP filter which can be either an IP address
* or an address with wildcard (e.g. 192.168.0.*) to represent a network segment.
* The default value is `['127.0.0.1', '::1']`, which means the module can only be accessed
* by localhost.
*/
public $allowedIPs = ['115.123.134.185(替換爲你如今的電腦ip)', '::1']; 框架
解決了一個小問題。yii
2016-07-13 更正: 本着不隨意修改源碼的原則, 直接在配置文件進行配置修改;this
修改以下:spa
在config/main-local.php中加入:.net
'allowedIPs' => ['127.0.0.1', '::1','*'], // 這裏容許全部用戶加載giidebug
詳細以下:
if (!YII_ENV_TEST) { // configuration adjustments for 'dev' environment $config['bootstrap'][] = 'debug'; $config['modules']['debug'] = [ 'class' => 'yii\debug\Module', ]; $config['bootstrap'][] = 'gii'; $config['modules']['gii'] = [ 'class' => 'yii\gii\Module', 'allowedIPs' => ['127.0.0.1', '::1','*'], // 這裏容許全部用戶加載gii ]; }