Home Backend Development PHP Tutorial Make Nginx support ThinkPHP framework_PHP tutorial

Make Nginx support ThinkPHP framework_PHP tutorial

Jul 14, 2016 am 10:07 AM
apache nginx thinkphp company Will support most server frame of

Recently, something went wrong when migrating one of the company's servers from Apache to Nginx, so I made a note.
The problem lies in the fact that the above website is developed based on the ThinkPHP framework and cannot be configured using the default method. After searching on Baidu online, I found that this problem is very common. The configuration of the general solution is as follows:
server {
...
If (!-e $request_filename) {
                                                                                                                                                          ;             break;
}

}

location ~ .+.php($|/) {

....
set $script $uri;
set $path_info "/";
If ($uri ~ "^(.+.php)(/.*)") {
set $script $1;
set $path_info $2;
}
 
Fastcgi_param PATH_INFO $path_info;
Fastcgi_param SCRIPT_FILENAME /path/to/web-root$script;

}

Yesterday, while reading a book, I suddenly discovered that the fastcgi module comes with a command specifically designed to solve such problems. The command is fastcgi_split_path_info. This command will separate the URL according to the given regular expression, thereby extracting the script name and path. info information, using this command can avoid using if statements and make the configuration simpler. (The if statement in the server part can be replaced by try_files). The new configuration is as follows:
server {
...
try_files $uri /index.php$uri;
}

location ~ .+.php($|/) {

....
Fastcgi_split_path_info ^(.+.php)(/.*)$;
Fastcgi_param PATH_INFO $fastcgi_path_info;
Fastcgi_param SCRIPT_FILENAME /path/to/web-root$fastcgi_script_name;

}

http://www.bkjia.com/PHPjc/477891.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477891.htmlTechArticleRecently, there was a problem when migrating one of the company's servers from Apache to Nginx, so I made a special notes. The problem is that the above website is developed based on the ThinkPHP framework, using default...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How do the lightweight options of PHP frameworks affect application performance? How do the lightweight options of PHP frameworks affect application performance? Jun 06, 2024 am 10:53 AM

The lightweight PHP framework improves application performance through small size and low resource consumption. Its features include: small size, fast startup, low memory usage, improved response speed and throughput, and reduced resource consumption. Practical case: SlimFramework creates REST API, only 500KB, high responsiveness and high throughput

Equipped with AMD EPYC 4004 series processors, ASUS launches a variety of server and workstation products Equipped with AMD EPYC 4004 series processors, ASUS launches a variety of server and workstation products Jul 23, 2024 pm 09:34 PM

According to news from this website on July 23, ASUS has launched a variety of server and workstation-level products powered by AMD EPYC 4004 series processors. Note from this site: AMD launched the AM5 platform and Zen4 architecture EPYC 4004 series processors in May, offering up to 16-core 3DV-Cache specifications. ASUSProER100AB6 server ASUSProER100AB6 is a 1U rack server product equipped with EPYC Xiaolong 4004 series processor, suitable for the needs of IDC and small and medium-sized enterprises. ASUSExpertCenterProET500AB6 workstation ASUSExpertCenterProET500AB6 is a

How does the learning curve of PHP frameworks compare to other language frameworks? How does the learning curve of PHP frameworks compare to other language frameworks? Jun 06, 2024 pm 12:41 PM

The learning curve of a PHP framework depends on language proficiency, framework complexity, documentation quality, and community support. The learning curve of PHP frameworks is higher when compared to Python frameworks and lower when compared to Ruby frameworks. Compared to Java frameworks, PHP frameworks have a moderate learning curve but a shorter time to get started.

Detailed practical explanation of golang framework development: Questions and Answers Detailed practical explanation of golang framework development: Questions and Answers Jun 06, 2024 am 10:57 AM

In Go framework development, common challenges and their solutions are: Error handling: Use the errors package for management, and use middleware to centrally handle errors. Authentication and authorization: Integrate third-party libraries and create custom middleware to check credentials. Concurrency processing: Use goroutines, mutexes, and channels to control resource access. Unit testing: Use gotest packages, mocks, and stubs for isolation, and code coverage tools to ensure sufficiency. Deployment and monitoring: Use Docker containers to package deployments, set up data backups, and track performance and errors with logging and monitoring tools.

Golang framework performance comparison: metrics for making wise choices Golang framework performance comparison: metrics for making wise choices Jun 05, 2024 pm 10:02 PM

When choosing a Go framework, key performance indicators (KPIs) include: response time, throughput, concurrency, and resource usage. By benchmarking and comparing frameworks' KPIs, developers can make informed choices based on application needs, taking into account expected load, performance-critical sections, and resource constraints.

What are the common things that need to be paid attention to when using the Golang framework? What are the common things that need to be paid attention to when using the Golang framework? Jun 06, 2024 pm 01:33 PM

When using the Golang framework, you should pay attention to: check whether the route matches the request to avoid routing errors. Use middleware with caution to avoid performance degradation. Properly manage database connections to prevent performance issues or crashes. Use error wrappers to handle errors and ensure your code is clear and easy to debug. Obtain third-party packages from reputable sources and keep packages up to date.

What are the common misunderstandings in the learning process of Golang framework? What are the common misunderstandings in the learning process of Golang framework? Jun 05, 2024 pm 09:59 PM

There are five misunderstandings in Go framework learning: over-reliance on the framework and limited flexibility. If you don’t follow the framework conventions, the code will be difficult to maintain. Using outdated libraries can cause security and compatibility issues. Excessive use of packages obfuscates code structure. Ignoring error handling leads to unexpected behavior and crashes.

Alibaba releases and opens the Tongyi Qianwen QwQ-32B inference model, with performance comparable to DeepSeek-R1 Alibaba releases and opens the Tongyi Qianwen QwQ-32B inference model, with performance comparable to DeepSeek-R1 Mar 12, 2025 pm 01:00 PM

Alibaba Cloud’s new open source inference model Tongyi Qianwen QwQ-32B, with performance comparable to DeepSeek-R1! On March 6, Alibaba Cloud officially announced the open source of its latest research and development inference model- Tongyi Qianwen QwQ-32B. The model has achieved significant improvements in math, code and general capabilities, with performance levels comparable to the industry-leading DeepSeek-R1 model. This news stimulated Alibaba's stock price to rise sharply, once rising by more than 8%. Alibaba Cloud confirmed in several authoritative benchmark tests that Qianwen QwQ-32B's performance far exceeds OpenAI-o1-mini and is on par with DeepSeek-R1 in overall performance. What's more remarkable is that the model has greatly reduced its performance while maintaining high performance.

See all articles