0
votes

I'm kinda novice on setting up a PHP environment (Apache), but nothing to do about it. I have a VPS, which has 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

index.php contains following code:

<?php  
print phpinfo();  
?>

It is WORKING IF it is located under "/var/www/" directory. But I wanted to change the location of the script to "/root/blog".

I have re-configured the "000-default" configuration file under "sites-enabled" folder in apache2 folder. 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.

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. So, that should not be an issue.

What should I do about it ? Can someone help me ?

P.S AFAIK, apache version: 2.2, PHP: 5.3.10 (installed today, using apt-get install php5 apache2)

1
do not use the home folder of the root user as a public document rootGerald Schneider
Whats about it ? Even if I won't be using it anyhow - I still want to know, how would I change the directory, if I want toDmitri
phpinfo() by default performs output. the print call is pointless. and /root? If that's an absolute path, then PHP is HIGHLY unlikely to be loading things from the root account's home folder.Marc B
Thanks, but this is not the problem itself. This script works totally OK under "/var/www" directory and not from "/root/blog"Dmitri

1 Answers

2
votes

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.

I really recommend you don't serve your website from /root but if you really want to try executing this command:

chown -R nobody /root/blog

(I'm assuming nobody is your Apache's user)

Out of curiosity, why run the website from /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?