Deploy thinkphp in nginx and configure the Pathinfo mode.

Source: Internet
Author: User
: This article describes how to deploy thinkphp in nginx and configure the Pathinfo mode. if you are interested in the PHP Tutorial, refer to it. If you use thinkphp to build a website and deploy it on ubuntu, the server uses nginx and does not support the pathinfo mode. you need to modify the configuration file so that it can use pathinfo.

I am using a VM. It has been configured for a long time before, and there are always various problems. In the end, the rewrite mode is used directly, and the configuration is relatively simple. Later, I don't know what to change, and the rewrite cannot be used.

Pathinfo configuration, so I checked all kinds of information and changed it. Finally changed.

I found that many online things are actually a little different from what I use. I need to modify them according to my own things.

Server {listen 8082; root/usr/share/nginx/www/ssdf; index. php index.html index.htm; error_page 404/404 .html; // 404 and the following "/" must be separated by a space # pass the PHP scripts to FastCGI server listening on the php-fpm socket location/{// Here is the rewrite rule, it can be used independently. the mode in thinkphp should also be changed to rewrite, if (! -E $ request_filename) {// you have configured it before. I don't know if it is changed later. Rewrite ^/(. *) $/index. php/$1 last; break;} location ~ ^ (. + \. Php )(. *) {# try_files $ uri = 404; this sentence is just an attempt to comment it out. later, I didn't try to comment it out. Can I use # fastcgi_pass 127.0.0.1: 9000? the first words written here, later modified to the default file in the following sentence, this sentence does not know how to use the two statements fastcgi_pass unix:/run/php5-fpm.sock; fastcgi_index index. php ;#IncludeFastcgi_params; fastcgi_params and fcgi. conf have the same content.IncludeFcgi. conf; set $ real_script_name $ fastcgi_script_name; set $ path_info ""; if ($ fastcgi_script_name ~ "^ (. +? \. Php )(/. +) $ ") {// there must be a space behind the if statement, which must be separated from others. it is a syntax rule set $ real_script_name $1; set $ path_info $2 ;} fastcgi_param SCRIPT_FILENAME $ document_root $ real_script_name; fastcgi_param SCRIPT_NAME $ real_script_name; fastcgi_param PATH_INFO $ path_info ;}}

The above describes how to deploy thinkphp in nginx, configure the Pathinfo mode, and finally configure thinkphp, including the include content, and hope to help those who are interested in the PHP Tutorial.

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.