### 实现虚拟主机
#### Step 1:准备工作
~~~
# ifconfig eth0:0 192.168.111.20
~~~
1. 建立两个站点目录
~~~
# mkdir /website1
# mkdir /website2
~~~
2. 建立两个存放日志的目录
~~~
# mkdir /var/log/nginx/website1
# mkdir /var/log/nginx/website2
~~~
3. 创建两个测试页
~~~
# echo "This is website1" >/website1/index.html
# echo "This is website2" >/website2/index.html
~~~
#### Step 2:修改配置文件
原有的配置文件中默认有一个server节点,修改一下,然后再添加一个server节点
~~~
server {
listen 192.168.111.10:80;
server_name localhost;
#charset koi8-r;
access_log /var/log/nginx/website1/access.log;
error_log /var/log/nginx/website1/error.log;
location / {
root /website1;
index index.html index.htm;
}
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;
}
}
server {
listen 192.168.111.20:80;
server_name localhost;
#charset koi8-r;
access_log /var/log/nginx/website2/access.log;
error_log /var/log/nginx/website2/error.log;
location / {
root /website2;
index index.html index.htm;
}
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;
}
}
~~~
此文件在Nginx安装目录下的conf里面的nginx.conf里面修改
#### Step 3:使用 ./nginx -s reload重新装在配置
在终端里面进入到nginx目录下的sbin,然后使用: `./nginx -s reload` 命令重载。
* * * * *
https://www.cnblogs.com/Brad-Lee/p/6258693.html
- 目录
- W3School
- 工具
- 手册
- 实验
- 慕课
- Linux软件安装管理
- RPM包安装
- yum安装
- Linux系统管理
- ps_mem
- uname
- CentOS版本
- Linux服务管理
- Linux权限管理
- Linux 权限控制的基本原理
- Linux网络管理
- Linux计划任务
- Crontab
- 任务启停
- 综合用例
- 间隔任务
- 一次任务
- 跨天任务
- 输出重定向
- Crontab任务权限
- 多任务
- 表达式
- 视频教程
- 不知疲倦的时间表
- 发送邮件
- nginx
- nginx入门到实践
- Nginx配置Web服务器
- 查看进程
- 配置步骤
- nginx升级
- 脚本升级
- systemctl 命令完全指南
- Linux 软件安装目录
- 查看文件安装路径
- 书籍
- 《Linux Shell脚本攻略》
- 《循序渐进Linux》
- 课程
- Linux典型应用
- 网址
- 通信
- MySQL开启远程连接
- 防火墙
- 安全组规则
- Mailx
- 介绍
- 安装
- 配置
- 发送邮件
- 163_email
- 安全
- Linux中root账号和普通账号有什么区别,root账号为什么不能删除?
- chmod改变文件权限
- SELinux入门