Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Nginx utilise fastcgi et donc php en fpm.
- /etc/nginx/fastcgi_params :
- fastcgi_param QUERY_STRING $query_string;
- fastcgi_param REQUEST_METHOD $request_method;
- fastcgi_param CONTENT_TYPE $content_type;
- fastcgi_param CONTENT_LENGTH $content_length;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- fastcgi_param SCRIPT_NAME $fastcgi_script_name;
- fastcgi_param PATH_INFO $fastcgi_path_info;
- fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
- fastcgi_param REQUEST_URI $request_uri;
- fastcgi_param DOCUMENT_URI $document_uri;
- fastcgi_param DOCUMENT_ROOT $document_root;
- fastcgi_param SERVER_PROTOCOL $server_protocol;
- fastcgi_param HTTPS $https if_not_empty;
- fastcgi_param GATEWAY_INTERFACE CGI/1.1;
- fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
- fastcgi_param REMOTE_ADDR $remote_addr;
- fastcgi_param REMOTE_PORT $remote_port;
- fastcgi_param SERVER_ADDR $server_addr;
- fastcgi_param SERVER_PORT $server_port;
- fastcgi_param SERVER_NAME $server_name;
- # PHP only, required if PHP was built with --enable-force-cgi-redirect
- fastcgi_param REDIRECT_STATUS 200;
- Exemple de configuration :
- location ~ [^/]\.php(/|$) {
- fastcgi_split_path_info ^(.+?\.php)(/.*)$;
- root /var/www/facetious-pelican/html/;
- if (!-f $document_root$fastcgi_script_name) {
- return 404;
- }
- fastcgi_pass unix:/var/run/php5-fpm.sock;
- fastcgi_index index.php;
- include /etc/nginx/fastcgi_params;
- }
- Le site se trouve dans /var/www/facetious-pelican/html/.
- Le fichier appelé, test/test.php, contient ceci :
- <pre><?php var_export($_SERVER)?></pre>
- Et il renvoie ceci :
- array (
- 'USER' => 'www-data',
- 'HOME' => '/var/www',
- 'FCGI_ROLE' => 'RESPONDER',
- 'QUERY_STRING' => '',
- 'REQUEST_METHOD' => 'GET',
- 'CONTENT_TYPE' => '',
- 'CONTENT_LENGTH' => '',
- 'SCRIPT_FILENAME' => '/var/www/facetious-pelican/html/test/test.php',
- 'SCRIPT_NAME' => '/test/test.php',
- 'PATH_INFO' => '',
- 'PATH_TRANSLATED' => '/var/www/facetious-pelican/html',
- 'REQUEST_URI' => '/test/test.php',
- 'DOCUMENT_URI' => '/test/test.php',
- 'DOCUMENT_ROOT' => '/var/www/facetious-pelican/html',
- 'SERVER_PROTOCOL' => 'HTTP/1.1',
- 'GATEWAY_INTERFACE' => 'CGI/1.1',
- 'SERVER_SOFTWARE' => 'nginx/1.4.4',
- 'REMOTE_ADDR' => '127.0.0.1',
- 'REMOTE_PORT' => '54654',
- 'SERVER_ADDR' => '127.0.0.1',
- 'SERVER_PORT' => '80',
- 'SERVER_NAME' => 'facetious-pelican',
- 'REDIRECT_STATUS' => '200',
- 'HTTP_HOST' => 'facetious-pelican',
- 'HTTP_USER_AGENT' => 'Mozilla/5.0 (X11; Linux i686; rv:20.0) Gecko/20100101 Firefox/20.0 Iceweasel/20.0',
- 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
- 'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.5',
- 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
- 'HTTP_CONNECTION' => 'keep-alive',
- 'HTTP_CACHE_CONTROL' => 'max-age=0',
- 'PHP_SELF' => '/test/test.php',
- 'REQUEST_TIME_FLOAT' => 1390690367.819366,
- 'REQUEST_TIME' => 1390690367,
- )
- Sources et références :
- http://wiki.nginx.org/PHPFcgiExample
- Infos système :
- para@para-clevo:/etc/nginx$ php5-fpm --version
- PHP 5.5.8-2 (fpm-fcgi) (built: Jan 12 2014 10:36:01)
- Copyright (c) 1997-2013 The PHP Group
- Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
- with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies
- para@para-clevo:/etc/nginx$ nginx -v
- nginx version: nginx/1.4.4
- Il se peut que nginx balance l'erreur suivante : (/var/log/nginx/error.log)
- 2014/11/11 22:41:51 [crit] 22493#0: *7159 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 81.164.20.137, server: facetious-pelican.fuuu.be, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "facetious-pelican.fuuu.be"
- => C'est une question de permission sur le socket de php5-fpm.
- 1/ checker le nom d'utilisateur utilisé par nginx : (/etc/nginx/nginx.conf)
- ...
- user nginx;
- ...
- 2/ modifier /etc/php5/fpm/pool.d/www.conf :
- user = nginx
- group = nginx
- listen.owner = nginx
- listen.group = nginx
- listen.mode = 0660
- 3/ sudo service php5-fpm stop
- sudo service php5-fpm start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement