1

Since a while ago I decided to say goodbye to Windows and start my journey in Linux. So far everything has been great. but when it comes to the permissions I am a little overwhelmed.

I am running a LAMP Stack with multiple CraftCMS installations. Everything works fine, but I am unable to execute CraftCMS's command line tools. Because I do not have the required permissions.

I do however understand where this comes from. Let me explain my setup:

My document root is living in /home/mike/websites/ Due to the fact that I have my document root in my home folder and not in /var/www/ the user that runs apache doesn't have acces to my document root. I solved this by making the user www-data the owner of /home/mike/websites/. I did this by running sudo chown -R www-data /home/mike/websites/ The websites work fine at this point, but I don't have access myself. To fix this I added myself to the group www-data, with the command: sudo usermod -a -G www-data mike

This is the point where we are now. Almost everything works fine and I can acces everything as i should.

When trying to run ./craft in /home/mike/websites/websiteA/ I get an error : bash: ./craft: Permission denied If I run the command with sudo permissions sudo ./craft I get the error : sudo: ./craft: command not found The only way I can get it to work is by using sudo php ./craft. But that's a bit tedious.

I do however have an idea why: When I write a php command in the console it will be executed by my user. Which probably doesn't have Php permissions to this folder.

Now, How do I fix this? Or should I move my document root to /var/www/

What is the right way?

ls -l craft output: -rwxrwxr-x 1 www-data www-data 577 apr 30 11:02 craft

  • "Or should I move my document root to /var/www/" This. What you want is possible but a lot more config. Put it in /var/www/ with www-data as user and a group (www-data would be the default), add mike to that group. – Rinzwind Apr 30 at 13:47
  • What if I want my document root to be accessible easily? I love having all the websites in my /home/ folder. @Rinzwind – mike Apr 30 at 13:52
  • you can always symlink :) – Rinzwind Apr 30 at 13:56
  • Could you post "ls -l craft" output? – Lety Apr 30 at 14:00
  • @Lety Sure, updated my question. – mike Apr 30 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.