我有一個基於codeigniter的php應用程序,我有一個數據庫,位於遠程主機上,安裝了所需的數據庫,設置正確的mysql權限並打開遠程連接的mysql端口,但是,當我運行該應用程序時,它不起作用,並返回500錯誤代碼。mysqli不能連接到Apache下
當我解決問題,它提供了以下錯誤
消息:mysqli的:: real_connect():(HY000/2003):無法連接到MySQL服務器上的 '192.168.6.13'(13 )
我所到目前爲止已經試過:
1)確保所有的權限設置是否正確。
2)確保沒有網絡相關的問題,如阻塞端口/主機
3)確保mysqli的已安裝並啓用的存在。
4)創建了一個連接測試php腳本,並從命令行運行它,它工作得很好。
5)的樂趣的部分是當我跑從命令行應用程序,它正確地工作了作爲根用戶和作爲apache的用戶作爲su -s /bin/sh apache -c "php index.php".
參數I具有:
1)PHP版本是PHP 5.4 0.16
2)操作系統版本:CentOS的Linux的發佈1511年2月7日(Web和數據庫
3)Web服務器版本的Apache/2.4.6(CentOS的)核心)
版本14.145)我跑在SSL我的應用程序,並在下面
4)MySQL的是我的配置
<VirtualHost *:443>
#### Gloabl config
DocumentRoot /var/www/bein
DirectoryIndex index.php
ServerName beinmob.com
ServerAlias www.beinmob.com
#### change basic URL to /index.php/POS_Admin/Session
RewriteEngine on
RewriteRule ^/?$ index.php/POS_Admin/Session [R]
#### change url to alias for web services
Alias /web-services /var/www/bein/index.php
Alias /POS_Admin /var/www/bein/
#### Basic Authentication for /web-services url
<Location /POS_Admin>
RewriteEngine on
# Hide the application and system directories by redirecting the request to index.php
RewriteBase /index.php
RewriteRule ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</Location>
<Location /web-services>
AuthName bein
AuthType Basic
AuthUserFile /etc/httpd/conf.d/beinServicePass
Require valid-user
</Location>
#### SSL configuration
SSLEngine on
SSLCertificateFile /etc/httpd/cert/certs/www_beinmob_com.crt
SSLCertificateKeyFile /etc/httpd/cert/certs/www_beinmob_com.key
SSLCertificateChainFile /etc/httpd/cert/certs/DigiCertCA.crt
</VirtualHost>
您的Apache配置是無關緊要的。 Apache與PHP嘗試連接到MySQL無關。或者你的mysql沒有監聽TCP連接,沒有監聽特定的IP,或者你使用了錯誤的IP,或者IP以某種方式被防火牆阻擋。 –
http://serverfault.com/questions/503489/cant-connect-to-mysql-server-13-using-php-function –