PHP FPM gives permission denied?nginx + PHP-FPM = “permission denied” error 13 in nginx log;...

How do I reattach a shelf to the wall when it ripped out of the wall?

My bank got bought out, am I now going to have to start filing tax returns in a different state?

std::unique_ptr of base class holding reference of derived class does not show warning in gcc compiler while naked pointer shows it. Why?

Older movie/show about humans on derelict alien warship which refuels by passing through a star

How exactly does Hawking radiation decrease the mass of black holes?

How bug prioritization works in agile projects vs non agile

Unknown code in script

What is the most expensive material in the world that could be used to create Pun-Pun's lute?

What *exactly* is electrical current, voltage, and resistance?

My admission is revoked after accepting the admission offer

A Paper Record is What I Hamper

Co-worker works way more than he should

Israeli soda type drink

Is there metaphorical meaning of "aus der Haft entlassen"?

What is the term for a person whose job is to place products on shelves in stores?

What is the unit of time_lock_delta in LND?

Injection into a proper class and choice without regularity

Drawing a german abacus as in the books of Adam Ries

Multiple fireplaces in an apartment building?

As an international instructor, should I openly talk about my accent?

Combinatorics problem, right solution?

A ​Note ​on ​N!

How do I deal with a coworker that keeps asking to make small superficial changes to a report, and it is seriously triggering my anxiety?

Island of Knights, Knaves and Spies



PHP FPM gives permission denied?


nginx + PHP-FPM = “permission denied” error 13 in nginx log; configuration mistake?Blank Page: wordpress on nginx+php-fpmPHP-FPM issue on LEMP Stack and WordPressphpmyadmin having problems on nginx and php-fpm on RHEL 6PHP-FPM/nginx-SELinux: No input file specifiedNGINX don't parse .php5 as .phpNginx PHP-fpm permissionnginx and php-fpm “Primary script unknown”nginx PHP files downloading instead of executingFastCGI: Access deniedWordpress overloads LEMP






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







8















I read several entries on why PHP-FPM might give me permission denied but I can not solve it.



The error logs read like:



    2013/04/20 23:33:28 [crit] 15479#0: *6 open() "/var/lib/nginx/tmp/fastcgi
/2/00/0000000002" failed (13: Permission denied) while reading upstream, client:
99.999.999.999, server: example.net, request: "GET /wp-admin/ HTTP/1.1",
upstream: "fastcgi://unix:/tmp/php-fpm.sock:", host: "example.net", referrer:
"http://example.net/"


Im a little but lost:




  1. I have set the /var/lib/nginx/tmp to ec2-user (i even +777 everything to check)

  2. I have set the /tmp/php-fpm.sock to ec2-user

  3. the nginx conf file is set to ec2-user

  4. the php-conf is set to user and group ec2-user

  5. ps aux gives ec2-user on all php-fpm and nginx processes


My Nginx Configuration includes a lot of files , the basic conf is:



user              ec2-user ec2-user;
worker_processes 5;
error_log /opt/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /opt/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
client_max_body_size 13m;
index index.php index.html index.htm;
upstream php {
server unix:/tmp/php-fpm.sock;
}
include /etc/nginx/conf.d/*.conf;
include /mnt/web/nginx/conf.d/*.conf;
}


my /etc/nginx/conf.d/ is empty
my /mnt/web/nginx/conf.d contain A LOT of website configurations which all include "wordpress.conf":



location / {
try_files $uri $uri/ /index.php?$args;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
expires 24h;
log_not_found off;
}
location ~ .php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php;
}


My /opt/php/etc/php-fpm.conf:



include=/opt/php/etc/fpm.d/*.conf
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = notice
[www]
listen = /tmp/php-fpm.sock
user = ec2-user
group = ec2-user
pm = dynamic
pm.max_children = 250
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
pm.status_path = /fpm-status
ping.path = /fpm-ping
slowlog = log/$pool.log.slow
catch_workers_output = yes


UPDATE: found the problem, put it in the answer










share|improve this question




















  • 1





    is selinux enabled ? run getenforce or cat /selinux/enforce if is not 0 is enabled

    – silviud
    Apr 20 '13 at 23:48






  • 1





    What's the rest of your nginx configuration?

    – Michael Hampton
    Apr 20 '13 at 23:51






  • 1





    your socket from log file is /tmp/php-fpm.sock but you changed /var/lib/nginx/tmp - did you do chroot in nginx ?

    – silviud
    Apr 20 '13 at 23:51






  • 1





    send the output from the command mount

    – silviud
    Apr 21 '13 at 0:12






  • 1





    also look that all directories in your home ... see serverfault.com/questions/170192/…

    – silviud
    Apr 21 '13 at 0:50


















8















I read several entries on why PHP-FPM might give me permission denied but I can not solve it.



The error logs read like:



    2013/04/20 23:33:28 [crit] 15479#0: *6 open() "/var/lib/nginx/tmp/fastcgi
/2/00/0000000002" failed (13: Permission denied) while reading upstream, client:
99.999.999.999, server: example.net, request: "GET /wp-admin/ HTTP/1.1",
upstream: "fastcgi://unix:/tmp/php-fpm.sock:", host: "example.net", referrer:
"http://example.net/"


Im a little but lost:




  1. I have set the /var/lib/nginx/tmp to ec2-user (i even +777 everything to check)

  2. I have set the /tmp/php-fpm.sock to ec2-user

  3. the nginx conf file is set to ec2-user

  4. the php-conf is set to user and group ec2-user

  5. ps aux gives ec2-user on all php-fpm and nginx processes


My Nginx Configuration includes a lot of files , the basic conf is:



user              ec2-user ec2-user;
worker_processes 5;
error_log /opt/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /opt/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
client_max_body_size 13m;
index index.php index.html index.htm;
upstream php {
server unix:/tmp/php-fpm.sock;
}
include /etc/nginx/conf.d/*.conf;
include /mnt/web/nginx/conf.d/*.conf;
}


my /etc/nginx/conf.d/ is empty
my /mnt/web/nginx/conf.d contain A LOT of website configurations which all include "wordpress.conf":



location / {
try_files $uri $uri/ /index.php?$args;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
expires 24h;
log_not_found off;
}
location ~ .php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php;
}


My /opt/php/etc/php-fpm.conf:



include=/opt/php/etc/fpm.d/*.conf
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = notice
[www]
listen = /tmp/php-fpm.sock
user = ec2-user
group = ec2-user
pm = dynamic
pm.max_children = 250
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
pm.status_path = /fpm-status
ping.path = /fpm-ping
slowlog = log/$pool.log.slow
catch_workers_output = yes


UPDATE: found the problem, put it in the answer










share|improve this question




















  • 1





    is selinux enabled ? run getenforce or cat /selinux/enforce if is not 0 is enabled

    – silviud
    Apr 20 '13 at 23:48






  • 1





    What's the rest of your nginx configuration?

    – Michael Hampton
    Apr 20 '13 at 23:51






  • 1





    your socket from log file is /tmp/php-fpm.sock but you changed /var/lib/nginx/tmp - did you do chroot in nginx ?

    – silviud
    Apr 20 '13 at 23:51






  • 1





    send the output from the command mount

    – silviud
    Apr 21 '13 at 0:12






  • 1





    also look that all directories in your home ... see serverfault.com/questions/170192/…

    – silviud
    Apr 21 '13 at 0:50














8












8








8


5






I read several entries on why PHP-FPM might give me permission denied but I can not solve it.



The error logs read like:



    2013/04/20 23:33:28 [crit] 15479#0: *6 open() "/var/lib/nginx/tmp/fastcgi
/2/00/0000000002" failed (13: Permission denied) while reading upstream, client:
99.999.999.999, server: example.net, request: "GET /wp-admin/ HTTP/1.1",
upstream: "fastcgi://unix:/tmp/php-fpm.sock:", host: "example.net", referrer:
"http://example.net/"


Im a little but lost:




  1. I have set the /var/lib/nginx/tmp to ec2-user (i even +777 everything to check)

  2. I have set the /tmp/php-fpm.sock to ec2-user

  3. the nginx conf file is set to ec2-user

  4. the php-conf is set to user and group ec2-user

  5. ps aux gives ec2-user on all php-fpm and nginx processes


My Nginx Configuration includes a lot of files , the basic conf is:



user              ec2-user ec2-user;
worker_processes 5;
error_log /opt/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /opt/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
client_max_body_size 13m;
index index.php index.html index.htm;
upstream php {
server unix:/tmp/php-fpm.sock;
}
include /etc/nginx/conf.d/*.conf;
include /mnt/web/nginx/conf.d/*.conf;
}


my /etc/nginx/conf.d/ is empty
my /mnt/web/nginx/conf.d contain A LOT of website configurations which all include "wordpress.conf":



location / {
try_files $uri $uri/ /index.php?$args;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
expires 24h;
log_not_found off;
}
location ~ .php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php;
}


My /opt/php/etc/php-fpm.conf:



include=/opt/php/etc/fpm.d/*.conf
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = notice
[www]
listen = /tmp/php-fpm.sock
user = ec2-user
group = ec2-user
pm = dynamic
pm.max_children = 250
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
pm.status_path = /fpm-status
ping.path = /fpm-ping
slowlog = log/$pool.log.slow
catch_workers_output = yes


UPDATE: found the problem, put it in the answer










share|improve this question
















I read several entries on why PHP-FPM might give me permission denied but I can not solve it.



The error logs read like:



    2013/04/20 23:33:28 [crit] 15479#0: *6 open() "/var/lib/nginx/tmp/fastcgi
/2/00/0000000002" failed (13: Permission denied) while reading upstream, client:
99.999.999.999, server: example.net, request: "GET /wp-admin/ HTTP/1.1",
upstream: "fastcgi://unix:/tmp/php-fpm.sock:", host: "example.net", referrer:
"http://example.net/"


Im a little but lost:




  1. I have set the /var/lib/nginx/tmp to ec2-user (i even +777 everything to check)

  2. I have set the /tmp/php-fpm.sock to ec2-user

  3. the nginx conf file is set to ec2-user

  4. the php-conf is set to user and group ec2-user

  5. ps aux gives ec2-user on all php-fpm and nginx processes


My Nginx Configuration includes a lot of files , the basic conf is:



user              ec2-user ec2-user;
worker_processes 5;
error_log /opt/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /opt/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
client_max_body_size 13m;
index index.php index.html index.htm;
upstream php {
server unix:/tmp/php-fpm.sock;
}
include /etc/nginx/conf.d/*.conf;
include /mnt/web/nginx/conf.d/*.conf;
}


my /etc/nginx/conf.d/ is empty
my /mnt/web/nginx/conf.d contain A LOT of website configurations which all include "wordpress.conf":



location / {
try_files $uri $uri/ /index.php?$args;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
expires 24h;
log_not_found off;
}
location ~ .php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php;
}


My /opt/php/etc/php-fpm.conf:



include=/opt/php/etc/fpm.d/*.conf
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = notice
[www]
listen = /tmp/php-fpm.sock
user = ec2-user
group = ec2-user
pm = dynamic
pm.max_children = 250
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
pm.status_path = /fpm-status
ping.path = /fpm-ping
slowlog = log/$pool.log.slow
catch_workers_output = yes


UPDATE: found the problem, put it in the answer







nginx amazon-ec2 php-fpm






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 21 '13 at 1:23







edelwater

















asked Apr 20 '13 at 23:43









edelwateredelwater

3121311




3121311








  • 1





    is selinux enabled ? run getenforce or cat /selinux/enforce if is not 0 is enabled

    – silviud
    Apr 20 '13 at 23:48






  • 1





    What's the rest of your nginx configuration?

    – Michael Hampton
    Apr 20 '13 at 23:51






  • 1





    your socket from log file is /tmp/php-fpm.sock but you changed /var/lib/nginx/tmp - did you do chroot in nginx ?

    – silviud
    Apr 20 '13 at 23:51






  • 1





    send the output from the command mount

    – silviud
    Apr 21 '13 at 0:12






  • 1





    also look that all directories in your home ... see serverfault.com/questions/170192/…

    – silviud
    Apr 21 '13 at 0:50














  • 1





    is selinux enabled ? run getenforce or cat /selinux/enforce if is not 0 is enabled

    – silviud
    Apr 20 '13 at 23:48






  • 1





    What's the rest of your nginx configuration?

    – Michael Hampton
    Apr 20 '13 at 23:51






  • 1





    your socket from log file is /tmp/php-fpm.sock but you changed /var/lib/nginx/tmp - did you do chroot in nginx ?

    – silviud
    Apr 20 '13 at 23:51






  • 1





    send the output from the command mount

    – silviud
    Apr 21 '13 at 0:12






  • 1





    also look that all directories in your home ... see serverfault.com/questions/170192/…

    – silviud
    Apr 21 '13 at 0:50








1




1





is selinux enabled ? run getenforce or cat /selinux/enforce if is not 0 is enabled

– silviud
Apr 20 '13 at 23:48





is selinux enabled ? run getenforce or cat /selinux/enforce if is not 0 is enabled

– silviud
Apr 20 '13 at 23:48




1




1





What's the rest of your nginx configuration?

– Michael Hampton
Apr 20 '13 at 23:51





What's the rest of your nginx configuration?

– Michael Hampton
Apr 20 '13 at 23:51




1




1





your socket from log file is /tmp/php-fpm.sock but you changed /var/lib/nginx/tmp - did you do chroot in nginx ?

– silviud
Apr 20 '13 at 23:51





your socket from log file is /tmp/php-fpm.sock but you changed /var/lib/nginx/tmp - did you do chroot in nginx ?

– silviud
Apr 20 '13 at 23:51




1




1





send the output from the command mount

– silviud
Apr 21 '13 at 0:12





send the output from the command mount

– silviud
Apr 21 '13 at 0:12




1




1





also look that all directories in your home ... see serverfault.com/questions/170192/…

– silviud
Apr 21 '13 at 0:50





also look that all directories in your home ... see serverfault.com/questions/170192/…

– silviud
Apr 21 '13 at 0:50










5 Answers
5






active

oldest

votes


















15














I had set the /var/lib/nginx/tmp to ec2-user/ec2-user (i even +777 everything to check)



But ... I also had to set /var/lib/nginx to ec2-user/ec2-user



... after also chown/chgrp the parent nginx folder : no more errors.



Took me some hours...






share|improve this answer



















  • 6





    chown -Rf www-data:www-data /var/lib/nginx worked for me. didn't need to chmod anything.

    – Chris
    Jul 24 '15 at 20:48













  • checking log files helps always, remember to check them before anything :)

    – sorrow poetry
    Jul 12 '18 at 22:59



















7














This generally happens. When the user setting in nginx.conf is changed from



user nginx;


to something else. In this case,



user ec2-user ec2-user;


The chmod command is not necessary per Chris's comment, and could open up a security hole.



Solution:



Check the current user and group ownership on /var/lib/nginx.



$ ls -ld /var/lib/nginx
drwx------ 3 nginx nginx 4096 Aug 5 00:05 /var/lib/nginx


This tells you that a possibly non-existant user and group named nginx owns this folder. This prevents file uploading.



Change the folder ownership to the user defined in nginx.conf in this case ec2-user (sudo may not be required).



$ sudo chown -Rf ec2-user:ec2-user /var/lib/nginx


Verify that it actually changed.



$ ls -ld /var/lib/nginx
drwx------ 3 ec2-user ec2-user 4096 Aug 5 00:05 /var/lib/nginx


The permission denied error should now go away. Check the error.log (based on nginx.conf error_log location).



$ sudo nano /opt/nginx/error.log


If that doesn't work you might need to reload nginx and php-fpm.



$ sudo service nginx reload
$ sudo service php-fpm reload





share|improve this answer































    3














    None of the other solutions worked for me, but I found this to work:



    $ apt-get install php-pear php5-dev
    $ pecl install timezonedb
    $ echo 'extension=timezonedb.so'> /etc/php5/mods-available/timezonedb.ini
    $ ln -sf /etc/php5/mods-available/timezonedb.ini /etc/php5/conf.d/30-timezonedb.ini
    $ service php5-fpm restart


    Source






    share|improve this answer
























    • Ok, we tried several solutions and this is the one that worked. We dont know why it worked or what the problem was, but it did.

      – Neil Masters
      Jun 11 '15 at 12:56



















    1














    I have got the similar problem with file upload. nginx 500 error

    2015/07/05 03:50:36 [crit] 3656#0: *7 open() "/var/lib/nginx/tmp/client_body/0000000007" failed (13: Permission denied), client: 10.0.2.2, server: www.test.com, request: "POST /api/v1/users HTTP/1.1", host: "test"



    The issue was related to permission only, i just set chmod -R 755 /var/lib/nginx and things worked!






    share|improve this answer































      0














      Just solved my issue with permissions. The easiest way and most simple was to not run php-fpm or nginx as sudo (super user). What you would have to do is:




      1. chown all log output locations for nginx to yourUserName:yourUserName example: chown yourUserName:yourUserName /var/log/nginx/error.log

      2. Next update server dir as well example: chown yourUserName:yourUserName -R /var/www


      By not using root i didn't have to change php-fpm user or group or any listening user or groups. Make sure you also comment out nginx.conf 'user' as it will be the current users name.






      share|improve this answer
























      • Please don't post the same answer multiple times. Also, this problem has long been solved.

        – Sven
        Jul 21 '17 at 21:18












      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "2"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f501258%2fphp-fpm-gives-permission-denied%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      5 Answers
      5






      active

      oldest

      votes








      5 Answers
      5






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      15














      I had set the /var/lib/nginx/tmp to ec2-user/ec2-user (i even +777 everything to check)



      But ... I also had to set /var/lib/nginx to ec2-user/ec2-user



      ... after also chown/chgrp the parent nginx folder : no more errors.



      Took me some hours...






      share|improve this answer



















      • 6





        chown -Rf www-data:www-data /var/lib/nginx worked for me. didn't need to chmod anything.

        – Chris
        Jul 24 '15 at 20:48













      • checking log files helps always, remember to check them before anything :)

        – sorrow poetry
        Jul 12 '18 at 22:59
















      15














      I had set the /var/lib/nginx/tmp to ec2-user/ec2-user (i even +777 everything to check)



      But ... I also had to set /var/lib/nginx to ec2-user/ec2-user



      ... after also chown/chgrp the parent nginx folder : no more errors.



      Took me some hours...






      share|improve this answer



















      • 6





        chown -Rf www-data:www-data /var/lib/nginx worked for me. didn't need to chmod anything.

        – Chris
        Jul 24 '15 at 20:48













      • checking log files helps always, remember to check them before anything :)

        – sorrow poetry
        Jul 12 '18 at 22:59














      15












      15








      15







      I had set the /var/lib/nginx/tmp to ec2-user/ec2-user (i even +777 everything to check)



      But ... I also had to set /var/lib/nginx to ec2-user/ec2-user



      ... after also chown/chgrp the parent nginx folder : no more errors.



      Took me some hours...






      share|improve this answer













      I had set the /var/lib/nginx/tmp to ec2-user/ec2-user (i even +777 everything to check)



      But ... I also had to set /var/lib/nginx to ec2-user/ec2-user



      ... after also chown/chgrp the parent nginx folder : no more errors.



      Took me some hours...







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Apr 21 '13 at 1:21









      edelwateredelwater

      3121311




      3121311








      • 6





        chown -Rf www-data:www-data /var/lib/nginx worked for me. didn't need to chmod anything.

        – Chris
        Jul 24 '15 at 20:48













      • checking log files helps always, remember to check them before anything :)

        – sorrow poetry
        Jul 12 '18 at 22:59














      • 6





        chown -Rf www-data:www-data /var/lib/nginx worked for me. didn't need to chmod anything.

        – Chris
        Jul 24 '15 at 20:48













      • checking log files helps always, remember to check them before anything :)

        – sorrow poetry
        Jul 12 '18 at 22:59








      6




      6





      chown -Rf www-data:www-data /var/lib/nginx worked for me. didn't need to chmod anything.

      – Chris
      Jul 24 '15 at 20:48







      chown -Rf www-data:www-data /var/lib/nginx worked for me. didn't need to chmod anything.

      – Chris
      Jul 24 '15 at 20:48















      checking log files helps always, remember to check them before anything :)

      – sorrow poetry
      Jul 12 '18 at 22:59





      checking log files helps always, remember to check them before anything :)

      – sorrow poetry
      Jul 12 '18 at 22:59













      7














      This generally happens. When the user setting in nginx.conf is changed from



      user nginx;


      to something else. In this case,



      user ec2-user ec2-user;


      The chmod command is not necessary per Chris's comment, and could open up a security hole.



      Solution:



      Check the current user and group ownership on /var/lib/nginx.



      $ ls -ld /var/lib/nginx
      drwx------ 3 nginx nginx 4096 Aug 5 00:05 /var/lib/nginx


      This tells you that a possibly non-existant user and group named nginx owns this folder. This prevents file uploading.



      Change the folder ownership to the user defined in nginx.conf in this case ec2-user (sudo may not be required).



      $ sudo chown -Rf ec2-user:ec2-user /var/lib/nginx


      Verify that it actually changed.



      $ ls -ld /var/lib/nginx
      drwx------ 3 ec2-user ec2-user 4096 Aug 5 00:05 /var/lib/nginx


      The permission denied error should now go away. Check the error.log (based on nginx.conf error_log location).



      $ sudo nano /opt/nginx/error.log


      If that doesn't work you might need to reload nginx and php-fpm.



      $ sudo service nginx reload
      $ sudo service php-fpm reload





      share|improve this answer




























        7














        This generally happens. When the user setting in nginx.conf is changed from



        user nginx;


        to something else. In this case,



        user ec2-user ec2-user;


        The chmod command is not necessary per Chris's comment, and could open up a security hole.



        Solution:



        Check the current user and group ownership on /var/lib/nginx.



        $ ls -ld /var/lib/nginx
        drwx------ 3 nginx nginx 4096 Aug 5 00:05 /var/lib/nginx


        This tells you that a possibly non-existant user and group named nginx owns this folder. This prevents file uploading.



        Change the folder ownership to the user defined in nginx.conf in this case ec2-user (sudo may not be required).



        $ sudo chown -Rf ec2-user:ec2-user /var/lib/nginx


        Verify that it actually changed.



        $ ls -ld /var/lib/nginx
        drwx------ 3 ec2-user ec2-user 4096 Aug 5 00:05 /var/lib/nginx


        The permission denied error should now go away. Check the error.log (based on nginx.conf error_log location).



        $ sudo nano /opt/nginx/error.log


        If that doesn't work you might need to reload nginx and php-fpm.



        $ sudo service nginx reload
        $ sudo service php-fpm reload





        share|improve this answer


























          7












          7








          7







          This generally happens. When the user setting in nginx.conf is changed from



          user nginx;


          to something else. In this case,



          user ec2-user ec2-user;


          The chmod command is not necessary per Chris's comment, and could open up a security hole.



          Solution:



          Check the current user and group ownership on /var/lib/nginx.



          $ ls -ld /var/lib/nginx
          drwx------ 3 nginx nginx 4096 Aug 5 00:05 /var/lib/nginx


          This tells you that a possibly non-existant user and group named nginx owns this folder. This prevents file uploading.



          Change the folder ownership to the user defined in nginx.conf in this case ec2-user (sudo may not be required).



          $ sudo chown -Rf ec2-user:ec2-user /var/lib/nginx


          Verify that it actually changed.



          $ ls -ld /var/lib/nginx
          drwx------ 3 ec2-user ec2-user 4096 Aug 5 00:05 /var/lib/nginx


          The permission denied error should now go away. Check the error.log (based on nginx.conf error_log location).



          $ sudo nano /opt/nginx/error.log


          If that doesn't work you might need to reload nginx and php-fpm.



          $ sudo service nginx reload
          $ sudo service php-fpm reload





          share|improve this answer













          This generally happens. When the user setting in nginx.conf is changed from



          user nginx;


          to something else. In this case,



          user ec2-user ec2-user;


          The chmod command is not necessary per Chris's comment, and could open up a security hole.



          Solution:



          Check the current user and group ownership on /var/lib/nginx.



          $ ls -ld /var/lib/nginx
          drwx------ 3 nginx nginx 4096 Aug 5 00:05 /var/lib/nginx


          This tells you that a possibly non-existant user and group named nginx owns this folder. This prevents file uploading.



          Change the folder ownership to the user defined in nginx.conf in this case ec2-user (sudo may not be required).



          $ sudo chown -Rf ec2-user:ec2-user /var/lib/nginx


          Verify that it actually changed.



          $ ls -ld /var/lib/nginx
          drwx------ 3 ec2-user ec2-user 4096 Aug 5 00:05 /var/lib/nginx


          The permission denied error should now go away. Check the error.log (based on nginx.conf error_log location).



          $ sudo nano /opt/nginx/error.log


          If that doesn't work you might need to reload nginx and php-fpm.



          $ sudo service nginx reload
          $ sudo service php-fpm reload






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 29 '16 at 22:13









          nu everestnu everest

          51211022




          51211022























              3














              None of the other solutions worked for me, but I found this to work:



              $ apt-get install php-pear php5-dev
              $ pecl install timezonedb
              $ echo 'extension=timezonedb.so'> /etc/php5/mods-available/timezonedb.ini
              $ ln -sf /etc/php5/mods-available/timezonedb.ini /etc/php5/conf.d/30-timezonedb.ini
              $ service php5-fpm restart


              Source






              share|improve this answer
























              • Ok, we tried several solutions and this is the one that worked. We dont know why it worked or what the problem was, but it did.

                – Neil Masters
                Jun 11 '15 at 12:56
















              3














              None of the other solutions worked for me, but I found this to work:



              $ apt-get install php-pear php5-dev
              $ pecl install timezonedb
              $ echo 'extension=timezonedb.so'> /etc/php5/mods-available/timezonedb.ini
              $ ln -sf /etc/php5/mods-available/timezonedb.ini /etc/php5/conf.d/30-timezonedb.ini
              $ service php5-fpm restart


              Source






              share|improve this answer
























              • Ok, we tried several solutions and this is the one that worked. We dont know why it worked or what the problem was, but it did.

                – Neil Masters
                Jun 11 '15 at 12:56














              3












              3








              3







              None of the other solutions worked for me, but I found this to work:



              $ apt-get install php-pear php5-dev
              $ pecl install timezonedb
              $ echo 'extension=timezonedb.so'> /etc/php5/mods-available/timezonedb.ini
              $ ln -sf /etc/php5/mods-available/timezonedb.ini /etc/php5/conf.d/30-timezonedb.ini
              $ service php5-fpm restart


              Source






              share|improve this answer













              None of the other solutions worked for me, but I found this to work:



              $ apt-get install php-pear php5-dev
              $ pecl install timezonedb
              $ echo 'extension=timezonedb.so'> /etc/php5/mods-available/timezonedb.ini
              $ ln -sf /etc/php5/mods-available/timezonedb.ini /etc/php5/conf.d/30-timezonedb.ini
              $ service php5-fpm restart


              Source







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered May 21 '14 at 11:57









              nullvariablenullvariable

              1314




              1314













              • Ok, we tried several solutions and this is the one that worked. We dont know why it worked or what the problem was, but it did.

                – Neil Masters
                Jun 11 '15 at 12:56



















              • Ok, we tried several solutions and this is the one that worked. We dont know why it worked or what the problem was, but it did.

                – Neil Masters
                Jun 11 '15 at 12:56

















              Ok, we tried several solutions and this is the one that worked. We dont know why it worked or what the problem was, but it did.

              – Neil Masters
              Jun 11 '15 at 12:56





              Ok, we tried several solutions and this is the one that worked. We dont know why it worked or what the problem was, but it did.

              – Neil Masters
              Jun 11 '15 at 12:56











              1














              I have got the similar problem with file upload. nginx 500 error

              2015/07/05 03:50:36 [crit] 3656#0: *7 open() "/var/lib/nginx/tmp/client_body/0000000007" failed (13: Permission denied), client: 10.0.2.2, server: www.test.com, request: "POST /api/v1/users HTTP/1.1", host: "test"



              The issue was related to permission only, i just set chmod -R 755 /var/lib/nginx and things worked!






              share|improve this answer




























                1














                I have got the similar problem with file upload. nginx 500 error

                2015/07/05 03:50:36 [crit] 3656#0: *7 open() "/var/lib/nginx/tmp/client_body/0000000007" failed (13: Permission denied), client: 10.0.2.2, server: www.test.com, request: "POST /api/v1/users HTTP/1.1", host: "test"



                The issue was related to permission only, i just set chmod -R 755 /var/lib/nginx and things worked!






                share|improve this answer


























                  1












                  1








                  1







                  I have got the similar problem with file upload. nginx 500 error

                  2015/07/05 03:50:36 [crit] 3656#0: *7 open() "/var/lib/nginx/tmp/client_body/0000000007" failed (13: Permission denied), client: 10.0.2.2, server: www.test.com, request: "POST /api/v1/users HTTP/1.1", host: "test"



                  The issue was related to permission only, i just set chmod -R 755 /var/lib/nginx and things worked!






                  share|improve this answer













                  I have got the similar problem with file upload. nginx 500 error

                  2015/07/05 03:50:36 [crit] 3656#0: *7 open() "/var/lib/nginx/tmp/client_body/0000000007" failed (13: Permission denied), client: 10.0.2.2, server: www.test.com, request: "POST /api/v1/users HTTP/1.1", host: "test"



                  The issue was related to permission only, i just set chmod -R 755 /var/lib/nginx and things worked!







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jul 5 '15 at 4:13









                  Bishwanath JhaBishwanath Jha

                  111




                  111























                      0














                      Just solved my issue with permissions. The easiest way and most simple was to not run php-fpm or nginx as sudo (super user). What you would have to do is:




                      1. chown all log output locations for nginx to yourUserName:yourUserName example: chown yourUserName:yourUserName /var/log/nginx/error.log

                      2. Next update server dir as well example: chown yourUserName:yourUserName -R /var/www


                      By not using root i didn't have to change php-fpm user or group or any listening user or groups. Make sure you also comment out nginx.conf 'user' as it will be the current users name.






                      share|improve this answer
























                      • Please don't post the same answer multiple times. Also, this problem has long been solved.

                        – Sven
                        Jul 21 '17 at 21:18
















                      0














                      Just solved my issue with permissions. The easiest way and most simple was to not run php-fpm or nginx as sudo (super user). What you would have to do is:




                      1. chown all log output locations for nginx to yourUserName:yourUserName example: chown yourUserName:yourUserName /var/log/nginx/error.log

                      2. Next update server dir as well example: chown yourUserName:yourUserName -R /var/www


                      By not using root i didn't have to change php-fpm user or group or any listening user or groups. Make sure you also comment out nginx.conf 'user' as it will be the current users name.






                      share|improve this answer
























                      • Please don't post the same answer multiple times. Also, this problem has long been solved.

                        – Sven
                        Jul 21 '17 at 21:18














                      0












                      0








                      0







                      Just solved my issue with permissions. The easiest way and most simple was to not run php-fpm or nginx as sudo (super user). What you would have to do is:




                      1. chown all log output locations for nginx to yourUserName:yourUserName example: chown yourUserName:yourUserName /var/log/nginx/error.log

                      2. Next update server dir as well example: chown yourUserName:yourUserName -R /var/www


                      By not using root i didn't have to change php-fpm user or group or any listening user or groups. Make sure you also comment out nginx.conf 'user' as it will be the current users name.






                      share|improve this answer













                      Just solved my issue with permissions. The easiest way and most simple was to not run php-fpm or nginx as sudo (super user). What you would have to do is:




                      1. chown all log output locations for nginx to yourUserName:yourUserName example: chown yourUserName:yourUserName /var/log/nginx/error.log

                      2. Next update server dir as well example: chown yourUserName:yourUserName -R /var/www


                      By not using root i didn't have to change php-fpm user or group or any listening user or groups. Make sure you also comment out nginx.conf 'user' as it will be the current users name.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Jul 21 '17 at 20:29









                      c-l-hc-l-h

                      1




                      1













                      • Please don't post the same answer multiple times. Also, this problem has long been solved.

                        – Sven
                        Jul 21 '17 at 21:18



















                      • Please don't post the same answer multiple times. Also, this problem has long been solved.

                        – Sven
                        Jul 21 '17 at 21:18

















                      Please don't post the same answer multiple times. Also, this problem has long been solved.

                      – Sven
                      Jul 21 '17 at 21:18





                      Please don't post the same answer multiple times. Also, this problem has long been solved.

                      – Sven
                      Jul 21 '17 at 21:18


















                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Server Fault!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f501258%2fphp-fpm-gives-permission-denied%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      As a Security Precaution, the user account has been locked The Next CEO of Stack OverflowMS...

                      Список ссавців Італії Природоохоронні статуси | Список |...

                      Українські прізвища Зміст Історичні відомості |...