0

I have a problem my test server loads html files fine but when I try to open a file like index.php it says The website encountered an error while retrieving http://localhost/. It may be down for maintenance or configured incorrectly. I have PHP5 installed but I don't see why this isn't working, is it an outdated PHP problem?

[Wed Sep 25 16:53:10 2013] [error] [client 127.0.0.1] PHP Warning:  require_once(/home/callum/public_html/Includes/Connection.php): failed to open stream: Permission denied in /home/callum/public_html/index.php on line 8
[Wed Sep 25 16:53:10 2013] [error] [client 127.0.0.1] PHP Fatal error:  require_once(): Failed opening required '/home/callum/public_html/Includes/Connection.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/callum/public_html/index.php on line 8
[Wed Sep 25 16:54:51 2013] [error] [client 127.0.0.1] PHP Warning:  require_once(/home/callum/public_html/Includes/Connection.php): failed to open stream: Permission denied in /home/callum/public_html/index.php on line 8
[Wed Sep 25 16:54:51 2013] [error] [client 127.0.0.1] PHP Fatal error:  require_once(): Failed opening required '/home/callum/public_html/Includes/Connection.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/callum/public_html/index.php on line 8

site config

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /home/callum/public_html/
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /home/callum/public_html/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

</VirtualHost>
2
  • Look at /var/log/apache2/error.log: vi /var/log/apache2/error.log and post it.
    – Manolo
    Commented Sep 25, 2013 at 16:00
  • Added the error log
    – Callum
    Commented Sep 25, 2013 at 16:04

2 Answers 2

1

It is a permissions issue. Just change the permissions:

sudo chmod 0644 /home/callum/public_html/Includes/Connection.php

and try again.

7
  • Didn't work, it made it worse. Said forbidden so I changed back to 0755
    – Callum
    Commented Sep 25, 2013 at 16:10
  • Ok. Go to your php.ini file: cd /etc/php5/apache2/php.ini and comment the line include_path.... Restart the server and try again.
    – Manolo
    Commented Sep 25, 2013 at 16:13
  • It was already commented ; UNIX: "/path1:/path2" ;include_path = ".:/usr/share/php"
    – Callum
    Commented Sep 25, 2013 at 16:17
  • Add the apache site configuration to your question: vi /etc/apache2/sites-available/000-default.conf or the name of your site configuration.
    – Manolo
    Commented Sep 25, 2013 at 16:28
  • Added the sites config
    – Callum
    Commented Sep 25, 2013 at 16:34
0

Instead of this:

require_once(DIR."/Includes/Connection.php");

Use this:

require_once("Includes/Connection.php");
4
  • Nope still get this failed to open stream: Permission denied
    – Callum
    Commented Sep 25, 2013 at 17:04
  • Is the error the same at /var/log/apache2/error.log?
    – Manolo
    Commented Sep 25, 2013 at 17:10
  • I've fixed it now, sorry for any inconvenience. THe problem is that the file access wasn't set.
    – Callum
    Commented Sep 25, 2013 at 17:13
  • Could you specify?
    – Manolo
    Commented Sep 25, 2013 at 17:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.