LAMP and file/directory permissions

I followed these instructions on this forum for installing LAMP and all seems to be working fine including MariaDB. I’m still pretty new to the Linux OS itself and unfamiliar with how file and directory permission are to be handled; and am using LAMP for local development only.

It appears that all files must be under /srv or srv/http which requires the sudo password every time a PHP script is edited, for example. I also need to work with SQLite and can’t create a database because of permissions.

Would you please tell me what I need to do to set up the permissions properly to work with LAMP or point me to information?

Thank you.

1 Like

There is myriad of wikis, articles, tutorials and whatnot on file permissions. You can start here: File permissions and attributes - ArchWiki

Why do you think they aren’t already? Your user has access to your $HOME only. And /srv, /srv/http, etc. is owned by root or httpd (apache) or whatever.

1 Like

Thanks for the link.

Why do you think they aren’t already?

Obviously I’m not claiming there is something wrong with LAMP itself. I am simply asking what needs to be changed in permissions to accomplish two things:

  1. Create and write to a SQLite databases in PHP scripts under the /srv directory while still requiring the sudo password in the CLI use of SQLite3 for that same directory.

  2. Edit files in a text editor (I’m using KATE) under the /srv directory without having to enter the password every time a file is saved; but only from within the editor itself while still requiring the password on that directory at the command line.

Perhaps the answers are contained within your link or the link leads to them.

I told you; you aren’t the owner of that directory or anything under. So either you have to change ownership of files or add write permission for ‘others’. Or add ACLs.

You either have permissions to write to a file (anywhere) or you don’t.

add your user to the http group

sudo gpasswd -a $USER http

You need to ensure group is set

sudo chgrp -R http /srv/http

Then ensure permissions

sudo chmod g+w -R /srv/http
1 Like

Thank you. I haven’t been on this forum for quite awhile and just saw this response.

I read that article linked above and recall doing something like this or at least trying to; but I don’t recall what I tried as being as easy as these three lines.

I’ll check what I did back then and try this out. Thanks again.