Nginx下支持Thinkphp URL Rewrite的配置示例
概述
Nginx服務(wù)器現(xiàn)在已經(jīng)成為相當(dāng)流行的開源Web服務(wù)器,很多生產(chǎn)環(huán)境也都在使用Nginx服務(wù)器?,F(xiàn)在做項(xiàng)目大多數(shù)時(shí)候都是在使用ThinkPHP,但是Nginx默認(rèn)不支持ThinkPHP的pathinfo模式,需要進(jìn)行一定的配置。
Nginx配置文件
# # The default server # server { listen 80 default_server; #server_name www.example.com; #charset koi8-r; #access_log logs/host.access.log main; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; #location / { # root /usr/share/nginx/html; # index index.html index.htm; #} location / { root /var/www/project_name; index index.html index.php; if (!-e $request_filename){ rewrite ^(.*)$ /index.php?s=$1 last; } } error_page 404 /404.html; location = /404.html { root /usr/share/nginx/html; } # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root /var/www/project_name; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }
總結(jié)
做個(gè)備份,方便以后查看:)
相關(guān)文章
Nginx解決vue項(xiàng)目服務(wù)器部署及跨域訪問后端詳解
跨域問題在前后端分離項(xiàng)目很常見,至于為什么會(huì)跨域,同源策略,百度各種博客都很詳細(xì),這里不再介紹,這篇文章主要給大家介紹了關(guān)于Nginx解決vue項(xiàng)目服務(wù)器部署及跨域訪問后端的相關(guān)資料,需要的朋友可以參考下2022-11-11配置nginx保證frps服務(wù)器與web共用80端口的方法
這篇文章主要介紹了frps服務(wù)端與nginx可共用80端口的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-06-06nginx 虛擬主機(jī)設(shè)置實(shí)例(多網(wǎng)站配置)
Nginx 虛擬主機(jī)設(shè)置一例,主要是針對(duì)虛擬主機(jī)的設(shè)置,多網(wǎng)站配置方法,需要的朋友可以參考下2013-02-02Nginx報(bào)404錯(cuò)誤的詳細(xì)解決方法
最近打開網(wǎng)站看看結(jié)果提示:nginx 404 not found,所以這篇文章主要給大家介紹了關(guān)于Nginx報(bào)404錯(cuò)誤的簡單解決方法,文中通過圖文介紹的非常詳細(xì),需要的朋友可以參考下2022-07-07利用nginx + fastcgi實(shí)現(xiàn)圖片識(shí)別服務(wù)器
這篇文章主要給大家介紹了關(guān)于如何利用nginx + fastcgi實(shí)現(xiàn)圖片識(shí)別服務(wù)器的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-03-03