I was not able to upload files on my site (cent OS 6 VPS). The path where web files should be uploaded is /var/www/html.

The permissions of directories were 755 and of files were 644.

But when I chmoded all files and directories in /var/www to 777 recursively then I was able to upload to /var/www/html

I am running WordPress. Isn't it a security issue to chmod all files and folders to 777? Also, if I chmod them back to 755, I cannot upload any files.

closed as off-topic by Iain, phoebus, colealtdelete, voretaq7 Nov 17 '13 at 3:20

This question appears to be off-topic. The users who voted to close gave these specific reasons:

  • "Questions must be relevant to professional system administration. Server Fault is dedicated to professional system and network administrators. End user and enthusiast questions are off-topic (contact your system administrator or hire a professional to help you out). Please see the Help Center for more information." – phoebus, voretaq7
  • "Questions must demonstrate a minimal understanding of the problem being solved. Try including attempted solutions, why they didn't work, and the expected results. See How can I ask better questions on Server Fault? for further guidance." – Iain, colealtdelete
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    You need to speak to your management and get them to provide some education on the tools that you are using. This is incredibly basic stuff that any professional at any level should know or be able to find out easily. – Iain Nov 16 '13 at 19:14
  • 2
    possible duplicate of How can I fix permissions in CentOS `/var/www/html` directory? – JakeGould Nov 16 '13 at 19:15
  • @JakeGloud Yes but this is some what different :) – user2997640 Nov 16 '13 at 19:16

You should never set files & folders to 777 permissions which basically means 100% of anyone with access to your server—or even via WordPress—can read, write & execute scripts.

The reason you are running into this issue is that the user ownership of the WordPress directory does not match the user that is running Apache. Of the Apache user does not own the files in a web root, it will not be able to write or execute.

So the solution is to figure out who the Apache web user is on your setup, and then set the WordPress install to be owned by that Apache web user.

To find out who is the Apache web user run this command look in the Apache environment variables file and find the User and Group. In Ubuntu it is located here:

nano /etc/apache2/envvars

And it is the line:

export APACHE_RUN_USER=www-data

Under CentOS it seems like it will be here, but I have not touched CentOS in years:

nano /etc/sysconfig/httpd
  • Can you please tell how to do it? – user2997640 Nov 16 '13 at 19:15
  • 3
    Seems like you are in over your head. Assuming good faith, I added some details. But you might want to get some help from your ISP's tech support. Also, SPAMming questions will not get you answers & will get you banned. – JakeGould Nov 16 '13 at 19:22
  • I used sudo chown -R apache /var/www/html/ and changed permissions back to 755 dirs and 644 (files), still I cant upload.. – user2997640 Nov 16 '13 at 19:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.