Linux – Write permissions on uploaded files – Linux, Apache, PHP

apache-2.2debianlinuxpermissionsPHP

I am working on a PHP script that transfers files using FTP functions. It has always worked on my production server (which is a hosting service). The development server I have just setup (I am a novice to servers) is Debian Lenny with Apache2, PHP5, and MySQL5.

The file transfer works correctly, but once the file has been written to the server, it has permissions of 600. This makes it impossible for me to view the file (JPEG) in the web browser, as permission is denied. I have scoured the internet and even broken my server installation and reinstalled it trying to figure this out (which has been fun, nonetheless!).

I know it is unwise to set 777 permissions on public accessible files, but even that will not solve the problem. The only thing that works is if I chmod 777 thefile.jpg after it has been transferred, which is not a working solution.

I tried changing the owner of my site files to www-data per this post, but that also does not work.

My user is mike, and it still does not work whether the owner of the files is mike or root.

Would somebody point me in the right direction? Thanks! And, of course, let me know if I can clarify anything.

Best Answer

this is more related to your ftp server configuration, and not so much to apache. which server are you using for ftp? i believe vsftpd is the default ftp server for Debian Lenny, the options you might need to look at in your vsftpd.conf file are: chown_upload_mode and file_open_mode

the default for chown_upload_mode is 0600 which makes me think that might be what you need to set, and then restart your FTPd and try again.