Detailed configuration Phalcon frame Nginx

Detailed configuration Phalcon frame Nginx

  • Local test environment configuration
server {
        listen       8080;#监听 80 端口,接收http请求
        server_name  ares.com ; #就是网站域名
        root   "D:\phpstudy\myphp_www\PHPTutorial\WWW\project\aresflare\public";# 准备存放代码工程的路径
	index       index.php index.html index.htm;
    charset     utf-8;
    #路由到网站根目录 www.test.com 时候的处理
       location / {
        try_files $uri $uri/ /index.php?_url=$uri&$args;
    }
    #当请求网站下 php 文件的时候,反向代理到 php-fpm
        location ~ \.php(.*)$ {
            fastcgi_pass   127.0.0.1:9000; # tcp 方式,php-fpm 监听的 IP 地址和端口
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params; #加载 nginx 的 fastcgi 模块
        }
}
  • BT configuration
server
{
    listen 80;
    server_name test.zshengt.com;
    index index.php index.html index.htm default.php default.htm default.html;
    root /www/wwwroot/test.zshengt.com/public;
    
    #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
    #error_page 404/404.html;
    #SSL-END
    
    #ERROR-PAGE-START  错误页配置,可以注释、删除或修改
    error_page 404 /404.html;
    error_page 502 /502.html;
    #ERROR-PAGE-END
    
    #PHP-INFO-START  PHP引用配置,可以注释或修改
    include enable-php-72.conf;
    #PHP-INFO-END
    
    #REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
    include /www/server/panel/vhost/rewrite/test.zshengt.com.conf;
    #REWRITE-END
    
    #禁止访问的文件或目录
    location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
    {
        return 404;
    }
    
    #一键申请SSL证书验证目录相关设置
    location ~ \.well-known{
        allow all;
    }
    
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
        expires      30d;
        error_log off;
        access_log off;
    }
    
    location ~ .*\.(js|css)?$
    {
        expires      12h;
        error_log off;
        access_log off; 
    }
    
     try_files $uri $uri/ @rewrite;

    location @rewrite {
        rewrite ^(.*)$ /index.php?_url=$1;
    }

    location ~ \.php {
        # try_files    $uri =404;

        fastcgi_index  /index.php;
        fastcgi_pass   127.0.0.1:9000;

        include fastcgi_params;
        fastcgi_split_path_info       ^(.+\.php)(/.+)$;
        fastcgi_param PATH_INFO       $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
        root /var/www/$host/public;
    }
    
    access_log  /www/wwwlogs/test.zshengt.com.log;
    error_log  /www/wwwlogs/test.zshengt.com.error.log;
}

Guess you like

Origin blog.csdn.net/qq_41049126/article/details/89515329