PHP nginx Server Configuration Support PathInfo

Source: Internet
Author: User
Tags nginx server
This article to share the content is about PHP nginx server configuration Support PathInfo, has a certain reference value, the need for friends can refer to

The first method:

Modification of Nginx configuration not seen nginx.conf

Location ~ \.php {          Fastcgi_pass 127.0.0.1:9000;          Fastcgi_index index.php;          include/usr/local/etc/nginx/fastcgi.conf;          Set $real _script_name $fastcgi _script_name;          if ($fastcgi _script_name ~ "^ (. +?\.php) (/.+) $") {                  set $real _script_name $;                  Set $path _info;          }          Fastcgi_param script_filename $document _root$real_script_name;          Fastcgi_param script_name $real _script_name;          Fastcgi_param path_info $path _info;  }

If you do not need to modify the fastcgi.conf configuration file for a specific host, do not forget to reload the Nginx configuration


The second method:

The nginx.conf code is as follows:

Location ~ [^/]\.php (/|$) {      #fastcgi_pass remote_php_ip:9000;      Fastcgi_pass Unix:/dev/shm/php-cgi.sock;      Fastcgi_index index.php;      Include fastcgi.conf;      Set $real _script_name $fastcgi _script_name;          if ($fastcgi _script_name ~ "^ (. +?\.php) (/.+) $") {                  set $real _script_name $;                  Set $path _info;          }          Fastcgi_param script_filename $document _root$real_script_name;          Fastcgi_param script_name $real _script_name;          Fastcgi_param path_info $path _info;    }

The fastcgi.conf code is as follows:

Fastcgi_param script_filename $document _root$fastcgi_script_name;fastcgi_param query_string $query _STRING;FASTC      Gi_param request_method $request _method;fastcgi_param content_type $content _type;fastcgi_param content_length $content _length;fastcgi_param script_name $fastcgi _script_name;fastcgi_param request_uri $request _uri ; Fastcgi_param Document_uri $document _uri;fastcgi_param document_root $document _root;fastcgi_param SERVER_PR Otocol $server _protocol;fastcgi_param request_scheme $scheme fastcgi_param HTTPS $https if_not_empty ; Fastcgi_param gateway_interface cgi/1.1;fastcgi_param server_software nginx/$nginx _version;fastcgi_param REMOTE_AD DR $remote _addr;fastcgi_param remote_port $remote _port;fastcgi_param server_addr $server _ADDR;FASTC Gi_param server_port $server _port;fastcgi_param server_name $server _name;# PHP only, required if PHP is b Uilt with--enable-force-cgi-redirectfastcgi_param Redirect_status 200; 

Reload Nginx:

Nginx-s Reload
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.