thinkphp3.2在ubantu上的nginx服务器下,path_info模式的部署

要想是pathinfo模式的话,首先需要再配置文件中设置:'URL_MODEL'=>1,

然后,ngixn配置文件为:

server {
        listen 80;
        server_name *.mobissp.com;
        
        if ($http_host ~* "^(.*?)\.mobissp\.com$") {    #正则表达式
                set $domain $1;                     #设置变量
        }
        
        
        location / {
            if ($domain ~* "ads") {
               proxy_pass http://127.0.0.1:9001;      #域名中有ads,转发到9001端口
            }
            if ($domain ~* "dashboard") {
               proxy_pass http://127.0.0.1:9002;      #域名中有dashboard,转发到9002端口
            }
 
            tcp_nodelay     on;
            proxy_set_header Host            $host;
            proxy_set_header X-Real-IP       $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            #以上三行,目的是将代理服务器收到的用户的信息传到真实服务器上
            
            root   html;
            index  index.html index.htm;            #默认情况
        }
    }

server {
        listen 9001;
        server_name 127.0.0.1;
        index index.php;
        root /data/project/;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;
        #include /mnt/project/.htaccess;
        
        location / {
                #index index.php;
                #ThinkPHP REWRITE支持
                #if (!-e  $request_filename) {
                #    rewrite ^/(.*)$ /index.php?s=$1 last;
                #}
                
                if (!-e $request_filename) {
                   #rewrite  ^(.*)$  /index.php?s=$1  last;
                   rewrite  ^/(.*)$  /index.php/$1  last;
                }
       }
        
        location ~ \.php {
            root /data/project/;
            fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
            
            set $path_info "";
            set $real_script_name $fastcgi_script_name;
            if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
                set $real_script_name $1;
                set $path_info $2;
            }
            
            fastcgi_param SCRIPT_NAME $real_script_name;
            fastcgi_param PATH_INFO $path_info;    
        }
    }

server {
        listen 9002;
        server_name 127.0.0.1;
        #server_name dashboard.mobissp.com;
        index index.php;
        root /data/mobissp/mobissp_cmn/;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;
        #include /mnt/project/.htaccess;
    access_log /data/log/nginx/access.log;
    error_log /data/log/nginx/error.log;
        
        location / {                
                if (!-e $request_filename) {
                   #rewrite  ^(.*)$  /index.php?s=$1  last;
                   rewrite  ^/(.*)$  /index.php/$1  last;
                }
       }
        
        location ~ \.php {
            root /data/mobissp/mobissp_cmn/;
            fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
            
            set $path_info "";
            set $real_script_name $fastcgi_script_name;
            if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
                set $real_script_name $1;
                set $path_info $2;
            }
            
            fastcgi_param SCRIPT_NAME $real_script_name;
            fastcgi_param PATH_INFO $path_info;    
        }
    }

重启ngixn和php-fpm(php-fpm也一定要重启,否则配置有可能会无效);

关于php-fpm的重启方法:百度的资料如下:

  • php中php-fpm的重启、终止操作命令:查看php运行目录命令:whichphp/usr/bin/php查看php-fpm进程数:psaux|grep-cphp-fpm查看运行内存/usr/bin/php -i|grepmem重启php-fpm/etc/init.d/php-fpmrestart在phpinfo()输出内容可以看到php相关配置。LoadedConfigurationFile /etc/php.ini==================
  • php 中php-fpm 的重启、终止操作命令:

    查看php运行目录命令:
    which php
    /usr/bin/php

    查看php-fpm进程数:
    ps aux | grep -c php-fpm

    查看运行内存
    /usr/bin/php  -i|grep mem

    重启php-fpm
    /etc/init.d/php-fpm restart

    在phpinfo()输出内容可以看到php相关配置。
    Loaded Configuration File /etc/php.ini

    ==============================

    首先要找到php-fpm.conf配置文件,查看pid的配置路径(不是安装路径),然后把下面对应的地方改掉才能正常执行。

    [[email protected] ~]# ps aux | grep php-fpm   
    root     11799  0.0  0.0 103248   880 pts/0    S+   13:51   0:00 grep --color php-fpm
    root     11973  0.0  0.0 417748   964 ?        Ss   Jun01   0:20 php-fpm: master process (/etc/php-fpm.conf)

    cat /etc/php-fpm.conf
    看到
    pid = /var/run/php-fpm/php-fpm.pid

    php-fpm 启动:
    /usr/local/php/sbin/php-fpm
    php-fpm 关闭:
    kill -INT `cat /var/run/php-fpm/php-fpm.pid`
    php-fpm 重启:
    kill -USR2 `cat /var/run/php-fpm/php-fpm.pid`

    查看php-fpm进程数:
    ps aux | grep -c php-fpm

    =============================

    [[email protected] ~]# find / -name 'php-fpm' -type d
    /var/log/php-fpm
    /var/run/php-fpm

    用这个find命令查找出来的路径是不对的

     which php
    /usr/bin/php

    shell脚本重启:

    #!/bin/bash
    # @create by jbxie 2014-02-10
    cat /opt/php-5.3.6p2/var/run/php-fpm.pid |xargs kill -USR2

    shell脚本暂停:

    #!/bin/bash
    # @create by jbxie 2014-02-10
    cat /opt/php-5.3.6p2/var/run/php-fpm.pid |xargs kill -QUIT

猜你喜欢

转载自blog.csdn.net/shj_php/article/details/82965338
今日推荐