# Nginx + Php-fpm Ownership issue!

**URL:** <https://www.ruby-forum.com/t/nginx-php-fpm-ownership-issue/243751>\
**Category:** NGINX\
**Created:** [December 30, 2015, 8:47am UTC](https://www.ruby-forum.com/t/nginx-php-fpm-ownership-issue/243751 "2015-12-30T08:47:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [December 30, 2015, 8:47am UTC](https://www.ruby-forum.com/t/nginx-php-fpm-ownership-issue/243751/1 "2015-12-30T08:47:52Z")

</div>

Hi,

We’ve installed nginx + php-fpm on FreeBSD OS and both of them are  
listening on www user / group. Here is the config :

NGINX :

user www ;

PHP-FPM :

[www]  
listen = /var/run/www.socket  
user = www  
group = www  
listen.owner = www  
listen.group = www  
listen.allowed\_clients = 127.0.0.1

* * *

According to these configs, now any files / directory should be created  
with www:www permissions in webroot directory by nginx/php-fpm but thats  
not happening, new uploaded files via nginx are being uploading with  
root:www permissions due to which most of uploading is getting failed.  
Here  
is the permission failed on  
(/videos/files/logs/2015/12/30/full-145145901836a71.log) :

2015/12/30 12:03:49 [error] 976#0: \*1502344 FastCGI sent in stderr: “PHP  
message: PHP Warning:  
file\_put\_contents(/videos/files/logs/2015/12/30/full-145145901836a71.log):  
failed to open stream: Permission denied in /videos/functions.php on  
line  
759” while reading response header from upstream, client: 5.254.102.94,  
server: [cw005.videos.com](http://cw005.videos.com), request: “POST /actions/file\_uploader.php  
HTTP/1.1”, upstream: “fastcgi://unix:/var/run/www.socket:”, host: "  
[cw005.videos.com](http://cw005.videos.com)", referrer: “[http://domain.com/upload](http://domain.com/upload)”

* * *

Now if i check the ownership of newly created  
“/videos/files/logs/2015/12/30/” by webserver, it is as follows :

root:www /videos/files/logs/2015/12/30/

It should had been www:www. Where we doing wrong ?

Please help.

Regards.  
Shahzaib

---

<div class="post-metadata">

**Author:** ![shahzaib12](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90db22/32.png) [@shahzaib12](https://www.ruby-forum.com/u/shahzaib12)\
**Post date:** [December 30, 2015, 9:00am UTC](https://www.ruby-forum.com/t/nginx-php-fpm-ownership-issue/243751/2 "2015-12-30T09:00:09Z")

</div>

Hi,

> listen.allowed\_clients = 127.0.0.1

I think you have mistake in the owner ownership.  
Below my config for nginx + php-fpm bundle..

;;;;;;;;;;;;;;;;;;;;;;;; MY pool for Joomla CMS ;;;;;;;;;;

[joomla1]

user = www-joomla1  
group = www-joomla1  
listen = /var/run/php-fpm-joomla1.sock

listen.owner = www-joomla1  
listen.group = www  
listen.mode = 0660

---

<div class="post-metadata">

**Author:** ![shahzaib12](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90db22/32.png) [@shahzaib12](https://www.ruby-forum.com/u/shahzaib12)\
**Post date:** [December 30, 2015, 9:37am UTC](https://www.ruby-forum.com/t/nginx-php-fpm-ownership-issue/243751/3 "2015-12-30T09:37:32Z")

</div>

Thanks for reply. However, our developer just notified us that the  
directory with root owner was created by a cron which ran by user root  
and  
created that issue though I’ve slightly modified nginx user directive  
with  
following :

former  
user www ;

later  
user www www;

Regards.  
Shahzaib
