abhi143
Posts: 80
Joined: Mon Oct 30, 2017 4:17 am

Getting permission denied error

Thu Dec 07, 2017 9:58 am

I think "permission denied " means that operating system is not permitting any file to be execute on the server. I have installed raspbain jessie lite opearting system and apache server. When I try to execute php program on apache server. it give permission denied error. That mean's raspbain operating system doesn't give permission to execute any php file on apache server.

I have seen that we should not give the Sudo Permission to the user if we give sudo permission to user it would be a massive security hole

We are executing the php program on the server, Is this the only reason. If I execute another program like python then Do I still need permissions?

User avatar
topguy
Posts: 3726
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Getting permission denied error

Thu Dec 07, 2017 3:30 pm

Each file has its own permissions the ending of the filename does NOT matter at all on Linux, one PHP file might have completely different persmissions than others. You have to check the permissions of your files and also the directory it is in.

Apache server usually run as the user "www-data" so all files that the server must read/write or access in any other way needs to be accessible by the "www-data" user.
But that also means that if you PHP (or python) script called by the apache server ALSO tried to access other files on the system those files ALSO need to be accessible by the "www-data" user.

Most of these problems can be solved without using "sudo".

abhi143
Posts: 80
Joined: Mon Oct 30, 2017 4:17 am

Re: Getting permission denied error

Thu Dec 07, 2017 5:15 pm

topguy wrote:
Thu Dec 07, 2017 3:30 pm
Most of these problems can be solved without using "sudo".
What are the other way's?

User avatar
topguy
Posts: 3726
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Getting permission denied error

Thu Dec 07, 2017 5:35 pm

1: Correcting permissions on files and directories.
2: Adding users to the correct group to give access to specific files or directories.

You do 1 first and only do 2 if 1 is not practical.
But you havent really given enough details ( not even who/where/when "persmission denied" is given as response ) for me to be more specific.

User avatar
DougieLawson
Posts: 30505
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Getting permission denied error

Thu Dec 07, 2017 5:48 pm

abhi143 wrote:
Thu Dec 07, 2017 5:15 pm
topguy wrote:
Thu Dec 07, 2017 3:30 pm
Most of these problems can be solved without using "sudo".
What are the other way's? [sic]
One other way is to start with a fresh SDCard with a copy of Raspbian 2017-11-29 or NOOBS 2.4.5. Then make notes of everything you change, so that when you break something you can take a small step back rather than a fresh install.

Once permissions are messed up, then it's a very long job with lots of effort to fix the mess. Don't use chown or chmod without understanding the consequences of your action.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

abhi143
Posts: 80
Joined: Mon Oct 30, 2017 4:17 am

Re: Getting permission denied error

Thu Dec 07, 2017 6:11 pm

DougieLawson wrote:
Thu Dec 07, 2017 5:48 pm
Once permissions are messed up, then it's a very long job with lots of effort to fix the mess. Don't use chown or chmod without understanding the consequences of your action.
What is meaning of this paragraph
To fix this, run the sudo visudo command and add the following line to the sudoers file:

www-data ALL=NOPASSWD: ALL

Also, make sure that the /var/www directory belongs to the www-data user and group (use sudo chown -R www-data:www-data /var/www to set the correct owner).

User avatar
DougieLawson
Posts: 30505
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Getting permission denied error

Thu Dec 07, 2017 7:16 pm

abhi143 wrote:
Thu Dec 07, 2017 6:11 pm
DougieLawson wrote:
Thu Dec 07, 2017 5:48 pm
Once permissions are messed up, then it's a very long job with lots of effort to fix the mess. Don't use chown or chmod without understanding the consequences of your action.
What is meaning of this paragraph
You've broken your system, a fresh install is the fastest route to recover from the damage you've done to your Linux filesystem.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 46 guests