Impossible to write on file in php with nginx + php-fpm -


i can't understand why php function is_writable() returning false. see nothing in log it, , after searching hours : can't understand why.

file setup :

[root@localhost owncloud]# ls -la /etc/test -rwxrwxrwx. 1 nginx nginx 4 jul 31 17:41 /etc/test 

test.php

<?php     $filename = '/etc/test';     echo exec('whoami');     if (file_exists($filename)) {         echo 'exist';     } else {         echo 'not exist';     }     if (is_writable($filename)) {         echo 'writable';     } else {         echo 'not writable';     } ?> 

it returns :

nginx exist not writable  

my nginx has following configuration :

/etc/nginx/nginx.conf

user  nginx; worker_processes  1;  error_log  /var/log/nginx/error.log; #error_log  /var/log/nginx/error.log  notice; #error_log  /var/log/nginx/error.log  info;  pid        /run/nginx.pid;  events {     worker_connections  1024; }  http {     include       /etc/nginx/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  /var/log/nginx/access.log  main;     sendfile        on;     keepalive_timeout  65;     server {      listen 8080 ssl;     ssl_certificate     /etc/nginx/certs/owncloud.crt;     ssl_certificate_key /etc/nginx/certs/owncloud.key;      error_log /var/log/nginx/owncloud.log;     access_log /var/log/nginx/owncloud.log;      server_name owncloud;      root /var/www/owncloud;      client_max_body_size 10g; # set max upload size     fastcgi_buffers 64 4k;      rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;     rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;     rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;      index index.php;     error_page 403 = /core/templates/403.php;     error_page 404 = /core/templates/404.php;      location = /robots.txt {         allow all;         log_not_found off;         access_log off;     }      location ~ ^/(data|config|\.ht|db_structure\.xml|readme) {         #allow instead of deny testing purpose                 allow all;     }      location / {             rewrite ^/.well-known/host-meta /public.php?service=host-meta last;             rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;             rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;             rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;             rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;              try_files $uri $uri/ index.php;     }      location ~ ^(.+?\.php)(/.*)?$ {             try_files $1 = 404;              include fastcgi_params;             fastcgi_param script_filename $document_root$1;             fastcgi_param path_info $2;             fastcgi_param https on;             fastcgi_pass 127.0.0.1:9000;     }   } } 

/etc/php-fpm.conf

include=/etc/php-fpm.d/www.conf [global] pid = /run/php-fpm/php-fpm.pid error_log = /var/log/php-fpm/error.log log_level = debug daemonize = no 

/etc/php-fpm.d/www.conf

[www] listen = 127.0.0.1:9000 listen.allowed_clients = 127.0.0.1 listen.owner = nginx  listen.group = nginx user = nginx group = nginx pm = dynamic pm.max_children = 50 pm.start_servers = 5 pm.min_spare_servers = 5 pm.max_spare_servers = 35 slowlog = /var/log/php-fpm/www-slow.log php_admin_value[error_log] = /var/log/php-fpm/www-error.log php_admin_flag[log_errors] = on php_value[session.save_handler] = files php_value[session.save_path] = /var/lib/php/session 

the problem selinux seems prevent nginx write files. disabling selinux solve problem


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -