0

I have a problem with nginx / php-fpm permissions.

I run a website in /var/www/clients/client1/web1/web, the owner:group of that folder and subfolders is web1:client1. When I try to create or upload a file with a PHP script in that folder i get a Permission Denied error because the new file get's created as www-data:www-data and it can't write to the folder (I have tested this by using the 777 permission).

How can I make it so nginx / php-fpm can write to those folders using web1:client1 and not www-data:www-data?

php-fpm pool file for that site:

[web1]

listen = /var/lib/php5-fpm/web1.sock  
listen.owner = web1  
listen.group = client1 
listen.mode = 0660

user = web1 
group = client1

pm = dynamic pm.max_children = 10 
pm.start_servers = 2 
pm.min_spare_servers = 1 
pm.max_spare_servers = 5 
pm.max_requests = 0

chdir = /

php_admin_value[open_basedir] = /var/www/clients/client1/web1/web:/var/www/clients/client1/web1/private:/var/www/clients/client1/web1/tmp:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin 
php_admin_value[session.save_path] = /var/www/clients/client1/web1/tmp
php_admin_value[upload_tmp_dir] = /var/www/clients/client1/web1/tmp
  • Have you tried searching? I don't use php-fpm and the first search I tried on google has quite a few number of links that answer your question. – yoonix Nov 4 '14 at 22:29
  • I did and they suggest having the user/group in php-fpm same as the user/group on the folder, witch I have. – Debrian Nov 4 '14 at 22:33
  • If you already have it done, then what's your question? – yoonix Nov 4 '14 at 22:35
  • As I said in the question, I have done it, but the new files get created under www-data:www-data and not web1:client1 as set in the config file. – Debrian Nov 4 '14 at 22:37
  • What does your nginx configuration look like? If you have it configured correctly where it is running as your defined user, it would be writing files as that user. – yoonix Nov 4 '14 at 22:41

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.