接着昨天的
npm run serve
构建项目
npm run build
ls
ls dist/
vim dist/index.html
[root@web eleme_web]# cd /usr/local/nginx/conf/
[root@web conf]# ls
将静态的项目移动到nginx中
[root@web nginx]# cd conf.d/
[root@web conf.d]# ls
qd.conf
[root@web conf.d]# cp qd.conf eleme.conf
[root@web conf.d]# vim eleme.conf
server{
listen 80;
server_name www.eleme.com;
root /root/eleme_web/dist;
location / {
index index.html;
}
}
[root@web conf.d]# vim /usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name 192.168.2.35;
[root@web conf.d]# /usr/local/nginx/sbin/nginx -s reload
[root@web conf.d]# mkdir /eleme
[root@web conf.d]# cp -r ~/eleme_web/dist/* /eleme/ //将项目整体移动到/eleme目录下
[root@web conf.d]# vim /usr/local/nginx/conf.d/eleme.conf
server{
listen 80;
server_name www.eleme.com;
root /eleme;
location / {
index index.html;
}
}
[root@web conf.d]# /usr/local/nginx/sbin/nginx -s reload
在windows中的C:\Windows\System32\drivers\etc路径下的hosts文件中添加:10.0.0.10 www.eleme.com
用浏览器访问www.eleme.com
java环境的配置
- 下载jdk22
wget https://download.oracle.com/java/22/latest/jdk-22_linux-x64_bin.tar.gz
- 解压
[root@dy001 ~]# tar -zxvf jdk-22_linux-x64_bin.tar.gz
- mv jdk-22.2/ /usr/local/jdk22/
- 配置配置文件
vim /etc/profile
export JAVA_HOME=/usr/local/jdk22/
export PATH=$JAVA_HOME/bin:$PATH
- 运行profile
source /etc/profile
- 测试
java
java -version
下载tomcat
[root@dy001 ~]# wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.26/bin/apache-tomcat-10.1.26.tar.gz
解压
[root@dy001 ~]# tar -zxvf apache-tomcat-10.1.26.tar.gz
将apache tomcat移动到/usr/loacl/目录下,改名tomcat
[root@dy001 ~]# mv apache-tomcat-10.1.26 /usr/local/tomcat/
启动tomcat
[root@dy001 ~]# /usr/local/tomcat/bin/startup.sh
查看有没有启动成功
[root@dy001 ~]# netstat -lnput|grep java
停止tomcat的命令是
/usr/local/rimcat/bin/shutdown.sh
tomcat的目录:
bin:可执行文件
Windows和linux通用
windows上优化后上传到linux,只需要添加权限
Webapps:每一个目录就是一个项目
ROOT是默认的项目目录,在实际的开发中,目录名修改为ROOT就可以直接发布
要发布项目有两个选项:
将项目到移动该目录下
在conf/server.xml修改资源文件的位置
[root@dy001 tomcat]# cd webapps/
[root@dy001 webapps]# ls ROOT/
[root@dy001 webapps]# vim ROOT/index.jsp
[root@dy001 webapps]# ls
docs examples host-manager manager ROOT
[root@dy001 webapps]# mkdir myweb
[root@dy001 webapps]# vim myweb/my.txt
[root@dy001 webapps]# cd myweb
logs[root@dy001 myweb]# vim a.jsp
work
将jsp还原成java和class文件
保存的路径/usr/local/tomcat/work/Catalina/localhost/myweb/org/apache/jsp/xxx.java
自动将jsp解析为javav文件,不需要重启服务
Conf
logs
日志文档
catalin.log
localhost.log
都有相应日期
lib
tomcat运行为项目提供的依赖文件
tmp
同样再配置另外两台主机dy002,dy003
下载jdk,tomcat并配置
修改ROOT目录中的index.isp
[root@dy001 ~]# echo "i am dynamic jsp java server page,nmuber is 001" > /usr/local/tomcat/webapps/ROOT/index.jsp
[root@dy002 ~]# echo "i am dynamic jsp java server page,nmuber is 002" > /usr/local/tomcat/webapps/ROOT/index.jsp
[root@dy002 ~]# /usr/local/tomcat/bin/startup.sh
[root@dy003 ~]# echo "i am dynamic jsp java server page
,nmuber is 003" > /usr/local/tomcat/webapps/ROOT/index.jsp
[root@dy003 ~]# /usr/local/tomcat/bin/startup.sh
[root@dy003 ~]# netstat -lnput|grep java
用这台机器来代理前面的三台机器发布的项目
[root@web ~]# cd /usr/local/nginx/
[root@web nginx]# cd conf.d
[root@web conf.d]# cp eleme.conf el.conf
[root@web conf.d]# ls
[root@web conf.d]# vim el.conf
server{
listen 80;
server_name www.el.com;
root /eleme;
location / {
proxy_pass http://elgroup;
}
}
[root@web conf.d]# cd /usr/local/nginx/conf
[root@web conf]# vim nginx.conf
keepalive_timeout 65;
upstream elgroup {
server 192.168.2.37:8080;
server 192.168.2.38:8080;
server 192.168.2.39:8080;
}
include ../conf.d/*.conf;
[root@web conf.d]# /usr/local/nginx/sbin/nginx
[root@web conf.d]# vim /etc/hosts
192.168.2.35 www.el.com //在最后添加
[root@web ~]# curl www.el.com
i am dynamic jsp java server page,nmuber is 001
[root@web ~]# curl www.el.com
i am dynamic jsp java server page,nmuber is 002
[root@web ~]# curl www.el.com
i am dynamic jsp java server page,nmuber is 003