【服务器】nginx二级域名配置
关于Nginx二级域名的配置,网上有好多文章和教程(好多都一样的),然而发现有太多复制粘贴且不适用的,这里安利一个炒鸡简单的方式配置nginx二级域名的方法。
首先介绍使用到的服务器的环境LNMP环境(其中nginx版本1.4.6,服务器是ubuntu 14.04的),可能因为版本问题有配置的方式和文件的位置有细微不同。
服务商域名配置
我们先去域名提供商哪里去将我们的域名和我们的主机(公网IP)匹配上
开始配置顶级域名
这个配完直接访问域名验证是否可以正常访问到我们的主机(这里配置完成通常在1分钟左右生效),完成之后开始配置二级域名
同样的道理,这里配置完,验证一下能否正常访问
Nginx服务器配置
include /etc/nginx/sites-enabled/*;
# server {
# ...
# }
# statements for each of your virtual hosts to this file
# '#'在linux中通常表示注释当行,这里面我们发现Google的Nginx还是挺贴心的,给出了解释和参考文档地址,如果我们的服务器有https访问得需求,也可以在这个文件中配置
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}
#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 /usr/share/nginx/html;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
# fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# With php5-cgi alone:
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
# fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$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;
#}
}
#MY CONFIG START
server
{
listen 80;
server_name qq.com;
root /usr/share/nginx/html;
index index.php index.html index.htm;
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
}
#不要问我为什么,我是抄上面那个默认的server的,错不了,手动滑稽
server
{
listen 80;
server_name blog.qq.com;
root /usr/share/nginx/html/blog;
index index.php index.html index.htm;
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
}
#MY CONFIG END
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# root html;
# index index.html index.htm;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
#
# root html;
# index index.html index.htm;
#
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
#
# ssl_session_timeout 5m;
#
# ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
# ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
# ssl_prefer_server_ciphers on;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
【服务器】nginx二级域名配置相关推荐
- nginx二级域名配置阿里云免费SSL证书浏览器提示不安全
阿里云免费SSL证书: 由图可知SSL证书只作用于 xxx.top 与 www.xxx.top 一个主域名和一个子域名! 如果你用nginx添加证书至 xxx.xxx.top 二级域名, 则需要购买通 ...
- Nginx二级域名及多Server反向代理配置
Nginx强大的正则表达式支持,可以使server_name的配置变得很灵活,如果你要做多用户博客,那么每个用户拥有自己的二级域名也就很容易实现了. 注:nginx反向代理同一ip多个域名,给head ...
- Centos7下Nginx代理和二级域名配置
Centos7下Nginx代理和二级域名配置 nginx的安装步骤请阅读上一篇文章. 一.nginx的反向代理配置 编辑nginx的配置文件(找到自己的配置文件) vim /usr/local/ngi ...
- 【Nginx】关于二级域名配置https
需求 域名fangkang.top 解析了blog.fangkang.top二级域名 配置blog.fangkang.top为https访问 解决方案 先来解析域名 这是解析的俩组域名,但是只给不带w ...
- linux dns中文域名,Nginx 中文域名配置详解及实现
Nginx中文域名配置 Nginx虚拟主机上绑定一个带中文域名,比如linuxeye.中国,浏览器不能跳转. why? 因为操作系统的核心都是英文组成,DNS服务器的解析也是由英文代码交换,所以DNS ...
- 服务器添加二级域名网站教程,服务器添加二级域名
服务器添加二级域名 内容精选 换一换 本节介绍网站使用华为云CDN做内容分发加速,且网站域名解析至中国大陆节点服务器的网站备案场景.如图1所示:① 企业A在华为云CDN添加加速域名(www.pictu ...
- 阿里云服务器 实现二级域名并对应不同项目 即 不同目录
参考网址 https://blog.csdn.net/m_nanle_xiaobudiu/article/details/80726900 1 服务器 解析 二级域名 2 在 nginx/conf.d ...
- linux nginx 域名转发,nginx域名转发|nginx域名配置|nginx多域名配置的方法
nginx域名转发只需要在nginx.cnf文件里面加入nginx域名配置信息即可,下面是nginx的配置文件,包括了nginx多域名配置方法,配置信息如下,只需要在nginx的http里面加入ser ...
- 二级域名配置以及nginx解析二级域名到html页面
此文章适合发布前端项目使用,如果想要配置二级域名到后端服务,可以查看这篇文章:nginx配置二级域名 - 简书 在阿里云上配置二级域名,就是添加一条记录就可以了,超级简单,不懂的可以看后面的解释说明, ...
最新文章
- 教机器遗忘或许比学习更重要:让AI健忘的三种方式
- 【学术相关】研究生通常都有怎样的作息时间呢?
- 跨域学习笔记2--WebApi 跨域问题解决方案:CORS
- 笔试面试收获(持续更新中)
- OsharpNS轻量级.net core快速开发框架简明入门教程-基于Osharp实现自己的业务功能...
- java 日历纪实,日历表--案例 (转载)
- 【Java每日一题】20161124
- Python基础——pickle(保存与提取数据)
- vb杨辉三角代码编写_杨辉三角算法集锦vb
- java混淆器最好_使用混淆器,保护你的java程序
- Python初学者必刷的五个项目,你做过几个?
- 江苏省计算机一级考试难度,浅谈江苏省计算机等级考试(一级除外)
- 【OpenCV】将图片黑色背景变成透明背景
- Java根据日利率计算等额本息每月还款
- 【初识C语言】从头到尾了解C语言这一篇足矣
- nagios的nsca被动模式及自动添加nsca服务
- 如何高效进行出货复核作业,提升出货准确率?
- 企业推广品牌网络营销占比必须重视哪些流程
- 工业大数据分析,主要有哪些应用?
- sql和python还有c语言_TIOBE 4 月排行榜:SQL 进入前十,Python 继续攀升
热门文章
- 服务器版本与操作系统兼容性,服务器跟操作系统兼容性
- window 查看文件大小工具(TreeSize)
- 余额宝收益率跌破5% 落后银行类宝宝产品
- echarts添加辅助线markLine
- sip注册流程 一步一光年_[已经解决]电信的SIP在网络电话上始终不能注册成功,何故?...
- 使用jTessBoxEditorFX训练Tesseract-OCR 简单教程
- GMGC数娱节前瞻,好玩好看有逼格
- 产品经理应该具备的技能
- 少儿编程Scratch真的不值得一学吗?
- 中国安防行业十年报告:产值增涨四倍!双巨头全球称雄