Apache user creates file in root account but not in other users
favorite
I have a p3.php file which if I execute from root user it creates a text file but if I execute from another user it doesn't create any text file. eg: I placed the p3.php in /var/www/html/p3.php and if I execute from "example.com/p3.php" it creates file without any issue. but if I place in /john/public_html/tmp/p3.php and execute from "example.com/~john/tmp/p3.php" it doesn't create any file. I gave all permissions to parent directory tmp and also executed the below commmand. sudo chown apache /home/john/public_html/tmp/ I found apache is the user in httpd.conf file. May I know what more I can do to create file in john account instead of root. Many Thanks. |
First try to create file in the /tmp directory,
Suppose your code in the file p3.php Code:
<?php Now path of the file is /home/john/public_html/p3.php Now you execute the file http://example.com/~john/p3.php and if it creates the file in /tmp directory of the server (not the /tmp directory of your public_html, the filesystem /tmp dir) It means the code is fine and it is able to create the file. To create the file in /home/john/public_html/tmp Change the owner of directory /path/to/john/public_html/tmp, it should be apache Quote:
Now execute the file, it should create the file in /path/to/john/public_html/tmp/myfile.txt if you have given the created file path in /home/john/public_html/tmp i.e. $ourFileName = "testFile.txt"; http://example.com/~john/tmp/p3.php |
You will have to show the php file. We can't tell anything about what it is/is not doing otherwise.
It would also help to know what distribution you are using. |
Also the Apache server should be ran as a deamon
as the user user=apache group=apache the user "apache" should not have a home folder and you really DO NOT!!! want to run the apache software as root -- nothing good will come of that -- |
...also if this:
Quote:
It's not the "right" way to accomplish things in a secure and safe way and it's not the "right" way to troubleshoot problems. |
All times are GMT -5. The time now is 10:29 AM. |