文章目录
部署五个站点:
- www.xxx.com
- download.xxx.com
- upload.xxx.com
- blog.xxx.com
- zhihu.xxx.ccom
要求:
- 通过域名访问
- upload通过8080端口访问
- blog和zhihu要开启状态监控
- download和blog、zhihu的状态监控需要开启用户认证
- zhihu只允许当前私有网段可以访问,其他网段都不能访问
www站点
网站环境
#创建站点目录
mkdir -p /web/www
#创建站点文件
echo "hello web01" > /web/www/index.html
#修改文件归属
chown -R nginx.nginx /web
#开启nginx和php-fpm服务
systemctl start nginx php-fpm
配置文件内容
server{
server_name www.yjs.com;
listen 80;
root /web/www;
index index.html;
access_log logs/www-access.log;
error_log logs/www-error.log;
}
重启服务和修改hosts
systemctl restart nginx
C:\Windows\System32\drivers\etc
hosts文件:
.........
10.0.0.7 www.yjs.com
访问网站

download站点
网站环境
#创建站点目录
mkdir -p /web/download
#创建站点文件
/web/download/ #可以通过rz上传文件也可以自己创建
├── jpg
└── mp4
#修改文件归属
chown -R nginx.nginx /web
#创建监控访问登陆密码与用户
htpasswd -b -c /etc/nginx/auth_conf yjs 1
#开启nginx和php-fpm服务
systemctl start nginx php-fpm
配置文件内容
server{
server_name download.yjs.com;
listen 80;
root /web/download;
index index.html;
location / {
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
}
location /status{
stub_status;
access_log off;
auth_basic "access auth,input your password!";
auth_basic_user_file /etc/nginx/auth_conf;
}
}
重启服务和修改hosts
systemctl restart nginx php-fpm
C:\Windows\System32\drivers\etc
hosts文件:
.........
10.0.0.7 www.yjs.com download.yjs.com
访问网站


upload站点
网站环境
#创建站点目录
mkdir -p /web/kaoshi
#创建站点内容
unzip kaoshi.zip -d /web/kaoshi/
#修改文件归属
chown -R nginx.nginx /web
#开启nginx和php-fpm服务
systemctl start nginx php-fpm
配置文件内容
server{
server_name upload.yjs.com;
insten 8080;
root /web/kaoshi;
index index.php index.html;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
重启服务和修改hosts
systemctl restart nginx php-fpm
C:\Windows\System32\drivers\etc
hosts文件:
.........
10.0.0.7 www.yjs.com download.yjs.com upload.yjs.com
访问网站

blog站点
网站环境
#创建站点目录
mkdir -p /web/wordpress
#解压文件
tar xf wordpress-5.7-zh_CN.tar.gz
#将解压文件移动到站点目录下
mv wordpress/* /web/wordpress/
#创建监控访问登陆密码与用户
htpasswd -b -c /etc/nginx/auth_conf yjs 1
#开启nginx和php-fpm服务
systemctl start nginx php-fpm
配置文件内容
server{
server_name blog.yjs.com;
listen 80;
root /web/wordpress;
index index.php indx.html;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location /status{
stub_status;
access_log off;
}
}
重启服务和修改hosts
systemctl restart nginx php-fpm
C:\Windows\System32\drivers\etc
hosts文件:
.........
10.0.0.7 www.yjs.com download.yjs.com upload.yjs.com blog.yjs.com
访问网站


zhihu站点
网站环境
#创建站点目录
mkdir -p /web/zhihu
#解压文件
unzip WeCenter_3-2-2.zip
#将解压文件移动到站点目录下
mv WeCenter322/* /web/zhihu/
#创建监控访问登陆密码与用户
htpasswd -b -c /etc/nginx/auth_conf yjs 1
#开启nginx和php-fpm服务
systemctl start nginx php-fpm
配置文件内容
server{
server_name zhihu.yjs.com;
listen 80;
root /web/zhihu;
index index.php indx.html;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location /status{
stub_status;
access_log off;
}
}
重启服务和修改hosts
systemctl restart nginx php-fpm
C:\Windows\System32\drivers\etc
hosts文件:
.........
10.0.0.7 www.yjs.com download.yjs.com upload.yjs.com blog.yjs.com zhihu.yjs.com
访问网站



本文介绍了一个具体的多站点部署案例,包括不同站点的配置细节及访问方式。涉及站点包括www、download、upload、blog和zhihu,每个站点都有特定的需求如端口设置、状态监控及用户认证等。
2318

被折叠的 条评论
为什么被折叠?



