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

山西网站制作公司定向推广

山西网站制作公司,定向推广,做网站维护,多米诺网站建设服务一.静态页面 1.更改页面内容 2.更改配置文件 3.测试 二.虚拟主机配置 1.基于IP (1)在html目录下新建目录存放测试文件 (2)修改nginx.conf文件,在htttp模块中配置两个server模块分别对应两个IP (3&am…

一.静态页面

1.更改页面内容

2.更改配置文件

3.测试

 二.虚拟主机配置

1.基于IP

(1)在html目录下新建目录存放测试文件

(2)修改nginx.conf文件,在htttp模块中配置两个server模块分别对应两个IP

(3)测试

2.基于端口

(1)创建测试界面

(2)同样在http模块中添加server模块,注意工作目录的变动

(3)测试

 3.基于域名

(1)在前面基于IP的基础上添加server_name一行即可

(2)修改/etc/hosts文件

(3)测试

三.nginx错误日志和访问日志配置

1. 在server模块中指定日志类型和日志存放目录即可

2.测试两边后查看


一.静态页面

要关闭apache的httpd

[root@localhost conf]# systemctl status httpd.service 
● httpd.service - The Apache HTTP ServerLoaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)Active: inactive (dead)Docs: man:httpd(8)man:apachectl(8)

1.更改页面内容

找到自己的nginx安装目录里的html目录,修改index.html

[root@localhost html]# pwd
/usr/local/src/nginx-1.22.0/html
[root@localhost html]# cat index.html 
<h1>nginx</h1>

2.更改配置文件

 nginx安装目录里的nginx.conf文件

[root@localhost conf]# pwd
/usr/local/src/nginx-1.22.0/conf
[root@localhost conf]# vim nginx.conf

找到serve内的区块位置,更改工作目录和指定html文件 

server {listen       80;server_name  localhost;#charset koi8-r;#access_log  logs/host.access.log  main;location / {root   /usr/local/src/nginx-1.22.0/html;  #你的html文件存放目录index  index.html;   #如果前面页面文件是其它名字,这里要更改一致}#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;}
}
[root@localhost conf]# systemctl restart nginx

3.测试

 二.虚拟主机配置

1.基于IP

(1)在html目录下新建目录存放测试文件

[root@localhost html]# ll
total 8
-rw-r--r-- 1 1001 1001 497 May 24  2022 50x.html
-rw-r--r-- 1 1001 1001  15 Aug 10 10:13 index.html
drwxr-xr-x 2 root root  43 Aug 10 11:53 ip
drwxr-xr-x 2 root root   6 Aug 10 11:51 port
[root@localhost html]# pwd
/usr/local/src/nginx-1.22.0/html
[root@localhost html]# cat ip/index.html ip/index1.html 
190
195

(2)修改nginx.conf文件,在htttp模块中配置两个server模块分别对应两个IP

server {listen 192.168.2.190;location / {root /usr/local/src/nginx-1.22.0/html/ip;index index.html index.htm;}}server {listen 192.168.2.195;location / {root /usr/local/src/nginx-1.22.0/html/ip;index index1.html index.htm;}}
[root@localhost conf]# systemctl restart nginx

(3)测试

 

2.基于端口

(1)创建测试界面

[root@localhost html]# cat port/index.html port/index1.html 
8090
8099

(2)同样在http模块中添加server模块,注意工作目录的变动

server {listen 8090;location / {root /usr/local/src/nginx-1.22.0/html/port;index index.html index.htm;}}server {listen 8099;location / {root /usr/local/src/nginx-1.22.0/html/port;index index1.html index.htm;}}
[root@localhost conf]# systemctl restart nginx

(3)测试

 3.基于域名

(1)在前面基于IP的基础上添加server_name一行即可

server {listen 192.168.2.190;server_name www.aabb.com;location / {root /usr/local/src/nginx-1.22.0/html/ip;index index.html index.htm;}}server {listen 192.168.2.195;server_name www.llss.com;location / {root /usr/local/src/nginx-1.22.0/html/ip;index index1.html index.htm;}}
[root@localhost conf]# systemctl restart nginx

(2)修改/etc/hosts文件

Linux

[root@localhost conf]# vim /etc/hosts
192.168.2.190 www.aabb.com
192.168.2.195 www.llss.com

windows

通过powershell使用notepad修改hosts文件

Windows PowerShell
版权所有(C) Microsoft Corporation。保留所有权利。安装最新的 PowerShell,了解新功能和改进!https://aka.ms/PSWindowsPS C:\WINDOWS\system32> cd .\drivers\etc\PS C:\WINDOWS\system32\drivers\etc> notepad .\hosts
PS C:\WINDOWS\system32\drivers\etc>

(3)测试

三.nginx错误日志和访问日志配置

1. 在server模块中指定日志类型和日志存放目录即可

2.测试两边后查看

[root@localhost logs]# cat access.log 
192.168.2.2 - - [10/Aug/2023:14:06:00 +0800] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.200"
192.168.2.2 - - [10/Aug/2023:14:06:00 +0800] "GET /favicon.ico HTTP/1.1" 404 555 "http://192.168.2.190/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.200"
[root@localhost logs]# cat error.log 
2023/08/10 14:06:00 [error] 59751#59751: *1 open() "/usr/local/src/nginx-1.22.0/html/ip/favicon.ico" failed (2: No such file or directory), client: 192.168.2.2, server: www.aabb.com, request: "GET /favicon.ico HTTP/1.1", host: "192.168.2.190", referrer: "http://192.168.2.190/"
[root@localhost logs]# pwd
/usr/local/src/nginx-1.22.0/logs
http://www.dinnco.com/news/87523.html

相关文章:

  • 免费网站开发合同搜索引擎优化seo课程总结
  • 怎么样免费创建网站重庆seo海洋qq
  • 石家庄网站建设电话搜索引擎优化的目标
  • 怎么建立本地网站seo+网站排名
  • 然后做网站网站制作软件
  • 厦门做网站公司最新小组排名
  • 网站开发课程意见和建议百度推广云南总代理
  • 新网站 被百度收录软件开发流程
  • 国内做外贸的平台有哪些网站优化是做什么的
  • 做包装的网站网络营销推广的方式
  • 黄石做网站的什么是搜索引擎销售
  • 房地产手机端网站建设深圳优化seo
  • 宁德工程建设监督网站网店推广方式有哪些
  • 网站制作属于什么品牌seo排名优化点击软件有哪些
  • 网络规划设计师专项提升百度关键词优化公司哪家好
  • 如何申请小程序账号seo是什么意思啊
  • 无锡网站制作启航好seo站长工具平台
  • discu论坛网站模板北京快速优化排名
  • 网站备案信息更改审核要多久徐州seo排名公司
  • php动态网页作业优化设计单元测试卷
  • 提供营销网站建设公司吴中seo页面优化推广
  • asp.net网站开发教程 pdf网站推广软件哪个最好
  • 昆明做网站哪家好百度网盘网页版登录入口官网
  • 有免费做海报的网站吗河南制作网站
  • 网站制作成功后怎么使用宣传平台有哪些
  • 银川做企业网站产品软文撰写
  • 做商城网站买多大的空间网站竞价推广
  • 商品推销关键词优化seo费用
  • 上海专业网站建设公seo数据优化
  • 网站建设目标责任软文推广营销服务平台