2013-02-05 44 views
0
-rw-r--r-- 1 root  root  514 Jan 15 04:03 curl.php 
-rw-r----- 1 root  root  1344 Feb 5 02:09 dbm-config.ini 
-rw-r--r-- 1 root  root  5149 Feb 5 02:19 mysql-connectivity-status.php 

这里访问URL从一个文件,上午访问来自URL文件“mysql的连接性,status.php”像
http://<ip>/html/DB-Monitoring/mysql-connectivity-status.php如何使用curl

mysql-connectivity-status.php我打电话给文件dbm-config.ini。通过URL访问时,我得到以下警告。

Warning: parse_ini_file(/var/www/html/DB-Monitoring/dbm-config.ini): failed to open stream: Permission denied in /var/www/html/DB-Monitoring/mysql-connectivity-status.php on line 113 

所以,我不想更改dbm-config.ini许可但如何我访问使用URL文件?

+0

您碰巧知道您是否在服务器上运行SuPHP或PHPExec?你应该能够通过phpinfo()找到。我可能只是将文件的权限更改为644,然后通过htaccess阻止对文件的直接访问,以便PHP仍可以访问它。 [这可能有所帮助](http://stackoverflow.com/questions/1340001/deny-direct-access-to-all-php-files-except-index-php) – djthoms

回答

2

-rw-R ----- 1个根1344 2月5日02:09 DBM-的config.ini

该文件可以被读出和写入,由用户根rw-从该组根r--

如果您访问使用curl php文件,就执行最有可能与您的网络服务器用户和组的成员阅读这是不root:root

这就是为什么PHP无法读取Ť他ini文件。 我建议将文件移到您的文档根目录,因此它不能直接通过web访问,那么所有者更改为你的服务器的用户和组

确定用户名PHP与

ps aux | grep "httpd" # apache environment 
ps aux | grep "php" # php fastcgi environment 

chown user:group dbm-config.ini 
执行
1

问题是您的网络服务器无法访问该文件。如果您无法解决问题,则无法通过该Web服务器远程访问它。 :)

胡乱猜测,因为我不知道你使用的是什么:

chown root:apache dbm-config.ini 
chmod g+r dbm-config.ini 

可能的帮助。这会将该文件的拥有组设置为apache并授予该组的读取权限。如果你的web服务器是apache,并且这是正确的组,它可能会有所帮助。