linux - Writing to a file in a directory that belongs to a different user using php -


i have server hosts several domains. 1 of domains, using php script want able append few lines .htaccess of other domains.

for example masterdomain.com want append lines .htaccess of otherdomain.com. php file in /home/masterdomain/www/ want append few lines .htaccess located @ /home/otherdomain/www.

to have written shell script, when run shell script root, works when running via php, exec('./write_htaccess.sh') it's not working, nothing happends. checked , there no errors returned.

i have tried chmod u+s on write_htaccess.sh try , make run root each time didn't work either, might have set s bit wrongly though.

how achieve this? have give php root priviledges, best way this?

php being run whichever user web server running under; i'm guessing when server mean web server. on red hat or fedora apache (unless you're using different web server), other flavors of linux might use www or other user. when run shell script php it's being executed user apache. user needs write permissions .htaccess file, or needs in group write access .htaccess file.

try changing .htaccess file's group ownership apache (or whatever) , making group writable. avoids mucking sudo or setuid bits. of course, means in group can modify .htaccess file.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -