Permission denied when opening localhost - php

I had recently installed Apache, PHP and MySQL in Ubuntu. And copied the files I created to the var/www directory. But when I open http://localhost it is showing
Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
Fatal error: Unknown: Failed opening required '/var/www/index.php'
(include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
How can I run my project normally? It was working fine in windows.

According to this article, you need to give read/execute permissions to Owner, Group, and Everyone.
Set permissions on the problem file to 777. Note, you should avoid doing this on a server that's accessible from the internet.
http://webomania.wordpress.com/2007/03/12/permission-denied-in-unknown-on-line-0/

To fix this problem, look at the line in your ErrorLog, to find out which folder it is trying to access.
If a block already exists for that folder, make sure it is set to allow access as necessary. If not, add a block to your Apache configuration file, allowing access as required. See the example below for folder /usr/local/awstats/htdocs.
Order allow,deny
Allow from all
for a complete reference, check the apache wiki

Related

file_put_contents failed to open stream: Permission denied

Basic php and javascript website
No errors on Wamp
When I put the files on my Lamp server everything works except for this error I get on the top of the page
Warning: file_put_contents(donneesDonut.json): failed to open stream:
Permission denied in /var/www/html/bp/action/IndexAction.php on line
101
I looked around and most people suggest to change the permission of the file or the entire directory on apache.
chmod 777 did nothing for me.
I'm new to web servers so I probably have missed some apache configuration for permissions during the installation process
Here is a screenshot of the directory
Directory listing
I don't think there is a problem with the code since it works on my local Wamp server but here is the line of code that gives me the error.
file_put_contents($this->json, json_encode($this->donneesDonut));
If you need any other information like specific apache configuration please tell me where to get them.
Hope you can help
The problem was SELinux with was set to enforce by default on Centos

Plesk: Access ouside public folder

I’m working on a web site that is hosted on a shared server that uses Plesk.
I want to put the database users config files outside of the public folder (httpdocs) and access them with include_once.
The problem is that the pages that use “include_once” don’t open in a browser, giving an error 500. Looking at the error log I found that the problem is caused by permission issues:
PHP Warning: require_once(PATH TO DB CONFIG): failed to open stream: Permission denied in PATH TO/httpdocs/index.php on line 2
PHP Fatal error: require_once(): Failed opening required 'PATH TO DB CONFIG' (include_path='.:') in PATH TO/httpdocs/index.php on line 2
The folders have a permission of 755, but I think the problem is happening because Plesk doesn’t allow access to folders outside the public folder.
Is there any way to allow access to those files?
Thanks!
You need to set open_basedir for the user, you can do this in Plesk under hosting settings, or via Apache config directly.

Include file from seperate domain on server: Failed to open stream: Permission denied

I just upgraded Plesk to the latest version and it has caused many of my sites to go down.
The websites all rely on a file which is located on another domain on my server so they all host an index file which contains an include like this:
include('/var/www/vhosts/assets-domain.co.uk/httpdocs/websites/index.php');
I am getting the following error when viewing the website:
Warning: include(/var/www/vhosts/assets-domain.co.uk/httpdocs/websites/index.php): failed to open stream: Permission denied in /var/www/vhosts/this-domain.co.uk/httpdocs/index.php on line 3 Warning: include(): Failed opening '/var/www/vhosts/assets-domain.co.uk/httpdocs/websites/index.php' for inclusion (include_path='.:') in /var/www/vhosts/this-domain.co.uk/httpdocs/index.php on line 3
So there is obviously a permissions problem of some sort but I have no idea where to start.
In SSH I have tried changing the ownership of the folder '/var/www/vhosts/assets-domain.co.uk/httpdocs/websites/' with no luck. I have noticed that all my domains have different ownership usernames now - would this affect it? EG.mydomain.com has the user of mydomain, cooldomain.com has the user of cooldomain - would this be why they can't access each others files?
Please help as I have 15+ websites down :-(
Fixed this - Plesk decided to change the permissions so simply changing the domain name folder to 755 solved this

PHP File Uploading Issues

I'm trying to implement script that will allow a file to be uploaded, and then moved to a designated directory. This is running on a Windows server & IIS. I'm having 2 issues in doing so.
First, I get an error when trying to move the file.
Warning: move_uploaded_file(reports/ff.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\inetpub\wwwroot\betterinsight\betterinsight\upload_file.php on line 29
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\Windows\Temp\php1EAB.tmp' to 'reports/ff.jpg' in C:\inetpub\wwwroot\betterinsight\betterinsight\upload_file.php on line 29
Stored in: reports/ff.jpg
When searching, almost everything says it's a permission problem. I have added full rights (will pare down later) to the user: IIS_IUSRS. Even did it to the parent directory as one site recommended.
Second: As a possible solution to the above issue, I tried changing the directory in which files are saved. But the files are still uploaded into C:\windows\temp.
I've run phpinfo, and it says that uploads should be in (as defined by upload_tmp_dir):
Again, this is on a Windows Server 2008. Thanks.
Permission denied
You need to set the folder permissions to 777 or enable read write to the folder. I think the permissions are messing...
OK, the answer was simple. I was adding permissions for user: IIS_USRS, when it should have been just user: USRS.

IIS website "failed to open stream: No such file or directory in C:\inetpub\vhosts\" but file exists there

Hi I have been struggle with a wierd problem. I am using IIS and moved one of my web site folder to desktop of my server and then put it back now I see
Warning: include_once(./lib/config.inc.php) [function.include-once]: failed to open stream: No such file or directory in C:\inetpub\vhosts\politikacim.net\httpdocs\index.php on line 12
Warning: include_once() [function.include]: Failed opening './lib/config.inc.php' for inclusion (include_path='.;./includes;./pear') in C:\inetpub\vhosts\politikacim.net\httpdocs\index.php on line 12
this kind of error. I looked at my root folder and see it's permission is system and administrator full access , how can I make it work ? Please help me.
Given the error messages, you'd need to have your config.inc.php file in one of the following locations:
C:\inetpub\vhosts\politikacim.net\httpdocs\lib\config.inc.php
C:\inetpub\vhosts\politikacim.net\httpdocs\includes\config.inc.php
C:\inetpub\vhosts\politikacim.net\httpdocs\pear\config.inc.php
system/admin permissions are irrelevant if your webserver is running under some other user account. You must grant permissions based on your webserver's userid, not your own personal one, or some other account.

Categories