首先,准备好配置环境:最少开三台服务器,并下编译好nginx命令,做好映射。
先在主配置服务器配置文件:
vim /usr/local/nginx/conf/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime,types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream dafault_server {
server 192.168.126.145:80 weight;
}
upstream static_server {
server 192.168.126.147:8 weight;
}
server {
listen 80;
server_name www.yunjisuan.com;
location / {
proxy_pass http://default_server;
}
location /static/ {
proxy_pass http://static_server;
}
}
}
将静态图片放入静态服务器中:
配置动态服务器:
vim /usr/local/nginx/html/www/index.html
<title>welcome to beijing</title>
<hl>zuida</hl>
<h4>zuixiao</h4>
<img src="C:\Users\Administrator\Desktop(图片存储路径)">
原文地址:https://www.cnblogs.com/mashuang/p/10065621.html