S
S
Shurik2020-05-13 19:06:27
PHP
Shurik, 2020-05-13 19:06:27

How to correctly assign permissions to the www folder in apache?

Hello. I have an apache web server. Faced such a problem - when executing php scripts, it gave a fatal error. I don't remember it exactly, but there is something with the rights.
I changed the permissions on the www folder: chmod -777 -R /var/www - this helped, but only until I add a new php file, on which I also need to set the permissions with the command above, after which it will be processed by the server.
The question is how to make it so that you do not have to constantly run the command above for roboticity?
What I already tried to do:
- created a php group and set it as the owner of the www folder
- added the www-data user to the php group
It did not help. You still need to run the chmod -777 -R /var/www command after new php files appear in it.

Z.Y. I forgot to say that I am distributing rights 777 since the server is test and local and I didn’t particularly bother with security issues. But in general, if in a nutshell someone chews, as in Feng Shui, I will be grateful.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sanes, 2020-05-13
@Sanes

Use normal php mode. FasCGI/CGI/PHP-FPM.
Then there will be no problems with the rights. Because scripts will be run as a separate user.
By default, you now have Apache prefork + mod_php. This is the oldest and most miserable mode of operation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question