1.制作静态web服务器
注意:这个实验需要虚拟机server1和server2,其中server1作为nginx服务器,server2安装apache服务
step1 修改配置文件
在server1中:
cd /usr/local/nginx
cd conf/
vim nginx.conf
17 http {
18 include mime.types;
19 default_type application/octet-stream;
20 upstream westos {
21 server 172.25.254.2:80; #代理哪个服务器就写哪个服务器的ip
119 server {
120 listen 80;
121 server_name www.westos.org;
122 location / {
123 proxy_pass http://westos;
124 }
125 }
nginx -t #语法检测
nginx -s reload #在不暂停服务的情况下重新加载
step2 写默认发布页面
在server2中:
yum install httpd -y
vim /var/www/html/index.html
systemctl restart httpd
step3 添加解析
在客户端(真机)中:
vim /etc/hosts
172.25.254.1 www.westos.org
step4 测试
curl www.westos.org