实训日记day18

avatar
作者
猴君
阅读量:0

基于域名和IP地址的虚拟机主机 线上静态商城

将原有的nginx.conf文件备份
[root@static ~]# cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak[root@static ~]# grep -Ev "#|^$" /usr/local/nginx/conf/nginx.conf > /usr/local/nginx/conf/nginx.conf
基于域名的虚拟主机
修改配置文件[root@static ~]# vim /usr/local/nginx/conf/nginx.conf创建目录[root@static ~]# mkdir /aaa在/aaa目录下创建index.html文件[root@static ~]# echo "hello,I am aaa" > /aaa/index.html[root@static ~]# cat /aaa/index.html hello,I am aaa配置nginx.conf文件[root@static ~]# vim /usr/local/nginx/conf/nginx.conf[root@static ~]# /usr/local/nginx/sbin/nginx[root@static ~]# /usr/local/nginx/sbin/nginx -s reload主机劫持IP [root@static ~]# curl www.aaa.com I am static server
将刚才配置的server模块保存到一个新的文件中
[root@static ~]# mkdir /usr/local/nginx/conf.d/[root@static ~]# sed -n '34,40p' /usr/local/nginx/conf/nginx.conf > /usr/local/nginx/conf.d/aaa.conf[root@static ~]# cat /usr/local/nginx/conf.d/aaa.conf    server{        listen    80;        server_name    www.aaa.com;        location / {            index    index.html;        }    }[root@static ~]# sed -i '34,40d' /usr/local/nginx/conf/nginx.conf[root@static ~]# /usr/local/nginx/sbin/nginx -s reload[root@static ~]# /usr/local/nginx/sbin/nginx -s reload[root@static ~]# vim /usr/local/nginx/conf/nginx.conf[root@static ~]# /usr/local/nginx/sbin/nginx -s reload
使用IP地址访问不同的虚拟主机
创建新的IP挂载这个网卡上[root@static ~]# ifconfig ens33:1 192.168.8.200修改配置文件[root@static ~]# vim /usr/local/nginx/conf/nginx.conf[root@static ~]# vim /usr/local/nginx/conf.d/aaa.conf[root@static ~]# /usr/local/nginx/sbin/nginx -s reload [root@static ~]# vim /usr/local/nginx/conf.d/aaa.conf[root@static ~]# /usr/local/nginx/sbin/nginx -s reload
上线一个静态的前端系统
在安装nodejs之前检查是否安装epel[root@static ~]# yum list installed | grep epel[root@static ~]# yum -y install epel-release安装nodejs(是个运行环境)[root@static ~]# yum -y install nodejs

[root@static ~]# node -v v16.20.2 安装npm(nodejs 的包管理器)[root@static ~]# yum -y install npm[root@static ~]# npm -v8.19.4安装vue[root@static ~]# npm config set registry https://registry.npmmirror.com[root@static ~]# npm install @vue/cli[root@static ~]# find / -name "vue"/root/node_modules/vue/root/node_modules/.bin/vue[root@static ~]# /root/node_modules/.bin/vue -V@vue/cli 5.0.8创建vue项目[root@static ~]# /root/node_modules/.bin/vue create eleme_web[root@static ~]# cd eleme_web/[root@static eleme_web]# npm run serve

[root@static eleme_web]# nohup npm run serve& [1] 3130 [root@static eleme_web]# npm run servehttp://192.168.8.159:8082/
配置samba
[root@static eleme_web]# yum -y install sambasamba文件位置编辑配置文件[root@static eleme_web]# pwd/root/eleme_web[root@static eleme_web]# vim /etc/samba/smb.conf创建用户[root@static eleme_web]# useradd vueediter[root@static eleme_web]# smbpasswd -a vueediterNew SMB password:123Retype new SMB password:123Added user vueediter.为该用户在文件夹中添加读写权限[root@static eleme_web]# setfacl -m u:vueediter:rwx /root/eleme_web/启动服务[root@static eleme_web]# systemctl start nmb[root@static eleme_web]# systemctl start smb[root@static eleme_web]# mkdir public/img[root@static eleme_web]# mkdir public/video[root@static eleme_web]# mkdir public/music部署nfs服务器[root@elemestatic ~]# yum -y install rpcbind.x86_64[root@elemestatic ~]# yum -y install nfs-utils.x86_64[root@elemestatic ~]# vim /etc/exports/static/img     *{rw,sync}[root@elemestatic ~]# mkdir -p /static/img/[root@elemestatic ~]# systemctl start rpcbind[root@elemestatic ~]# systemctl start nfs[root@static eleme_web]# yum -y install nfs-utils.x86_64[root@static eleme_web]# mount -t nfs 192.168.8.161:/static/img public/img/[root@tomcat src]# cd components/[root@tomcat components]# lsHelloWorld.vue[root@tomcat components]# vim HelloWorld.vue[root@tomcat src]# ls views/[root@tomcat src]# vim views/HomeView.vue[root@tomcat eleme_web]#nohup npm run serve&

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!