Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache+php doesn't open php script from certain directory

Tags:

linux

php

apache

I have two directories in /var/www:

root@user:/var/www# ls -l
drwxrwxrwx 2 root root      4096 Июл 14 17:59 first
drwxrwxrwx 2 root root      4096 Июл 14 18:00 second

with exactly the same php scripts:

root@user:/var/www# ls -l first/
-rwxrwxrwx 1 root root 20 Июл 14 16:37 info.php

root@user:/var/www# ls -l second/
-rwxrwxrwx 1 root root 20 Июл 14 16:37 info.php

info.php:

<?php
phpinfo();
?>

But from the first/ directory Apache opens script, from the second/ pulls error:

( ! ) Warning: Unknown: failed to open stream: Operation not permitted in Unknown on line 0

( ! ) Warning: Unknown: failed to open stream: Operation not permitted in Unknown on line 0

( ! ) Fatal error: Unknown: Failed opening required '/var/www/second/info.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0

What can be a reason?

Directory config:

DocumentRoot "/var/www"

<Directory "/var/www">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
</Directory>
like image 717
Sas Avatar asked Jul 14 '14 14:07

Sas


People also ask

Why does my Web browser not give the output of my PHP it only shows my PHP codes?

You're just opening your php file into browser. You have to open it using localhost url. if you open a file directly from your directory it will not execute the php code in any case. Enable php short code.

Why is my PHP page not working?

The most common reason for a blank page is that the script is missing a character. If you left out a ' or } or ; somewhere, your PHP won't work. You don't get an error; you just get a blank screen.


1 Answers

You need to change the owner of the two folders from 'root' to apache.

Try sudo chown -R [yourusername]:www-data /var/www

This should help.

like image 84
MustafaG Avatar answered Sep 20 '22 03:09

MustafaG