编程技术分享平台

网站首页 > 技术教程 正文

关于TP3.2 nginx下配置子域名(nginx 配置php)

xnh888 2024-09-12 22:29:59 技术教程 37 ℃ 0 评论
  1. nginx.conf

    server {

    listen 80;

    server_name admin.xxx.com;

    set $rootpath /data/wwwroot/;

    client_max_body_size 128M;

    access_log /var/log/nginx/log/www.xxx.com.access.log;

    location / {

    root $rootpath;

    #下面这段伪静态支持

    if (!-e $request_filename){

    #rewrite ^/(.*) /index.php last;

    rewrite ^(.*)$ /index.php?s=$1 last;

    break;

    }

    #上面这段伪静态支持

    index index.php index.html index.htm;

    }

    #error_page 404 /404.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;

    }

    location ~ \.php$ {

    root $rootpath;

    fastcgi_pass 127.0.0.1:9000;

    fastcgi_index index.php;

    fastcgi_param _FILENAME $rootpath$fastcgi__name;

    include fastcgi_params;

    }

    location ~ /\.ht {

    deny all;

    }

    }

  2. TP框架入口

    .htaccess文件 //默认自带的即可

    <IfModule mod_rewrite.c>

    Options +FollowSymlinks

    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

    </IfModule>

  3. TP框架App/commcon/conf文件

    'APP_SUB_DOMAIN_DEPLOY' => 0, // 开启子域名或者IP配置

    'APP_SUB_DOMAIN_RULES' => array(

    'admin' => 'Admin', // 后台访问网站

    ),

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表