Permissions for PHP for writing files

Hello,

One of the most provoking disadvantages of running PHP as nobody is the presence of limited permissions for writing and uploading files. Since PHP runs as 'nobody' on my virtual server, I must enable PHP to write files. In consequence, files must, as far as I know, include the presence of the unreasonably insecure 777 permissions for PHP to write files. An alternative is using PHP as CGI mode, such as using PHPsuexec or suPHP. Using PHP as CGI mode might give you the solution, but due to starting the PHP module on every page request, it would be a massive performance hit. Without using PHP as CGI mode, "CHMODing", "CHGRPing", or "CHOWNing", how can I let PHP write files? Although "CHMODing", "CHGRPing", or "CHOWNing", the files will work, but when it comes to uploading new and updated PHP files through FTP, these files have to repetitively change their permissions. However, when I was using shared hosting, PHP files can directly write any file without changing anything after uploading through FTP. Is there any solution for PHP to upload (.png, .jpg, .svg, .swf files) and write text files (generated by PHP) instead of running PHP as CGI mode, "CHMODing", "CHGRPing", or "CHOWNing" the files? Is it even possible?

All suggestions are severely appreciated.

Thank you very much.

 

 

 

 

Top