3

After reinstalling 15.1 I have a lot of problems with my permissions. I constantly have to adjust them manually. That means I'm doing it wrong.

Here is what I do:

I create a folder. The permissions are: Owner: Me, Group: Jos (I'm the only user). Both have create and delete files. With those settings Joomla doesn't remove the installation folder. After manually removing it I get the error message:

No configuration file found and no installation code available. Exiting...

Now I use the command:

sudo chown -R www-data:jos /var/www/html/my_site

Owner is now www-data (create and delete) Group is jos (create and delete). Installation works fine. Site works. But I can't do anything in it, as I am not the owner. www-data is, and I have only Access Files permission.

I am using Lamp.

How do I set it correctly?

Trevor Clarke
  • 892
  • 6
  • 18
Jos
  • 596

1 Answers1

2

Your web user should not have write permission on your content, so to fix this what you should do is add yourself to the www-data group and then flip your chown command:

sudo usermod -a -G www-data jos
sudo chown -R jos:www-data /var/www/html/my_site

Then set your permissions to 2755 (directories) and 644 (files) or if you're wanting to be extra secure (or paranoid) 2750 and 640 respectively:

find /var/www/html -type f -exec chmod 644 {} \;
find /var/www/html -type d -exec chmod 2755 {} \;

This will allow your user (jos) to have the write permissions on the content, and the www-data user to have the read permission that it needs. This is also a better security practice as prohibits the www-data user from modifying content thus limiting damage a potential attacker could do. One other thing to note here is that if joomla or some other program does need to modify content in the /var/www/html/my_site folder, I'd recommend manually adding the write permissions to those files/directories only.

chmod g+w /var/www/html/my_site/joomalwriteshere/

Since I noticed you mentioned joomla here's a link to the source about their recommended permissions: https://docs.joomla.org/Verifying_permissions

snorp
  • 480
  • Sorry. I followed all the steps given, no luck. Restarted Ubuntu, tried again. No go. Didn't work. – Jos Dec 30 '15 at 07:24
  • Owner now is: Me (jos), create and delete files. Group is www-data, access files. Enclosed file permissions are r&w for files and c&d for folders.

    Removing the installation folder was not automatic, I had to manually delete it.

    – Jos Dec 30 '15 at 07:26
  • a WP site in localhost now asks for FTP credentials, which it didn't before. – Jos Dec 30 '15 at 07:28
  • This sounds like it's app specific. So I get that you've using a LAMP setup but you're using JOOMLA and WP(wordpress) so the problem is that those programs may require special/specific permissions or when you install them you may need to be a specific user (like the www-data user instead of jos or using sudo). – snorp Dec 30 '15 at 14:43
  • Wordpress has a great article about permissions: https://codex.wordpress.org/Changing_File_Permissions – snorp Dec 30 '15 at 14:44