nginx 部署thinkphp 做的货色, 配置 Pathinfo 模式,终于配好了
nginx 部署thinkphp 做的东西, 配置 Pathinfo 模式,终于配好了
用thinkphp做了一个网站,部署到ubuntu上的时候需要,服务器用的是nginx,本身不支持pathinfo模式,需要修改配置文件,使其能够用pathinfo。
我用的是虚拟主机的方式。之前配置了好久,总是出现各种各样的问题,最后实在不行,直接用rewrite模式,配置还比较简单。后来不知道改了什么,rewrite也不能用了,这回打算把
pathinfo 配出来, 所以查了各种资料,一点一点的改。终于改成了。
发现很多网上的东西,其实和自己用的经常会有一点差别,需要根据自己的东西进行修改才行
<span style="color: #000000;">server { listen </span>8082<span style="color: #000000;">; root </span>/usr/share/nginx/www/<span style="color: #000000;">ssdf; index index.php index.html index.htm; error_page </span>404 /404<span style="color: #000000;">.html; //404和后面的“/” 需要有一个空格隔开 </span><span style="color: #008000;">#</span><span style="color: #008000;"> pass the PHP scripts to FastCGI server listening on the php-fpm socket</span> location /<span style="color: #000000;"> { //这里是rewrite规则,可以单独使用,thinkphp中模式也要改成rewrite, </span><span style="color: #0000ff;">if</span> (!-e <span style="color: #800080;">$request_filename</span><span style="color: #000000;">) { //之前配置好了,不知道后来改了那不能用了。 rewrite ^</span>/(.*)$ /index.php/<span style="color: #800080;">$1</span><span style="color: #000000;"> last; </span><span style="color: #0000ff;">break</span><span style="color: #000000;">; } } location ~ ^(.</span>+\.php)(.*<span style="color: #000000;">) {</span><span style="color: #008000;">#</span><span style="color: #008000;"> try_files $uri =404; 这句只是尝试注释掉了,后来也没再尝试不注释能不能用</span><span style="color: #008000;">#</span><span style="color: #008000;"> fastcgi_pass 127.0.0.1:9000; 这里一开始写的词句,后来修改成default文件中的下面那一句,这句不知道这两句怎么用</span> fastcgi_pass unix:/run/php5-<span style="color: #000000;">fpm.sock; fastcgi_index index.php;</span><span style="color: #008000;">#</span><span style="color: #008000;"> include fastcgi_params; 这里面fastcgi_params和 fcgi.conf内容是相同的,网上两种命名都有人用</span><span style="color: #000000;"> include fcgi.conf; set </span><span style="color: #800080;">$real_script_name</span> <span style="color: #800080;">$fastcgi_script_name</span><span style="color: #000000;">; set </span><span style="color: #800080;">$path_info</span> <span style="color: #800000;">""</span><span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$fastcgi_script_name</span> ~ <span style="color: #800000;">"</span><span style="color: #800000;">^(.+?\.php)(/.+)$</span><span style="color: #800000;">"</span><span style="color: #000000;">){ //if语句后面一定要有个空格,要和别的区分开,属于语法规定 set </span><span style="color: #800080;">$real_script_name</span> <span style="color: #800080;">$1</span><span style="color: #000000;">; set </span><span style="color: #800080;">$path_info</span> <span style="color: #800080;">$2</span><span style="color: #000000;">; } fastcgi_param SCRIPT_FILENAME </span><span style="color: #800080;">$document_root$real_script_name</span><span style="color: #000000;">; fastcgi_param SCRIPT_NAME </span><span style="color: #800080;">$real_script_name</span><span style="color: #000000;">; fastcgi_param PATH_INFO </span><span style="color: #800080;">$path_info</span><span style="color: #000000;">; }}</span>
- 1楼三百里江山
- 先收藏着,以后有用。多谢你的贡献

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

index.html represents the home page file of the web page and is the default page of the website. When a user visits a website, the index.html page is usually loaded first. HTML (HypertextMarkupLanguage) is a markup language used to create web pages, and index.html is also an HTML file. It contains the structure and content of a web page, as well as tags and elements used for formatting and layout. Here is an example index.html code: <

Script means script or script. In film, television, drama and other art forms, script is used to describe the dialogue, actions and scenes of characters, as well as the development and structure of the story. Script writing requires certain skills and experience, and it should be vivid and powerful, capable of attracting the audience's attention and conveying the emotions and themes of the story. Scripts are particularly important in the film and television industries. They are the basis of creation and determine the storyline, character development and dialogue content of the film. Script is an important tool for artists to create and express themselves.

fastcgi: fastcgi is developed and improved from cgi. The main disadvantage of the traditional cgi interface method is poor performance, because every time the http server encounters a dynamic program, the script parser needs to be restarted to perform parsing, and then the results are returned to the http server. This is almost unavailable when dealing with high concurrent access. In addition, the traditional cgi interface method has poor security and is rarely used now. The fastcgi interface mode adopts the c/s structure, which can separate the http server and the script parsing server, and start one or more script parsing daemons on the script parsing server. Every time the http server encounters a dynamic program, it can be delivered directly to fastcg

URL jump The URL jump mentioned here is to jump to another URL when the user accesses one URL. A common application scenario is to let multiple domain names jump to the same URL (for example, let the old domain name jump to a new domain name), jump static file requests to CDN, etc. Jump to different sites according to the user's device (PC version) , wap version), etc. URL jump can be achieved by setting the window.location on the page with js or by setting the header with php. Of course, it can also be implemented using the rewrite function of nginx. The nginxrewrite module rewrite is the static rewrite module of nginx. The basic usage is rewritepattenre.

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

In the field of computer science, "script" usually refers to a scripting language or script file. A scripting language is an interpreted programming language commonly used for tasks such as automation, batch processing, and rapid prototyping.

Location tutorial example: location=/{#Exact match/, the host name cannot be followed by any string [configurationA]}location/{#Because all addresses begin with /, this rule will match all requests#But regular and the longest string will be matched first [configurationB]}location/documents/{#Match any address starting with /documents/. After matching, continue to search downwards#Only when the subsequent regular expression is not matched, This article will use [configurationC]}location~/document

The index in MySQL means index. It is a data structure used to speed up the query of database tables. The index can be compared to the catalog of a book. It stores the values of specific columns in the table and the corresponding row positions, making the database more efficient. Locate and access data quickly. The function of the index is to improve query efficiency. Without an index, the database needs to scan the entire table row by row to find matching data. This method will be very time-consuming in large tables. With an index, the database can The required data rows are quickly located in the order, which greatly improves the query speed.
