nginx域名配置

nginx域名配置

php中,http配置

server {
        listen       80;
        server_name  ####你的域名#######;
        root         #######你的项目目录#########;
        client_max_body_size  1000m;
        location / {
            index  index.html index.php;
            try_files $uri $uri/ /index.php?$query_string;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            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;
        }
}

php中,https配置


server {
        listen       443 ssl;
        server_name  ####你的域名#######;
        root         #######你的项目目录#########;
        client_max_body_size  1000m;
        ssl_certificate     /cert/fairy-card/4194999_fairy-card.qsqwei.com.pem;
        ssl_certificate_key /cert/fairy-card/4194999_fairy-card.qsqwei.com.key;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        location / {
            index  index.html index.php;
            try_files $uri $uri/ /index.php?$query_string;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            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;
        }
}

域名重定向

server {
        listen       80;
        server_name  #####需要重定向的域名########;
        return 301 https://$host$request_uri;
}

你可能感兴趣的:(服务器)