PHP 學(xué)習(xí)中遇到的坑

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 是無法給遠(yuǎn)程連接的用戶權(quán)限問題

解決方法

在mysql命令行輸入
GRANT ALL PRIVILEGES ON *.* TO '數(shù)據(jù)庫用戶名'@'%' IDENTIFIED BY '數(shù)據(jù)庫密碼' 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'],
            
        ],
    ],
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容