简体   繁体   English

PHP5 apache无法从另一个目录工作

[英]PHP5 apache not working from another directory

I'm kinda novice on setting up a PHP environment (Apache), but nothing to do about it. 我对建立一个PHP环境(Apache)很新手,但没什么好处的。 I have a VPS, which has Ubuntu 12.04 LTS. 我有一个VPS,它有Ubuntu 12.04 LTS。

My issue is that I receive following error: 我的问题是我收到以下错误:

[Wed Nov 13 16:43:31 2013] [error] [client 127.0.0.1] PHP Fatal error: Unknown: Failed opening required '/root/blog/index.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0 [Wed 11月16日16:43:31] [错误] [客户端127.0.0.1] PHP致命错误:未知:未能打开所需的'/root/blog/index.php'(include_path ='。:/ usr / share / php:/ usr / share / pear')在第0行的Unknown中

index.php contains following code: index.php包含以下代码:

<?php  
print phpinfo();  
?>

It is WORKING IF it is located under "/var/www/" directory. 如果它位于“/ var / www /”目录下,它正在工作 But I wanted to change the location of the script to "/root/blog". 但我想将脚本的位置更改为“/ root / blog”。

I have re-configured the " 000-default " configuration file under "sites-enabled" folder in apache2 folder. 我已经在apache2文件夹中的“sites-enabled”文件夹下重新配置了“ 000-default ”配置文件。 So it shouldn't be a problem. 所以它应该不是问题。

I've tried assigning different permissions (chmod 777) to "/root/blog" folder (both: recursively and traditionally), but no avail. 我已经尝试将不同的权限(chmod 777)分配给“/ root / blog”文件夹(两者:递归和传统),但无济于事。

I've checked the user and user group for the "/var/www" folder and files, and they are: root/root - root user and root group. 我已经检查了用户和用户组的“/ var / www”文件夹和文件,它们是:root / root - root用户和root组。 So, that should not be an issue. 所以,这应该不是问题。

What should I do about it ? 我该怎么办呢? Can someone help me ? 有人能帮我吗 ?

PS AFAIK, apache version: 2.2, PHP: 5.3.10 (installed today, using apt-get install php5 apache2) PS AFAIK,apache版本:2.2,PHP:5.3.10(今天安装,使用apt-get install php5 apache2)

I imagine the problem comes from the Apache user not having permission to read/execute files under the /root directory, since after all, that's the root user's home directory. 我想这个问题来自Apache用户没有权限读取/执行/root目录下的文件,因为毕竟这是root用户的主目录。

I really recommend you don't serve your website from /root but if you really want to try executing this command: 我真的建议你不要从/root服务你的网站,但如果你真的想尝试执行这个命令:

chown -R nobody /root/blog

(I'm assuming nobody is your Apache's user) (我假设nobody是你的Apache的用户)

Out of curiosity, why run the website from /root ? 出于好奇,为什么要从/root运行网站? /var/www is the standard location for website files and if it works when the files are under this directory why not stick to it? /var/www是网站文件的标准位置,如果文件在这个目录下,它可以工作,为什么不坚持呢?

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

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