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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
|
11-24-2009, 03:35 AM
|
#1
|
LQ Newbie
Registered: Nov 2009
Posts: 8
Rep:
|
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(decoct( fileperms('.') ), 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
|
|
|
11-24-2009, 04:48 AM
|
#2
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
Hi, welcome to LQ!
Actually your snippet doesn't do anything for me;
with a <?php it creates the directory just fine.
Cheers,
Tink
|
|
|
11-24-2009, 05:08 AM
|
#3
|
LQ Newbie
Registered: Nov 2009
Posts: 8
Original Poster
Rep:
|
Quote:
Originally Posted by Tinkster
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
|
|
|
11-24-2009, 05:19 AM
|
#4
|
Senior Member
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,278
Rep:
|
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.
|
|
|
11-24-2009, 05:30 AM
|
#5
|
LQ Newbie
Registered: Nov 2009
Posts: 8
Original Poster
Rep:
|
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
|
|
|
11-24-2009, 05:33 AM
|
#6
|
Senior Member
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,278
Rep:
|
it doesn't have execute permission (use 755 thats enough)
|
|
|
11-24-2009, 05:37 AM
|
#7
|
LQ Newbie
Registered: Nov 2009
Posts: 8
Original Poster
Rep:
|
Changed permission to 755 but still the same error...
|
|
|
11-24-2009, 05:40 AM
|
#8
|
Senior Member
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,278
Rep:
|
is SELinux enabled?
|
|
|
11-24-2009, 05:46 AM
|
#9
|
LQ Newbie
Registered: Nov 2009
Posts: 8
Original Poster
Rep:
|
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 08:15 AM.
|
|
|
11-24-2009, 11:52 AM
|
#10
|
Member
Registered: Sep 2009
Location: Russia
Distribution: Gentoo, LFS
Posts: 399
Rep:
|
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 11:54 AM.
Reason: su
|
|
|
11-24-2009, 05:15 PM
|
#11
|
LQ Newbie
Registered: Nov 2009
Posts: 8
Original Poster
Rep:
|
Quote:
Originally Posted by Web31337
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 03:02 AM.
|
|
|
11-24-2009, 05:21 PM
|
#12
|
Senior Member
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Rep:
|
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
|
|
|
11-24-2009, 08:03 PM
|
#13
|
Member
Registered: Jun 2008
Posts: 405
Rep:
|
Quote:
Originally Posted by Zabrajin
|
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).
|
|
|
11-24-2009, 10:14 PM
|
#14
|
Member
Registered: Sep 2009
Posts: 196
Rep:
|
...
Last edited by Smartpatrol; 03-11-2010 at 10:50 PM.
Reason: verbage
|
|
|
11-24-2009, 10:33 PM
|
#15
|
Senior Member
Registered: Jun 2006
Location: Hyderabad, India
Distribution: Fedora
Posts: 1,191
Rep:
|
You must have enabled SELinux, trying checking that first.
|
|
|
All times are GMT -5. The time now is 03:58 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|