lnmp部署:域名访问、端口访问、状态监控、用户认证、访问限制

部署五个站点:

  • www.xxx.com
  • download.xxx.com
  • upload.xxx.com
  • blog.xxx.com
  • zhihu.xxx.ccom

要求:

  1. 通过域名访问
  2. upload通过8080端口访问
  3. blog和zhihu要开启状态监控
  4. download和blog、zhihu的状态监控需要开启用户认证
  5. 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

访问网站

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值