-5

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.

3
  • 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.
    – user9517
    Nov 16, 2013 at 19:14
  • 2
    possible duplicate of How can I fix permissions in CentOS `/var/www/html` directory? Nov 16, 2013 at 19:15
  • @JakeGloud Yes but this is some what different :) Nov 16, 2013 at 19:16

1 Answer 1

3

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
3
  • Can you please tell how to do it? Nov 16, 2013 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. Nov 16, 2013 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.. Nov 16, 2013 at 19:50

Not the answer you're looking for? Browse other questions tagged .