<p>Sorry for the basic question - I'm a .NET developer and don't have much experience with LAMP setups.</p>

<p>I have a PHP site that will allow uploads to a specific folder. I have been told that this folder needs to be owned by the webserver user for the upload process to work, so I created the folder and then set permissions as such:</p>

<pre><code>chown apache:apache -R uploads/
chmod 755 -R uploads/
</code></pre>

<p>The only problem now is that the FTP user can not modify the uploaded files at all.</p>

<p>Is there a permission setting that will allow me to still upload files and then modify them later as a user other than the webserver user?</p>

[{'answer_id': 11005, 'author': 'Ryan Ahearn', 'author_id': 75, 'author_profile': 'https://Stackoverflow.com/users/75', 'pm_score': 7, 'selected': True, 'text': '<p>You can create a new group with both the apache user and FTP user as members and then make the permission on the upload folder 775.  This should give both the apache and FTP users the ability to write to the files in the folder but keep everyone else from modifying them.</p>\n'}, {'answer_id': 11025, 'author': 'palehorse', 'author_id': 312, 'author_profile': 'https://Stackoverflow.com/users/312', 'pm_score': 1, 'selected': False, 'text': '<p>I will add that if you are using SELinux that you need to make sure the type context is tmp_t  You can accomplish this by using the chcon utility</p>\n\n<blockquote>\n  <p>chcon -t tmp_t uploads</p>\n</blockquote>\n'}, {'answer_id': 11029, 'author': 'Max', 'author_id': 1309, 'author_profile': 'https://Stackoverflow.com/users/1309', 'pm_score': 4, 'selected': False, 'text': '<p>I would go with Ryan\'s answer if you really want to do this.</p>\n\n<p>In general on a *nix environment, you always want to err on giving away as little permissions as possible.</p>\n\n<p>9 times out of 10, 755 is the ideal permission for this - as the only user with the ability to modify the files will be the webserver. Change this to 775 with your ftp user in a group if you REALLY need to change this.</p>\n\n<p>Since you\'re new to php by your own admission, here\'s a helpful link for improving the security of your upload service:\n<a href="http://www.php.net/move_uploaded_file" rel="noreferrer"><code>move_uploaded_file</code></a></p>\n'}, {'answer_id': 9460755, 'author': 'M. Ahmad Zafar', 'author_id': 462732, 'author_profile': 'https://Stackoverflow.com/users/462732', 'pm_score': 1, 'selected': False, 'text': '<p>What is important is that the <code>apache</code> user and group should have minimum <code>read</code> access and in some cases <code>execute</code> access. For the rest you can give <code>0</code> access.</p>\n\n<p>This is the most safe setting.</p>\n'}, {'answer_id': 24689360, 'author': 'CesareoAguirre', 'author_id': 960117, 'author_profile': 'https://Stackoverflow.com/users/960117', 'pm_score': 0, 'selected': False, 'text': '<p>Remember also <code>CHOWN</code> or <code>chgrp</code> your website folder. Try  <code>myusername# chown -R myusername:_www uploads</code></p>\n'}, {'answer_id': 35366052, 'author': 'Lazarus Rising', 'author_id': 4299423, 'author_profile': 'https://Stackoverflow.com/users/4299423', 'pm_score': 2, 'selected': False, 'text': "<p>I would support the idea of creating a ftp group that will have the rights to upload. However, i don't think it is necessary to give 775 permission. 7 stands for read, write, execute. Normally you want to allow certain groups to read and write, but depending on the case, execute may not be necessary. </p>\n"}, {'answer_id': 44402979, 'author': 'Eric', 'author_id': 1568658, 'author_profile': 'https://Stackoverflow.com/users/1568658', 'pm_score': -1, 'selected': False, 'text': '<p>Based on the answer from <code>@Ryan Ahearn</code>, following is what I did on <code>Ubuntu</code> 16.04 to create a user <code>front</code> that only has permission for nginx\'s web dir <code>/var/www/html</code>.</p>\n\n<p><strong>Steps:</strong></p>\n\n<pre>\n* pre-steps:\n    * basic prepare of server,\n    * create user \'dev\'\n        which will be the owner of "/var/www/html",\n    * \n    * install nginx,\n    * \n* \n* create user \'front\'\n    sudo useradd -d /home/front -s /bin/bash front\n    sudo passwd front\n\n    # create home folder, if not exists yet,\n    sudo mkdir /home/front\n    # set owner of new home folder,\n    sudo chown -R front:front /home/front\n\n    # switch to user,\n    su - front\n\n    # copy .bashrc, if not exists yet,\n    cp /etc/skel/.bashrc ~front/\n    cp /etc/skel/.profile ~front/\n\n    # enable color,\n    vi ~front/.bashrc\n    # uncomment the line start with "force_color_prompt",\n\n    # exit user\n    exit\n* \n* add to group \'dev\',\n    sudo usermod -a -G dev front\n* change owner of web dir,\n    sudo chown -R dev:dev /var/www\n* change permission of web dir,\n    chmod 775 $(find /var/www/html -type d)\n    chmod 664 $(find /var/www/html -type f)\n* \n* re-login as \'front\'\n    to make group take effect,\n* \n* test\n* \n* ok\n* \n\n</pre>\n'}, {'answer_id': 73532081, 'author': 'Julio Vinachi', 'author_id': 4929137, 'author_profile': 'https://Stackoverflow.com/users/4929137', 'pm_score': 1, 'selected': False, 'text': '<pre><code>chmod -R 775 uploads/\nchown -R www-data uploads/\n</code></pre>\n<p>Important add to group public for web users standars in ubuntu <code>www-data</code></p>\n'}]
['https://Stackoverflow.com/questions/10990', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1153/']