码迷,mamicode.com
首页 > 其他好文 > 详细

nginx 简单配置

时间:2018-06-03 14:33:30      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:real   目录   stat   AC   main   root   tps   log   man   

https的配置方法
#这个是接口文档的----------------------------------
server {
#侦听80端口
listen 80;
#定义使用 www.nginx.cn访问
server_name tapi.***.net;

 

rewrite ^(.*) https://$server_name$1 permanent;
}
#微信项目 https配置
server {

 

listen 443 ssl;
server_name tapi.m***.net;

 

ssl_certificate /etc/nginx/ssl_key/2147197624dd932.pem;
ssl_certificate_key /etc/nginx/ssl_key/2147197dd410932.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;



#定义服务器的默认网站根目录位置
root /usr/share/nginx/html/api/public;
 
#设定本虚拟主机的访问日志
# access_log logs/nginx.access.log main;
 
#默认请求
 
location / {
root
/usr/share/nginx/html/api/public;
index
index.html index.htm index.php;
#去除index.php用的
#方法1----
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}

 

#如果文件不存在则尝试TP解析 (方法2)
# try_files $uri /index.php$uri;
}
 
# 定义错误提示页面
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
 
# #静态文件,nginx自己处理
# location ~ ^/(images|javascript|js|css|flash|media|static)/ {
 
# #过期30天,静态文件不怎么更新,过期可以设大一点,
# #如果频繁更新,则可以设置得小一点。
# expires 30d;
# }
 
#PHP 脚本请求全部转发到 FastCGI处理. 使用FastCGI默认配置.
 
location ~ \.php {
root /usr/share/nginx/html/api/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;

 

# set $path_info "";
# 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$real_script_name;
# fastcgi_param SCRIPT_NAME $real_script_name;
# fastcgi_param PATH_INFO $path_info;

 

fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
 
#禁止访问 .htxxx 文件
location ~ /.ht {
deny all;
}
}
 
普通的80端口配置方法——————————
# #这个是接口文档的----------------------------------
# server {
# #侦听80端口
# listen 80;
# #定义使用 www.nginx.cn访问
# server_name test.m***.net;
 
# #定义服务器的默认网站根目录位置
# root /usr/share/nginx/html/index/public;
 
# #设定本虚拟主机的访问日志
# # access_log logs/nginx.access.log main;
 
# #默认请求
 
# location / {
# root
# /usr/share/nginx/html/index/public;
# index
# index.html index.htm index.php;
# #去除index.php用的
# #方法1----
# if (!-e $request_filename) {
# rewrite ^(.*)$ /index.php?s=/$1 last;
# break;
# }

# #如果文件不存在则尝试TP解析 (方法2)
# # try_files $uri /index.php$uri;
# }
 
# # 定义错误提示页面
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
 
# # #静态文件,nginx自己处理
# # location ~ ^/(images|javascript|js|css|flash|media|static)/ {
 
# # #过期30天,静态文件不怎么更新,过期可以设大一点,
# # #如果频繁更新,则可以设置得小一点。
# # expires 30d;
# # }
 
# #PHP 脚本请求全部转发到 FastCGI处理. 使用FastCGI默认配置.
 
# location ~ \.php {
# root /usr/share/nginx/html/index/public;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# include fastcgi_params;
# # set $path_info "";
# # 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$real_script_name;
# # fastcgi_param SCRIPT_NAME $real_script_name;
# # fastcgi_param PATH_INFO $path_info;

# fastcgi_split_path_info ^(.+\.php)(/.*)$;
# fastcgi_param PATH_INFO $fastcgi_path_info;
# }
 
# #禁止访问 .htxxx 文件
# location ~ /.ht {
# deny all;
# }
 
# }

nginx 简单配置

标签:real   目录   stat   AC   main   root   tps   log   man   

原文地址:https://www.cnblogs.com/cbywan/p/9128542.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!