This is a discussion on "PHP/Apache" within the PHP Forum section. This forum, and the thread "PHP/Apache are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
PHP/Apache
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
PHP/Apache
Hello all!
What I have is a problem with my apache server and I don't know how to deal with it... I have a PHP page that is supposed to create an empty file, using "system" command, then open it ("fopen") na dwrite some stuff in there... But, when I point to the reffering page, it says ... "Permission denied" and the file is not created.. Because I don't know much about servers, is there somewhere in my Linux filesystem that I should tell PHP to create the file where it will not have such restrictions? when you tell PHP to create a file, which 'user' does this? The Apache user? |
|
|
|
|||
|
Re: PHP/Apache
try writing the file to your home directory, the user you are logged in as. you should have sufficient permissions to write to that directory.
|
|
|||
|
Re: PHP/Apache
On most systems, the web server runs as a user called "apache" or "www" or "webuser" or something like that, and it's that user which would require permissions to create a file on your file system. That's a different user to one you're logged in as, and things are set up like this to ensure that one web site provider of a shared instance of httpd can't overwrite or delete all the files of another web site provider. So in other works, in my experience writing to your home directory will NOT work (certainly doesn't for my web sites!).
If you want to create files while you're running a PHP script, I would advise you to create a separate directory for them. Use the mkdir command. Then set write permissions on the directory for the apache user .... it's write permission on a directory that lets you create and delete files in it. Use the chmod command. Finally, no need to do a system call to create the file - if you fopen a file for write and it doesn't already exist, the very act of opening the file will create it if permissions allow. Should you be in doubt as to how your system is set up, test it out and see how it's set up - create a directory for test purposes and chmod 777 it. Write a few llines of php that fopen and write to a file in that directory. Look and see how it worked / what user name was used. And don't forget to take away public write access to the directory you just created if you don't need it long term! -- Graham |
![]() |
| Tags |
| phpapache |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| what does apache do? | jjgamepro17 | Hosting & Domains | 9 | Jun 26th, 2007 12:27 |
| addmodule in Apache | isca | PHP Forum | 2 | May 10th, 2007 20:19 |
| Apache FOP Border | davedran | Other Programming Languages | 0 | Dec 18th, 2006 15:28 |
| Apache | Alan | PHP Forum | 3 | Aug 4th, 2005 12:48 |
| Problems with Apache | benbacardi | PHP Forum | 3 | Jun 3rd, 2005 13:44 |