Sunday, January 16, 2011

Automatically Set Permissions : CentOS 5.3

Hi , I have just switched from shared hosting to a centOS VPS. I'm using my VPS to run a few blogs and Joomla websites. Whenever I try to install Joomla / Wordpress, I always have permission issues. There are always some files that can't be written to. As a solution, I have to chmod everything to 777 and then 755. Is there any way to automatically set correct permissions for these folders?

I never had any permission issues while using shared hosting. Any idea how they configure their servers?

Thanks in advance

  • What is your umask?

    From a shell prompt, do

    umask
    

    or

    umask -S
    

    If the result is "0022" that corresponds to "755" (7 - 2 = 5).

    Look in your /etc/profile or $HOME/.profile to see where it's being set and change it, probably to 002 (you can ignore the other leading zero).

    Edit: Rather than changing umask in your profile, It's probably better to do it at the command line only when needed (or in a script - when the script exits, it returns to your "default").

    warren : just be careful with this - so that you only make files you *NEED* to make writeable :)
    Dennis Williamson : @warren: **Very** important advice. I've edited my answer.
    warren : crud - my vote for your answer got dropped because i clicked the wrong spot :(
  • It's not automatic, but find out what user owns the process writing to those files, and change ownership to that user. Then you can restrict to 644.

    And stop putting execute permission on output files!

    From kmarsh
  • Use FileZilla FTP client and chmod all folders to 0755 and files to 0644. It allows recursive chmodding files and folders separately.

0 comments:

Post a Comment