Ningx 80 端口 配置文件
server {
    #监听端口
    listen       80;
    #域名
    server_name  www.abc.com abc.com;
    #首页默认index.html文件  
    index index.html index.htm index.php;
    #项目路径
    root  /apps/www/html;
    #访问不带www的,默认跳转到www
    if ($http_host !~ "^www.abc.com$") {
        rewrite ^(.*) http://www.abc.com$1 permanent;
    }
    #图片放盗链
    location ~* \.(gif|jpg|png|bmp|zip|pdf)$ {
        valid_referers none blocked *.abc.com;
        if ($invalid_referer) {
                return 403;
         }      
    }    
    #nginx 缓存文件7天
    location ~ .*\.(?:jpg|jpeg|gif|png|ico|cur|gz|svg)$
    {
        expires      7d;
    }   
    #缓存css js
    location ~ .*\.(?:js|css)$
    {
        expires      7d;
    }   
    #隐藏index.php
    location / {
        if (!-e  $request_filename) {
                rewrite  ^/(.*)$  /index.php/$1  last;
                break;
        }       

       index  index.php;

    }  
    #解析php 文件
    location ~ \.php {

       fastcgi_pass   127.0.0.1:9000;

        fastcgi_index  index.php;

        set $real_script_name $fastcgi_script_name;
        if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
                set $real_script_name $1;
                set $path_info $2;
        }
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $real_script_name;
        fastcgi_param PATH_INFO $path_info;
        include        fastcgi_params;
    }
80 端口 和 443 端口并存,(http和https共用)
server {
    listen       80;
    listen       443 ssl;
    server_name  www.abc.com;
    index index.html index.htm index.php;
    root  /apps/web/www;

    client_max_body_size 20m;

    #ssl on;
    #nginx秘钥
    ssl_certificate   /etc/nginx/ssl/abc.pem;
    ssl_certificate_key  /etc/nginx/ssl/abc.key;
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    #禁止浏览器地址访问svn文件
    location ~ ^(.*)\/\.svn\/  {
        return 404;
    }
    #隐藏index.php
    location / {
        index  index.php index.html index.htm;
        #如果请求既不是一个文件,也不是一个目录,则执行一下重写规则
        if (!-e $request_filename)
        {
            #地址作为将参数rewrite到index.php上。
            rewrite ^/(.*)$ /index.php?s=$1;
            #若是子目录则使用下面这句,将subdir改成目录名称即可。
            #rewrite ^/admin/(.*)$ /admin/index.php?s=$1;
        }
    }
    #解析php
    location ~ \.php {

       fastcgi_pass   127.0.0.1:9000;

        fastcgi_index  index.php;

        set $real_script_name $fastcgi_script_name;
        if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
                set $real_script_name $1;
                set $path_info $2;
        }
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $real_script_name;
        fastcgi_param PATH_INFO $path_info;
        include        fastcgi_params;
        fastcgi_read_timeout 3600;
    }
}

php使用生成器读取超大文件

<?php function getLines($file) { $f = fopen($file, 'r'); try { while ($line = fgets($f)) { yield $line; ...

阅读全文

php获取字符串里面的图片,xpath方式

代码 <?php $html = <<<str <html> <head> <title>123</title> </head> <body> <img src=&quo...

阅读全文

Thinkphp5 in查询结果按照in里面的顺序排

或许有人会注意过,但我以前真不知道 SQL: select * from table where id IN (3,6,9,1,2,5,8,7); 这样的情况取出来后,其实,id还是按1,2,3,4,5,6,7,8,9,排序...

阅读全文

评论已经关闭。