zl程序教程

您现在的位置是:首页 >  大数据

当前栏目

Nginx网站架构实战——03、nginx虚拟主机配置

配置架构Nginx网站 实战 03 虚拟主机
2023-06-13 09:15:45 时间

Nginx网站架构实战——01、Nginx介绍及编译安装:传送门

Nginx网站架构实战——02、Nginx信号量:传送门

基于域名访问

[root@tiejiang nginx]# mkdir z.com #在nginx的家目录创建z.com文件夹

[root@tiejiang nginx]# vim z.com/index.html #在z.com里面创建一个默认首页

 amp;lt;html amp;gt;

 this is z.com

 amp;lt;/html amp;gt;

[root@tiejiang nginx]# vim conf/nginx.conf

 server {

 listen 80; #监听的端口

 server_name z.com; #访问的地址

 location / { 

 root z.com; #相对路径是nginx的根目录

 index index.html; #访问z.com的默认页面

[root@tiejiang nginx]# ./sbin/nginx -s reload #重新加载一下配置文件

Nginx网站架构实战——03、nginx虚拟主机配置

基于端口访问

[root@tiejiang nginx]# cat /var/www/html/index.html

 amp;lt;html amp;gt;

 wecome to z.com:8080 admin panel

 amp;lt;/html amp;gt;

[root@tiejiang nginx]# vim conf/nginx.conf

 server {

 listen 8080; #用的是8080的端口来访问

 server_name 192.168.0.11; #访问的地址

 location / {

 root /var/www/html/; #网页程序的绝对路径

 index index.html;

[root@tiejiang nginx]# ./sbin/nginx -s reload

Nginx网站架构实战——03、nginx虚拟主机配置

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/54287.html

nginx