When I run my php file:
<?php
exec("touch file.txt");
?>
via the command line, it will create the file. When I run via a web browser, it will not write.
This would be writing to a non-root folder, too. What is wrong? Surely something to do with permissions, but I don't understand it.
exec() won't write via browser
Moderator: General Moderators
-
okherewego
- Forum Newbie
- Posts: 4
- Joined: Mon Sep 13, 2010 6:16 pm
Re: exec() won't write via browser
Are you running this on a linux server? the user that you are using on the command line (root?) probably has different permissions / group than the apache process that runs the script.
-
okherewego
- Forum Newbie
- Posts: 4
- Joined: Mon Sep 13, 2010 6:16 pm
Re: exec() won't write via browser
Yes, on a linux server.pytrin wrote:Are you running this on a linux server? the user that you are using on the command line (root?) probably has different permissions / group than the apache process that runs the script.
User on the command line is not root. As I say, it's writing to a non-root folder as well.
Re: exec() won't write via browser
root was just an example. In any case, it probably has different permissions than the apache process. chmod and chown the folder to allow access by the user/group that apache runs under
-
okherewego
- Forum Newbie
- Posts: 4
- Joined: Mon Sep 13, 2010 6:16 pm
Re: exec() won't write via browser
How do I know what user/group apache runs under? I tried changing permissions to my home user, but that didn't work.pytrin wrote:root was just an example. In any case, it probably has different permissions than the apache process. chmod and chown the folder to allow access by the user/group that apache runs under
Re: exec() won't write via browser
run 'top' in the command line. You can see both user and group there for each process (apache should be running as the httpd daemon). If you don't see one of those, click 'f' to add more columns into the view
-
okherewego
- Forum Newbie
- Posts: 4
- Joined: Mon Sep 13, 2010 6:16 pm
Re: exec() won't write via browser
I hate to be a pain, but I don't see any httpd process. I've tested and localhost is working... so.... uhhh. I'm on Ubuntu with apache2.pytrin wrote:run 'top' in the command line. You can see both user and group there for each process (apache should be running as the httpd daemon). If you don't see one of those, click 'f' to add more columns into the view
Edit: According to http://ubuntuforums.org/showthread.php?t=268262 ... the group is www-data.
I changed it, and it allows access. Thank you.
However, I need to do more than write a file. I need to use the ImageMagick command, import, to take a snapshot. And it doesn't work. Surely that would mean giving www-data access to a whole bunch of programs., including X? Would that be too complicated?