In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
Today, the editor will share with you the relevant knowledge points about how to configure pathinfo mode in nginx. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.
Reason
I haven't used apache for a long time, and I gradually feel strange to apache, because my friend has a zendframework framework that has been moved from apache to nginx and needs pathinfo mode support.
Online sea search
So I started searching for nginx+pathinfo-related articles and thought it would be easy to configure. Because after searching, I found that there are a large number of articles about nginx turning on pathinfo mode, which is not a difficult task. But after a few hours, it still hasn't been configured. And the contents of a large number of articles are very similar, basically reprinted.
I'm in a bit of a hurry! Because at the end of the day, it's not ready.
Keep groping.
I can't help it. keep searching. For verification convenience, I used a.com to download the thinkphp framework to build an environment. And add the useraction.class.php controller class, add an app method to the class and output a line of text.
So I began to constantly rewrite the nginx.conf file to restart nginx and constantly refresh the a.com/index.php/user/app address. The result is either address damage prompt, 502, access defind.
Another day went by, and I began to feel a little at a loss.
Finally, insist.
In theory, I feel that there should be a precedent for nginx+thinkphp, but I didn't find the answer. Suddenly I feel so confused on the Internet that I can't find an answer to a small question. Tonight, I tried to search again using the nginx thinkphp keyword. After I clicked to more than ten pages, I found a code.
The copy code is as follows:
Location / {
If (!-e $request_filename) {
Rewrite ^ / (. *) $/ index.php/$1 last
Break
}
}
Location ~\ .php {
Fastcgi_pass 127.0.0.1:9000
Fastcgi_index index.php
Include fcgi.conf
Set $real_script_name $fastcgi_script_name
If ($fastcgi_script_name ~ "^ (. +?\ .php) (/. +) $") {
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
}
Save changes, restart nginx, refresh browser
An unexpected page appeared.
It's not easy to be able to visit and finally breathe a sigh of relief.
Post the nginx.conf code:
The copy code is as follows:
User www www
Worker_processes 2
Worker_cpu_affinity 01 10
Error_log / data1/logs/nginx_error.log crit
Pid / usr/local/webserver/nginx/nginx.pid
Worker_rlimit_nofile 65535
Events
{
Use epoll
Worker_connections 65535
}
Http
{
Include mime.types
Default_type application/octet-stream
Server_names_hash_bucket_size 128
Client_header_buffer_size 32k
Large_client_header_buffers 4 32k
Client_max_body_size 8m
Sendfile on
Tcp_nopush on
Keepalive_timeout 60
Tcp_nodelay on
Fastcgi_connect_timeout 300
Fastcgi_send_timeout 300
Fastcgi_read_timeout 300
Fastcgi_buffer_size 64k
Fastcgi_buffers 4 64k
Fastcgi_busy_buffers_size 128k
Fastcgi_temp_file_write_size 128k
Server
{
Listen 80
Server_name a.com
Index index.php
Root / data0/htdocs/a.com/www
Location / {
If (!-e $request_filename) {
Rewrite ^ / (. *) $/ index.php/$1 last
Break
}
}
Location ~\ .php {
Fastcgi_pass 127.0.0.1:9000
Fastcgi_index index.php
Include fcgi.conf
Set $real_script_name $fastcgi_script_name
If ($fastcgi_script_name ~ "^ (. +?\ .php) (/. +) $") {
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
}
}
}
These are all the contents of the article "how to configure pathinfo mode in nginx". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un