当前位置: 首页 > news >正文

宁波网站推广宣传网站推广的技巧

宁波网站推广宣传,网站推广的技巧,杭州网站建设 博客,WordPress网页加载时间虚拟主机 虚拟主机指的就是⼀个独⽴的站点,具有独⽴的域名,有完整的www服务,例如⽹站、FTP、邮件等 。Nginx⽀持多虚拟主机,在⼀台机器上可以运⾏完全独⽴的多个站点。⼀些草根流量站⻓,常会搭建个⼈站点进⾏资源分享交…

虚拟主机

虚拟主机指的就是⼀个独⽴的站点,具有独⽴的域名,有完整的www服务,例如⽹站、FTP、邮件等 。Nginx⽀持多虚拟主机,在⼀台机器上可以运⾏完全独⽴的多个站点。⼀些草根流量站⻓,常会搭建个⼈站点进⾏资源分享交流,并且可能有多个不同业务的站点,如果每台服务器只运⾏⼀个⽹站,那么将造成资源浪费,成本浪费。利⽤虚拟主机的功能,就不⽤为了运⾏⼀个⽹站⽽单独配置⼀个Nginx服务器,或是单独再运⾏⼀组Nginx进程。虚拟主机可以在⼀台服务器,同⼀个Nginx进程上运⾏多个⽹站。

搭建网站

搭建一个静态网站,修改nginx.conf,⾃上⽽下找到第⼀个server{}指令块, 修改如下
 server {listen 80;server_name localhost;#默认编码charset utf-8;# access_log logs/host.access.log  main;location / {#定义虚拟主机的资源目录,无论win或linux都要写成正斜杠root C:/Users/zhang/Desktop/new;#定义首页文件的名字index index.html index.htm;}}

执行命令 

// 检查配置是否正确
nginx -t
// 启动
nginx
// 重新加载Nginx配置文件
nginx -s reload

准备资源

访问localhost

访问静态资源

 

 nginx⽀持gzip对资源压缩传输,经过gzip压缩后的⻚⾯⼤⼩可以为原本的30%甚⾄更⼩,⽤户浏览体验会快很多


#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;gzip_http_version 1.1;gzip_comp_level 4;gzip_types text/plain application/javascriptapplication/x-javascript text/css application/xmltext/javascript application/x-httpd-php image/jpeg image/gifimage/png;server {listen 80;server_name localhost;#默认编码charset utf-8;# access_log logs/host.access.log  main;location / {#定义虚拟主机的资源目录,无论win或linux都要写成正斜杠root C:/Users/zhang/Desktop/new;#定义首页文件的名字index index.html index.htm;}}}

目录游览功能

修改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 {#监听的端口和iplisten 80;#主机域名server_name www.test1.com;charset utf-8;access_log logs/host.access.log;#url匹配location / {#HTML文件存放的目录root C:/Users/zhang/Desktop/new/web2;#开启目录索引功能autoindex on;#关闭详细文件大小统计,让文件大小显示MB,GB单位,默认为b; autoindex_exact_size off;#开启以服务器本地时区显示文件修改日期!  autoindex_localtime on;        }}}

 访问

基于IP多虚拟主机

修改 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;gzip_http_version 1.1;gzip_comp_level 4;gzip_types text/plain application/javascriptapplication/x-javascript text/css application/xmltext/javascript application/x-httpd-php image/jpeg image/gifimage/png;#第一个虚拟主机server {#监听的端⼝和iplisten 127.0.0.1:80;#主机域名server_name 127.0.0.1;charset utf-8;access_log logs/host.access.log;#url匹配location / {#HTML文件存放的目录root C:/Users/zhang/Desktop/new/web1;#默认首页文件,从左往右寻找,index.html或是index.htmindex index.html index.htm;}}#第二个虚拟主机server {listen 192.168.52.100:80;server_name 192.168.52.100;location / {index index.html index.htm;root C:/Users/zhang/Desktop/new/web2;}}
}

执行命令

#重载nginx
nginx -s reload

访问站点一

访问站点二

基于域名多虚拟主机

 基于多IP的虚拟主机可能会造成IP地址不⾜的问题,如果没有特殊需求,更常⽤的是基于多域名的形式。只需要你单独配置DNS服务器,将主机名对应到正确的IP地址,修改Nginx配置,可以识别到不同的主机即可,这样就可以使得多个虚拟主机⽤同⼀个IP,解决了IP不足的隐患。

打开C:\Windows\System32\drivers\etc,配置域名。 

修改 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;gzip_http_version 1.1;gzip_comp_level 4;gzip_types text/plain application/javascriptapplication/x-javascript text/css application/xmltext/javascript application/x-httpd-php image/jpeg image/gifimage/png;#第一个虚拟主机server {#监听的端?和iplisten 80;#主机域名server_name www.test1.com;charset utf-8;access_log logs/host.access.log;#url匹配location / {#HTML文件存放的目录root C:/Users/zhang/Desktop/new/web1;#默认首页文件,从左往右寻找,index.html或是index.htmindex index.html index.htm;}}#第二个虚拟主机server {listen 80;server_name www.test2.com;location / {index index.html index.htm;root C:/Users/zhang/Desktop/new/web2;}}
}

执行命令

#重载nginx
nginx -s reload

访问域名1

访问域名2

基于端口多虚拟机

基于端⼝的配置在⽣产环境⽐较少⻅,⽤于特殊场景,例如公司内部测试平台⽹站,使⽤特殊端⼝的后台,OA 系统、⽹站后台, CRM 后台等。

修改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;gzip_http_version 1.1;gzip_comp_level 4;gzip_types text/plain application/javascriptapplication/x-javascript text/css application/xmltext/javascript application/x-httpd-php image/jpeg image/gifimage/png;#第一个虚拟主机server {#监听的端口和iplisten 80;#主机域名server_name www.test1.com;charset utf-8;access_log logs/host.access.log;#url匹配location / {#HTML文件存放的目录root C:/Users/zhang/Desktop/new/web1;#默认首页文件,从左往右寻找,index.html或是index.htmindex index.html index.htm;}}#第二个虚拟主机server {listen 81;server_name www.test1.com;location / {index index.html index.htm;root C:/Users/zhang/Desktop/new/web2;}}
}

执行命令

#重载nginx
nginx -s reload

访问端口80

访问端口81

root和alias区别

1. Nginx的配置文件server中指定两个location执行,分别为root和alias的指令

location /test/{alias /www/test/;
}

按照上述配置,则访问/test/目录里面的文件时,nginx会去/www/test目录找文件

location /test/{root /www/test;
}

按照上述配置,则访问/test/目录下的文件时,nginx会去/www/test/test/目录下找文件

2.alias是一个目录别名的定义,root则是最上层目录的定义。

3,另一个区别是alias后面必须要用"/"结束,否则会找不到文件,而root则对"/"可有可无

4.不少人都有误区,认为root是指的/www/test目录下,但是应该是/www/test/test目录

http://www.hkea.cn/news/238904/

相关文章:

  • 网站建设服务怎么样近期国内热点新闻事件
  • 阿里巴巴网站国际站建设seo托管服务
  • 企业网站优化之如何做需求分析网奇seo赚钱培训
  • 施工企业会计制度收入确认规定百度自然排名优化
  • 校园网站建设意义网络营销的特点有哪些
  • 内江做网站哪里便宜google搜索关键词热度
  • 福建省建设银行招聘网站网络推广员压力大吗
  • 动态网站订单怎么做搜索引擎优化营销
  • html5行业网站最近有哪些新闻
  • 做网站业务的怎么寻找客户在哪里打广告效果最好
  • 广东深圳seo服务内容
  • 做网站怎么备案网络服务有限公司
  • 网站主页特效欣赏百度官网下载电脑版
  • php mysql开发网站开发任何小说都能搜到的软件
  • the7 wordpress主题宁波seo外包费用
  • 云南建筑培训网seo刷点击软件
  • 男女做暖网站h5页面制作平台
  • 可以做puzzle的网站百度关键词排名提升工具
  • 竞网网站建设南宁网站seo大概多少钱
  • 114黄页信息网宝鸡seo培训
  • 东南亚做棋牌网站挖掘爱站网
  • 中国工程建设招标网官方网站谷歌查询关键词的工具叫什么
  • wordpress管理员密码忘记成都seo招聘
  • 武汉企业建站系统模板下载官方正版百度
  • 上海做网站国际财经新闻
  • 用废旧盒子做家用物品网站seo排名工具
  • 企业铭做网站域名解析在线查询
  • 怎么注册自己的小程序网站优化分析
  • 荆州网站建设流程网站设计培训
  • 网站支付怎么做的seo职业技能培训班