Permission on OpenLiteSpeed Server localhost with Magento 2
-
12-04-2021 - |
Question
I'm using CentOS 8 as my OS on my laptop and currently running OpenLiteServer (lsphp73) and have been successfully installed phpmyadmin and magento 2.3.4. Then, it comes with a problem that everytime I want to run something related to cache it always said:
Permission denied / Operation not permitted because /var/cache owned by nobody:nobody always has 775 file permission.
I have to chown first with my username and do some bin/magento command then change it back to nobody:nobody to make it run on localhost subfolder and show in the browser.
It's not a big problem but quite irritated by this. I'm quite new with CentOS 8 anyway and trying to learn a bit deeper in Magento. Has anyone facing the same issue?
Solution
this is not about operating system, this is only permissions.
if your webserver/php user is nobody, then you better run all commands as nobody.
https://linux.die.net/man/8/sudo
su -c "Your command right here" -s /bin/bash nobody
sudo su -c "Your command right here" -s /bin/bash nobody
su nobody -s /bin/bash -c "Your command right here" -s /bin/bash
sudo su nobody -s /bin/bash -c "Your command right here"
or you go into nobody environment:
su - nobody -s /bin/bash