LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 11-24-2009, 02:35 AM   #1
Zabrajin
LQ Newbie
 
Registered: Nov 2009
Posts: 8

Rep: Reputation: 0
Permission denied even with chmod 777


Hello everyone,

i've just setup my first Linux server and installed apache + php. I have a simple PHP script which should just create ja directory. But i always get the following error:

PHP Warning: mkdir() [function.mkdir]: Permission denied in /var/www/html/default/test.php on line 3

So as you can see the script is within the folder 'default' which has rights set so 777

Code:
ls -rtl
drwxrwxrwx  2 apache apache 4096 2009-11-23 19:38 default
The php script contains this:
PHP Code:
<?
echo substr(decoctfileperms('.') ), 2);
mkdir("/var/www/html/default/test");
?>
The first line, which echos the current permission shows 777

I've also checked if the httpd process is running with the right user:

Code:
ps aux | grep httpd
root      6765  0.0  0.8 272440  9080 ?        Ss   Nov23   0:08 /usr/sbin/httpd
apache   13158  0.0  0.9 274536  9292 ?        R    02:47   0:00 /usr/sbin/httpd
apache   13213  0.0  0.8 273492  8804 ?        S    02:49   0:00 /usr/sbin/httpd
apache   13228  0.0  0.9 273940  9280 ?        R    02:49   0:00 /usr/sbin/httpd
apache   13238  0.1  0.8 273748  8844 ?        R    02:49   0:00 /usr/sbin/httpd
apache   13246  0.0  0.8 273748  8864 ?        R    02:49   0:00 /usr/sbin/httpd
apache   13250  0.0  0.8 273752  9064 ?        R    02:49   0:00 /usr/sbin/httpd
apache   13256  0.0  0.9 274536  9244 ?        R    02:50   0:00 /usr/sbin/httpd
apache   13260  0.1  0.9 274264  9768 ?        R    02:50   0:00 /usr/sbin/httpd
apache   13268  0.0  0.8 273756  8840 ?        S    02:51   0:00 /usr/sbin/httpd
apache   13272  0.0  0.9 274536  9256 ?        R    02:51   0:00 /usr/sbin/httpd
apache   13273  0.0  0.8 273492  8808 ?        S    02:51   0:00 /usr/sbin/httpd
apache   13275  0.0  0.9 274532  9556 ?        R    02:51   0:00 /usr/sbin/httpd
apache   13281  0.0  0.8 273880  8952 ?        S    02:51   0:00 /usr/sbin/httpd
apache   13284  0.0  0.8 273624  8956 ?        S    02:51   0:00 /usr/sbin/httpd
apache   13291  0.0  0.8 273748  8764 ?        R    02:51   0:00 /usr/sbin/httpd
apache   13301  0.0  0.8 273492  8780 ?        S    02:51   0:00 /usr/sbin/httpd
apache   13304  0.0  0.8 273880  9008 ?        R    02:51   0:00 /usr/sbin/httpd
apache   13310  0.0  0.8 273748  8796 ?        R    02:51   0:00 /usr/sbin/httpd
apache   13311  0.0  0.9 274272  9296 ?        R    02:51   0:00 /usr/sbin/httpd
apache   13312  0.0  0.9 274536  9272 ?        R    02:51   0:00 /usr/sbin/httpd
apache   13314  0.0  0.9 274544  9368 ?        S    02:51   0:00 /usr/sbin/httpd
apache   13318  0.0  0.8 273624  8808 ?        S    02:51   0:00 /usr/sbin/httpd
apache   13321  0.0  0.8 273880  8928 ?        R    02:51   0:00 /usr/sbin/httpd
apache   13323  0.0  0.8 273492  8808 ?        R    02:51   0:00 /usr/sbin/httpd
apache   13325  0.1  0.8 273748  8944 ?        S    02:51   0:00 /usr/sbin/httpd
apache   13327  0.0  0.8 273752  9000 ?        R    02:51   0:00 /usr/sbin/httpd
apache   13340  0.0  0.5 272440  5540 ?        R    02:51   0:00 /usr/sbin/httpd
apache   13345  0.0  0.8 273752  8828 ?        R    02:51   0:00 /usr/sbin/httpd
apache   13346  0.0  0.8 273756  9028 ?        R    02:51   0:00 /usr/sbin/httpd
apache   13347  0.0  0.8 273748  8924 ?        R    02:51   0:00 /usr/sbin/httpd
apache   13350  0.3  0.9 274540  9484 ?        R    02:51   0:00 /usr/sbin/httpd
apache   13352  0.0  0.8 273880  9108 ?        R    02:51   0:00 /usr/sbin/httpd
apache   13359  0.0  0.9 274020  9328 ?        S    02:51   0:00 /usr/sbin/httpd
apache   13361  0.0  0.8 273748  9084 ?        R    02:51   0:00 /usr/sbin/httpd
apache   13362  0.0  0.5 272440  5540 ?        R    02:52   0:00 /usr/sbin/httpd
apache   13363  0.1  0.8 273740  8760 ?        R    02:53   0:00 /usr/sbin/httpd
apache   13364  0.0  0.7 273340  7584 ?        S    02:53   0:00 /usr/sbin/httpd
apache   13366  0.0  0.8 273484  8580 ?        S    02:53   0:00 /usr/sbin/httpd
apache   13367  0.2  0.8 273616  8804 ?        S    02:53   0:00 /usr/sbin/httpd
apache   13368  0.1  0.8 273488  8572 ?        S    02:53   0:00 /usr/sbin/httpd
root     13370  0.0  0.0  85000   820 pts/0    R+   02:53   0:00 grep httpd
(BTW: is it right that there are that many httpd processes? I've another site running on the server)

Thus i should be able to create directories via php or not? Why do i get this error even though the permissions are set to 777?


best regards

Zabrajin
 
Old 11-24-2009, 03:48 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,978
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Hi, welcome to LQ!

Actually your snippet doesn't do anything for me;
with a <?php it creates the directory just fine.


Cheers,
Tink
 
Old 11-24-2009, 04:08 AM   #3
Zabrajin
LQ Newbie
 
Registered: Nov 2009
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Tinkster View Post
Hi, welcome to LQ!

Actually your snippet doesn't do anything for me;
with a <?php it creates the directory just fine.


Cheers,
Tink
Hm maybe you've disabled php short tags? I've tried it with <?php ?>, but no difference for me.
Still says permission denied
 
Old 11-24-2009, 04:19 AM   #4
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,230

Rep: Reputation: 132Reputation: 132
Quote:
<?
echo substr(decoct( fileperms('.') ), 2);
mkdir("/var/www/html/default/test");
?>
check who is owning this php script? if you want to create directory within /var/ww/html/default then this script should own by apache user.
 
Old 11-24-2009, 04:30 AM   #5
Zabrajin
LQ Newbie
 
Registered: Nov 2009
Posts: 8

Original Poster
Rep: Reputation: 0
The permission for the script is as follwing
Quote:
ls -rtl
-rw-r--r-- 1 apache apache 88 2009-11-24 04:25 test.php
Since the webserver is running as the user apache this should be ok i think
 
Old 11-24-2009, 04:33 AM   #6
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,230

Rep: Reputation: 132Reputation: 132
it doesn't have execute permission (use 755 thats enough)
 
Old 11-24-2009, 04:37 AM   #7
Zabrajin
LQ Newbie
 
Registered: Nov 2009
Posts: 8

Original Poster
Rep: Reputation: 0
Changed permission to 755 but still the same error...
 
Old 11-24-2009, 04:40 AM   #8
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,230

Rep: Reputation: 132Reputation: 132
is SELinux enabled?
 
Old 11-24-2009, 04:46 AM   #9
Zabrajin
LQ Newbie
 
Registered: Nov 2009
Posts: 8

Original Poster
Rep: Reputation: 0
i'm not sure but i don't think so. It's a VPS with a basic fc10 install. Can i check that somehow?

//edit: I've just run the script as root via the local php interpreter and then everything works fine. Anybody has a clue why it fails when i try it within the webserver?

Last edited by Zabrajin; 11-24-2009 at 07:15 AM.
 
Old 11-24-2009, 10:52 AM   #10
Web31337
Member
 
Registered: Sep 2009
Location: Russia
Distribution: Gentoo, LFS
Posts: 399
Blog Entries: 71

Rep: Reputation: 65
PHP safe mode is on?
this just looks extremely stupid to me: it must work under even 0700 with user "apache". copy your phpinfo() outputs.
--
upd: try to su to "apache" and cd to that directory then mkdir test there.

Last edited by Web31337; 11-24-2009 at 10:54 AM. Reason: su
 
Old 11-24-2009, 04:15 PM   #11
Zabrajin
LQ Newbie
 
Registered: Nov 2009
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Web31337 View Post
PHP safe mode is on?
this just looks extremely stupid to me: it must work under even 0700 with user "apache". copy your phpinfo() outputs.
--
upd: try to su to "apache" and cd to that directory then mkdir test there.
i can't su to apache...

Code:
su apache
This account is currently not available.
//edit... removed php info link xD

Last edited by Zabrajin; 11-25-2009 at 02:02 AM.
 
Old 11-24-2009, 04:21 PM   #12
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora, Lubuntu, FreeBSD
Posts: 3,930
Blog Entries: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by Zabrajin
i'm not sure but i don't think so. It's a VPS with a basic fc10 install. Can i check that somehow?
Code:
$ /usr/sbin/getenforce
 
Old 11-24-2009, 07:03 PM   #13
davidstvz
Member
 
Registered: Jun 2008
Posts: 405

Rep: Reputation: 30
Quote:
Originally Posted by Zabrajin View Post
i can't su to apache...

Code:
su apache
This account is currently not available.
And you can view the php info page here: http://199.187.126.22/phpinfo.php

If you look at the info in /etc/passwd (if you need to modify don't do it directly, use a program or at least vipw) you will see that the user apache may not have a shell, a home and/or a password which will prevent it from being used as a regular user. You could try to edit in a shell and use the passwd command to give a password and then try what Web suggested (back up your /etc/passwd and /etc/shadow files and restore them after you're done this test).
 
Old 11-24-2009, 09:14 PM   #14
Smartpatrol
Member
 
Registered: Sep 2009
Posts: 196

Rep: Reputation: 38
...

Last edited by Smartpatrol; 03-11-2010 at 09:50 PM. Reason: verbage
 
Old 11-24-2009, 09:33 PM   #15
w3bd3vil
Senior Member
 
Registered: Jun 2006
Location: Hyderabad, India
Distribution: Fedora
Posts: 1,189

Rep: Reputation: 49
You must have enabled SELinux, trying checking that first.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
can't execute c++ binaries, "permission denied"... even though permission is 777 SerfurJ Programming 14 02-20-2009 04:50 AM
BIND 9 Permission denied when chmod is 777 o_O KasperLotus Linux - Networking 10 09-07-2005 12:20 AM
BIND 9 Permission denied when chmod is 777 o_O KasperLotus Linux - Software 0 08-28-2005 11:42 PM
CHMOD in shell : chmod 777 /usr/ <---is that right? cpanelskindepot Programming 5 07-16-2004 05:37 AM
chmod : permission denied onebyone Linux - Software 4 01-27-2004 02:29 PM


All times are GMT -5. The time now is 04:04 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration