thinkphp nginx配置

tp的nginx配置

server {
    listen       80;
    server_name  jktest.sysu.edu;  # 改成所配域名,在 /etc/hosts下增加
    root /var/www/jktest;  # 根地址
    index  index.html index.htm index.php;

    error_page  404              /404.html;
    location = /404.html {
        return 404 ‘Sorry, File not Found!‘;
    }
    error_page  500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html; # windows用户替换这个目录
    }

    location / {
        try_files $uri @rewrite;
    }

    location @rewrite {
        set $static 0;
        if  ($uri ~ \.(css|js|jpg|jpeg|png|gif|ico|woff|eot|svg|css\.map|min\.map)$) {
            set $static 1;
        }

        if ($static = 0) {
            rewrite ^/(.*)$ /index.php?s=/$1;
        }

    }

    location ~ /Uploads/.*\.php$ {
        deny all;
    }

    location ~ \.php/ {
       if ($request_uri ~ ^(.+\.php)(/.+?)($|\?)) { }
       fastcgi_pass 127.0.0.1:9000;
       include fastcgi_params;
       fastcgi_param SCRIPT_NAME     $1;
       fastcgi_param PATH_INFO       $2;
       fastcgi_param SCRIPT_FILENAME $document_root$1;
    }

    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny  all;
    }
}
时间: 2024-08-19 03:35:18

thinkphp nginx配置的相关文章

thinkphp nginx 配置

thinkphp convention配置:'URL_MODEL' => '2', //URL模式 nginx rewrite配置: if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } 如果你的ThinkPHP安装在二级目录,Nginx的伪静态方法设置如下,其中youdomain是所在的目录名称 location /youdomain/ { if (!-e $request_filename){ r

让nginx完美支持Thinkphp的配置

习惯了用apache后,当第一次用nginx时,把原来的项目(thinkphp框架)部署在新服务器上的时候,惊呆了! 所有的URL模式下都不能正常运行,甚至连css,js文件都不能正常加载. 原因是ngibx不支持pathinfo 主要是需要配置nginx location / { root D:/wnmp/www; index index.html index.htm; #访问路径的文件不存在则重写URL转交给ThinkPHP处理 if ( !-e $request_filename ) {

nginx 配置web 虚拟目录 并且codeIgniter,thinkphp 重新url 地址

nginx 配置虚拟目录并且url 重写 server { #侦听80端口 listen 8090; #定义使用www.xx.com访问 server_name 127.0.0.1; #设定本虚拟主机的访问日志 access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; root /home/lxy/www/cs/; #定义服务器的默认网站根目录位置 #默认请求 location / { index inde

nginx 配置web 虚拟文件夹 而且codeIgniter,thinkphp 重定向url 地址

nginx 配置虚拟文件夹而且url 重定向 server { #侦听80port listen 8090; #定义使用www.xx.com訪问 server_name 127.0.0.1; #设定本虚拟主机的訪问日志 access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; root /home/lxy/www/cs/; #定义服务器的默认站点根文件夹位置 #默认请求 location / { index

thinkphp nginx php-fpm url rewrite 导致 404 错误

thinkphp nginx php-fpm url rewrite 导致 404 错误 之前thinkphp的系统部署在apache上,考虑到在并发性能nginx比apache强悍得多,所以在centos上以 nginx+php-fpm模式重新部署了thinkphp系统,结果发现诸如 1 /index.php/home/user/verify 此类的url nginx会报404错误,但是改成 1 /index.php?s=/home/user/verify 之后却能够访问,这说明前一种url

nginx 配置rewrite

先说自己的情况,目前富乔使用的是lnmp一键包,解决步骤如下: 1.打开/usr/local/nginx/conf/nginx.conf   文件,在server段中,access_log句子前加入以下代码 location /ck/cashier/ { if (!-e $request_filename){ rewrite ^/ck/cashier/(.*)$ /ck/cashier/index.php?s=/$1 last; } } 其中/ck/cashier/  为二级目录,可根据自己的项

centos6.8 环境一键安装包 nginx配置thinkphp5

---恢复内容开始--- lnmp1.4 一键安装包 nginx配置thinkphp5 环境:Nginx1.12.1  PHP5.6  Coentos6.8 修改网站配置文件 server { listen 443 ssl http2; #listen [::]:443 ssl http2; server_name xxx.cn; index index.html index.htm index.php default.html default.htm default.php; root /ho

linux学习笔记——搭建基于nginx的web服务器、多核配置、nginx配置参数

############ 认识nginx #############Nginx:(发音同 engine x)是一款轻量级的Web服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行.由俄罗斯的程序设计师Igor Sysoev所开发,最初供俄国大型的入口网站及搜寻引擎Rambler(俄文:Рамблер)使用.  其优点是轻量级(占有内存少),高并发(并发能力强),事实上nginx的并发能力确实在同类型的网页伺服器中表现较好.目前中国大陆使用ngi

12.17 Nginx负载均衡;12.18 ssl原理;12.19 生产ssl密钥对;12.20 Nginx配置ssl

扩展: 针对请求的uri来代理 http://ask.apelearn.com/question/1049 根据访问的目录来区分后端web http://ask.apelearn.com/question/920 12.17 Nginx负载均衡 1. 安装dig命令: [[email protected] ~]# yum install -y bind-utils 2. 用dig获取qq.com的ip地址: [[email protected] ~]# dig qq.com 3. 创建ld.co