简体   繁体   English

php包含问题

[英]php include problem

When i try to load a page that resides in /var/www/vhosts/mypage/httpdocs/index.php using a browser I get an include error that it cannot include file which is in /var/www/fw/trunk. 当我尝试使用浏览器加载位于/var/www/vhosts/mypage/httpdocs/index.php中的页面时,出现了包含错误,该错误无法包含/ var / www / fw / trunk中的文件。

include path is set to include_path='.:/var/www/fw/trunk'. 包含路径设置为include_path ='。:/ var / www / fw / trunk'。

But when I try to load it from console using 'php index.php' it loads fine, i guess it some kind of a permission problem but I can't seem to find what and where. 但是,当我尝试使用“ php index.php”从控制台加载它时,它可以很好地加载,我想这是一种权限问题,但我似乎找不到任何内容和位置。

You need to make sure that the webserver or php process is able to read the folder an the files at least. 您需要确保Web服务器或PHP进程至少能够读取文件夹和文件。 Search for chown and chmod . 搜索chownchmod

Your web server is probably accessing the file system as www-data. 您的Web服务器可能正在以www-data的身份访问文件系统。 You should make sure /var/www/fw/trunk is readable by that user or group. 您应该确保该用户或组可以读取/ var / www / fw / trunk。

You can test this by switching to the www-data user and manually viewing the file. 您可以通过切换到www-data用户并手动查看文件来进行测试。

As root, you can switch user without knowing the password. 作为root用户,您可以在不知道密码的情况下切换用户。

su www-data

If you encounter a directory you can not traverse as www-data, your web app will also fail there. 如果遇到无法作为www-data遍历的目录,则Web应用程序也将在那里失败。 You can use chmod to open the directory. 您可以使用chmod打开目录。

I found a solution, it was this thing I had to put in a config file for that virutal host: 我找到了解决方案,这是我必须在该虚拟主机中放入的配置文件:

php_admin_value safe_mode off php_admin_value safe_mode关闭

php_admin_value open_basedir none php_admin_value open_basedir无

Does the page you're trying to include compile? 您要包含的页面是否可以编译?

Otherwise, make sure that read and execute permission is given to everyone. 否则,请确保向所有人授予读取和执行权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM