Forum Moderators: coopster
I can use the same module to mkdir in the /tmp directory without a problem and I can PHP command line mkdirs and file creation all day but not when I call the PHP script through a browser. Through a browser I get permission denied every time.
the file system permissions for /var/www/html/example/files are as follows (for testing I know this is bad):
drwxrwxrwx 40 apache apache 4096 Feb 1 15:06 files
the user/group portion of my HTTPD.conf are as follows:
User apache
Group apache
output from check.php is as follows:
examplesite System Checks
MySQL Available OK
MySQL Server Version
MySQL Database Connection Connected OK
MySQL Database Select Selected OK
Operating System Linux trippliteis2 2.6.9-1.667smp #1 SMP Tue Nov 2 14:59:52 EST 2004 i686
PHP Version 4.3.10 OK
Server API apache2handler
Web Server Apache/2.0.52 (Fedora)
User Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0
default locale C
session.auto_start 0 OK
session.save_handler files
session.save_path /var/lib/php/session OK
session.serialize_handler php
session.use_cookies 1 OK
session.use_trans_sid 0 OK
file_uploads 1 OK
/locales/en directory writable Warning: you will not be able to save translation files. Check the directory permissions.
/files directory writable Warning: you will not be able to upload files. Check the directory permissions.
/files/temp directory writable Warning: you will not be able to make PDF's. Check the directory permissions.
root_dir /var/www/html/example OK
All other aspects of the Apache/PHP server with the MySQL backend are functional from browsing to database entries. The only issue I have is with using the PHP under Apache to do the mkdir() and file functions. I can log into the Apache account and issue mkdir directives wihtout a problem it's only when the calls are made through Apache/PHP.
the PHP code is as follows:
<?php
mkdir("/tmp/testernew1", 0777); <==== works fine
?>
<?php
mkdir("/var/www/html/example/files/testernew1", 0777); <===== fails
?>
Any help would be appreciated.
[edited by: jatar_k at 8:51 pm (utc) on Feb. 10, 2005]
[edit reason] removed url [/edit]
Apache is running as a special user.
Normally, Apache and PHP is running under this.
But when you are using PHP from the commandline, yuo are executing the script as yourself - not as Apache. And then of course everything then just works. The reason it works with /tmp is that /tmp has setting that allows everybody to write to that folder
So, to fix this, you'll have to give Apache write access to the part of the server you want to modify with your PHP script. And you'll usually need to be root (or sudo) to be able to do this.
There are two ways to accomplish this:
1) assign the group to Apache and chmod g+w
2) make Apache part of the group and chmod g+w
Try a
ps -auxww ¦ grep httpd and see what the 'worker' httpd's are running as. I've enabled webdav on my machines for some directories, and that involves a lot of thinking about the permissions for files and directories in order for the users not to be able to destroy important parts of the server. And for me that's working perfectly.
I'ld still say that you are having permission problems. It's probably something completely simple and obvious - at least in hindsigt.
[root@theplace ~]# ps -auxww ¦ grep httpd
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.3/FAQ
root 5581 0.0 0.5 27240 13376? Ss Feb10 0:02 /usr/sbin/httpd
apache 5387 0.0 0.5 27240 13428? S 04:02 0:00 /usr/sbin/httpd
apache 5388 0.0 0.5 27240 13428? S 04:02 0:00 /usr/sbin/httpd
apache 5389 0.0 0.5 27240 13428? S 04:02 0:00 /usr/sbin/httpd
apache 5390 0.0 0.5 27240 13396? S 04:02 0:00 /usr/sbin/httpd
apache 5391 0.0 0.5 27240 13396? S 04:02 0:00 /usr/sbin/httpd
apache 5392 0.0 0.5 27240 13396? S 04:02 0:00 /usr/sbin/httpd
apache 5393 0.0 0.5 27240 13396? S 04:02 0:00 /usr/sbin/httpd
apache 5394 0.0 0.5 27240 13396? S 04:02 0:00 /usr/sbin/httpd
root 16556 0.0 0.0 5412 660 pts/1 S+ 18:15 0:00 grep httpd
The directory permissions:
[root@theplace html]# ls -l
total 104
drwxrwxrwx 14 apache apache 4096 Jul 21 2004 1.0.2
drwxrwxrwx 17 apache apache 4096 Jul 26 2004 beta
drwxrwxrwx 7 apache apache 4096 Jan 20 16:59 dba
drwxrwxrwx 2 apache apache 4096 Aug 3 2004 dev
drwxrwxrwx 15 apache apache 4096 Feb 3 11:50 dotproject
-rwxrwxrwx 1 apache apache 48 Jul 22 2004 index.php
drwxrwxrwx 8 apache apache 4096 Jul 28 2004 ipw
-rwxrwxrwx 1 apache apache 52 Jul 19 2004 phpinfo.php
drwxrwxrwx 7 apache apache 4096 Oct 21 15:10 phpldapadmin-0.9.4b
drwxrwxrwx 3 apache apache 4096 Jul 22 2004 phpmaker
drwxrwxrwx 4 apache apache 4096 Jul 26 2004 repgen
-rwxrwxrwx 1 apache apache 563 Feb 8 14:29 setperms.sh
drwxrwxrwx 5 apache apache 4096 Jul 26 2004 ta
[root@theplace html]#