包括在PHP不工作的Linux的Apache2 [英] Include php not working linux apache2

查看:141
本文介绍了包括在PHP不工作的Linux的Apache2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天。也许,这是一个重复的,但我没有找到答案对我来说。我已经制定了本地服务器(Apache2.4,Windows)中,所有的工作都一个PHP的网站。包括文件不能正常工作的Debian VPS服务器与Apache2的。什么会导致这个问题?

 &LT ;?包括/include/libs.php';?>


解决方案

三个原因,我猜结果
第一:搜索结果
您可能没有权限/权限来访问你的努力包括文件。结果
   通常,这是涉及到失败包括语句非常错误。结果
   尝试运行此code:结果
  < PHP
  后续代码var_dump(SUBSTR(sprintf的('%O',fileperms('/有/ libs.php')),-4));
 ?>

  如果输出的最后三个数字都低于7,5和5分别然后你在一个文件权限问题,赶上了。结果
您可以通过改变包括文件(S)权限在bash结果解决此错误
  sudo的搭配chmod -R 0755 /var/www/include/libs.php 结果
使用 sudo的搭配chmod 0755 /var/www/html/include/libs.php 相反,如果你的Apache版本是2.4以上结果
请注意,您需要使用 -R 标志CHMOD让你所有的上层文件夹也chmodded。结果

第二:结果
你没有运行PHP作为默认Apache2的用户组,或者你includee文件属于根。结果
这一点,像previous原因也文件权限异常。结果


 须藤CHOWNWWW的数据/var/www/include/libs.php

 须藤chgrp命令WWW的数据/var/www/include/libs.php
然后按须藤服务的Apache2重启在bash。搜索结果
第三:结果
您可能已经搞砸你的Apache2 / PHP安装/配置设置。结果
sudo易于得到净化PHP5 命令和apt-get安装在bash PHP5 。结果
请记住,他会燃烧所有的自定义的php.ini 设置,您可能需要从头开始正确的配置。 [我这学到了艰辛的道路:D]。
结果
结果
希望这可以帮助 ...



更新:

之后我读了没有错误显示,搜索
我想到你的默认配置PHP5结果...
打开须藤gedit中/etc/php5/apache2/php.ini 结果
更改行的display_errors =关闭的display_errors =开结果
这是当我安装从零开始的php我有问题...

Good day. Maybe, it's a duplicate, but I didn't found an answer for me. I have developed a PHP site on local server (Apache2.4, Windows) and all were working. Including files isn't working on Debian VPS server with apache2. What can cause this problem?

<? include '/include/libs.php';?>

解决方案

Three reasons I'm guessing
First:

You may not have privileges/permissions to access the file your trying to include.
Usually, this is the very error involved with failed include statements.
Try running this code:
<?php var_dump(substr(sprintf('%o', fileperms('/include/libs.php')), -4)); ?> If the last three digits of output are less than 7, 5 and 5 respectively then you're caught up in a file permission problem.
You can resolve this error by changing the including file(s) permissions in bash
sudo chmod -R 0755 /var/www/include/libs.php
Use sudo chmod 0755 /var/www/html/include/libs.php instead, if, your apache version is above 2.4
Note that you need to use the -R flag for chmod so that all your enclosing folders are also chmodded.

Second:
You are not running php as the default apache2 user-group OR your includee file belongs to root.
This, like the previous reason is also file permission exception.
run sudo chown "www-data" /var/www/include/libs.php OR sudo chgrp "www-data" /var/www/include/libs.php followed by sudo service apache2 restart in bash.

Third:
You may have screwed your apache2/PHP installation/configuration settings.
Hit sudo apt-get purge php5 and the sudo apt-get install php5 in bash.
Keep in mind that his WILL burn all your custom php.ini settings and you may need to start configuring right from the beginning. [ I learned this the hard way :D ].

Hope this helps ...

UPDATE:
After i read that there is no error shown,
it occurred to me you have the default php5 config ...
open sudo gedit /etc/php5/apache2/php.ini
Change the line display_errors = Off to display_errors = On
This was the problem I had when I installed php from scratch ...

这篇关于包括在PHP不工作的Linux的Apache2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆