PHP 学习中遇到的坑

2017-01-17  本文已影响32人  吃肉666

Apache重启时报警:

AH00112: Warning: DocumentRoot [/usr/local/apache/docs/dummy-host.example.com] does not exist

AH00112: Warning: DocumentRoot [/usr/local/apache/docs/dummy-host2.example.com] does not exist

问题原因:

Apache在配置虚拟主机时会在配置文件中(httpd.conf)开启虚拟主机的配置文件;

将“ #Include /etc/httpd/extra/httpd-vhosts.conf ”前面的“#”去掉;

而“httpd-vhosts.conf ”中会有两个配置虚拟主机的例子:

<VirtualHost *:80>
  ServerAdmin webmaster@dummy-host.example.com
   DocumentRoot "/usr/local/apache/docs/dummy-host.example.com"
   ServerName dummy-host.example.com
   ServerAlias www.dummy-host.example.com
   ErrorLog "logs/dummy-host.example.com-error_log"
   CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>

<VirtualHost *:80>
   ServerAdmin webmaster@dummy-host2.example.com
   DocumentRoot "/usr/local/apache/docs/dummy-host2.example.com"
   ServerName dummy-host2.example.com
   ErrorLog "logs/dummy-host2.example.com-error_log"
   CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>

这样Apache在启动时就会去寻找以上两个不存在的文件夹,就会报错。

解决方法:
方法二:将“httpd-vhosts.conf ”中的例子注释掉;

#<VirtualHost *:80>
  #    ServerAdmin webmaster@dummy-host2.example.com
  #    DocumentRoot "/usr/local/apache/docs/dummy-host2.example.com"
  #    ServerName dummy-host2.example.com
  #   ErrorLog "logs/dummy-host2.example.com-error_log"
  #    CustomLog "logs/dummy-host2.example.com-access_log" common
  #</VirtualHost>

问题

$link = mysqli_connect('192.168.0.102','root','123456','my_database');

把192.168.0.102换成127.0.0.1就OK
错误代码是1130,ERROR 1130: Host xxx.xxx.xxx.xxx is not allowed to connect to this MySQL server 是无法给远程连接的用户权限问题

解决方法

在mysql命令行输入
GRANT ALL PRIVILEGES ON *.* TO '数据库用户名'@'%' IDENTIFIED BY '数据库密码' WITH GRANT OPTION;
看到Query OK, 0 rows affected, 1 warning (0.01 sec) 表示OK了

问题

Yii2 Gii http://localhost/blogDemo2/backend/web/index.php?r=gii没问题
http://192.168.0.102/blogDemo2/backend/web/index.php?r=gii就报错
Forbidden code 403 You are not allowed to access this page

解决方法

在main.php增加

'modules' => [
        'gii' => [
            'class' => 'yii\gii\Module',
            'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.102'],
            
        ],
    ],
上一篇 下一篇

猜你喜欢

热点阅读