B
B
Benjamin2014-08-01 09:02:10
PHP
Benjamin, 2014-08-01 09:02:10

Why are file permissions reset after configuring nginx+apache+php-fpm after rebooting debian7.0?

I configure nginx through sockets.
Example from /etc/nginx/sites-available/site1.com.conf

...
location @sside {
      root /web/site1.com;
      fastcgi_pass unix:/etc/nginx/socket/site1.com.socket;
      fastcgi_index index.php;
      include /etc/nginx/fastcgi_params;
      fastcgi_param SCRIPT_FILENAME   $document_root$fastcgi_script_name;
}

Example from /etc/php5/fpm/pool.d/site1.com.conf
[site1.com]

listen = /etc/nginx/socket/site1.com.socket
listen.backlog = -1

; Unix user/group of processes
user = user_site1
group = web_group

I create a file /etc/nginx/socket/site1.com.socket with permissions
srw-rw---- 1 root root 0 Jul 31 13:30 site1.com.socket

With such rights on site1.com.socket, nginx issues 502 and writes
2014/07/31 13:14:26 [crit] 2413#0: *1 connect() to unix:/etc/nginx/socket/site1.com.socket failed (13: Permission denied) while connecting to upstream

I put permissions on /etc/nginx/socket/site1.com.socket
chmod 777 /etc/nginx/socket/site1.com.socket
chown user_site1:web_group /etc/nginx/socket/site1.com.socket

ls -l /etc/nginx/socket

srwxrwxrwx 1 user_site1 web_group 0 Jul 31 13:30 site1.com.socket

After setting the rights everything works as it should.
Next, I do a reboot and the actual rights to the /etc/nginx/socket/site1.com.socket file are returned to root
srw-rw---- 1 root root 0 Jul 31 13:30 site1.com.socket

Actually the question is - Where to look and pick to solve the problem - so that the rights are not reset after reboot?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lynn "Coffee Man", 2014-08-01
@Itspacedev

The phrase “I create the file /etc/nginx/socket/site1.com.socket” scares me
. PHP-FPM should create it. And in order for him to have the necessary rights, you need to specify something like this in the settings

listen.owner = www-data
listen.group = www-data
listen.mode = 0600

Well, on the subject of the question, the socket is not stored in the file system, and after reboot it is restored by PHP-FPM. Since you don't have any settings, it is recreated with default settings.

B
Benjamin, 2014-08-01
@Itspacedev

Thanks, to the point.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question