zoukankan      html  css  js  c++  java
  • 003.thinkPHP-nginx部署-nginx.conf文件配置

    #user  nobody;
    worker_processes  1;
    
    #error_log  logs/error.log;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;
    
    #pid        logs/nginx.pid;
    
    
    events {
        worker_connections  1024;
    }
    
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
    
        #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
        #                  '$status $body_bytes_sent "$http_referer" '
        #                  '"$http_user_agent" "$http_x_forwarded_for"';
    
        #access_log  logs/access.log  main;
    
        sendfile        on;
        #tcp_nopush     on;
    
        #keepalive_timeout  0;
        keepalive_timeout  65;
    
        #gzip  on;
    
        server {
            listen       80;
            root  /usr/local/nginx/html/threeholePHP;
            server_name  localhost;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
    
            location / {
                root   html;
                index  index.html index.htm;
                if (!-e $request_filename){
                     rewrite ^/(.*)$ /index.php?s=$1 last;
                }
    
            }
    
            #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   html;
            }
    
            # proxy the PHP scripts to Apache listening on 127.0.0.1:80
            #
            #location ~ .php$ {
            #    proxy_pass   http://127.0.0.1;
            #}
    
            # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
            #
            #location ~ .php$ {
            #    root           html;
            #    fastcgi_pass   127.0.0.1:9000;
            #    fastcgi_index  index.php;
            #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            #    include        fastcgi_params;
            #}
    
            # deny access to .htaccess files, if Apache's document root
            # concurs with nginx's one
            #
            #location ~ /.ht {
            #    deny  all;
            #}
            location ~ .php {
                #root           html;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
                #fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                #fastcgi_split_path_info ^(.+.php)(.*)$;
                #fastcgi_param PATH_INFO $fastcgi_path_info;
                #include        fastcgi_params;
                
                #加载Nginx默认"服务器环境变量"配置 
                include        fastcgi.conf; 
                   
                #设置PATH_INFO并改写SCRIPT_FILENAME,SCRIPT_NAME服务器环境变量 
                set $fastcgi_script_name2 $fastcgi_script_name; 
                if ($fastcgi_script_name ~ "^(.+.php)(/.+)$") { 
                    set $fastcgi_script_name2 $1; 
                    set $path_info $2; 
                } 
                fastcgi_param   PATH_INFO $path_info; 
                fastcgi_param   SCRIPT_FILENAME   $document_root$fastcgi_script_name2; 
                fastcgi_param   SCRIPT_NAME   $fastcgi_script_name2; 
            
            }    
            
        }
    
    
        # another virtual host using mix of IP-, name-, and port-based configuration
        #
        #server {
        #    listen       8000;
        #    listen       somename:8080;
        #    server_name  somename  alias  another.alias;
    
        #    location / {
        #        root   html;
        #        index  index.html index.htm;
        #    }
        #}
    
    
        # HTTPS server
        server {
            listen 443 ssl;
            #配置HTTPS的默认访问端口为443。
            #如果未在此处配置HTTPS的默认访问端口,可能会造成Nginx无法启动。
            #如果您使用Nginx 1.15.0及以上版本,请使用listen 443 ssl代替listen 443和ssl on。
            server_name www.lognet.top; #需要将yourdomain.com替换成证书绑定的域名。
            root html;
            index index.html index.htm;
            ssl_certificate cert/5019243_www.lognet.top.pem;  #需要将cert-file-name.pem替换成已上传的证书文件的名称。
            ssl_certificate_key cert/5019243_www.lognet.top.key; #需要将cert-file-name.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; #表示使用的TLS协议的类型。
            ssl_prefer_server_ciphers on;
            location / {
                root html;  #站点目录。
                index index.html index.htm;
            }
    }
    
    }

    nginx重启

    ps -ef|grep nginx
    kill -9 30297
    cd /usr/local/nginx/sbin/
    ./nginx

  • 相关阅读:
    计算广告(1):计算广告基础
    shell定时任务
    shell脚本运行报错:-bash: xxx: /bin/sh^M: bad interpreter: No such file or directory
    spark文件读取与保存(scala实现)
    spark中的共享变量(广播变量和累加器)
    spark基本概念与运行架构
    用二维数组输出螺旋方阵(JAVA实现)
    InputStream、InputStreamReader和BufferedReader
    Arrays.sort()自定义排序的实现
    BufferedReader和Scanner
  • 原文地址:https://www.cnblogs.com/star521/p/14244347.html
Copyright © 2011-2022 走看看