1.安装nginx
vim /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
yum install nginx -y
systemctl start nginx
systemctl enable nginx
2.安装tomcat
yum install tomcat -y
wget https://mirror.bit.edu.cn/apache/tomcat/tomcat-9/v9.0.41/bin/apache-tomcat-9.0.41.tar.gz
tar xf apache-tomcat-9.0.41.tar.gz -C /usr/local/
创建启动服务
groupadd tomcat -g 1111
useradd tomcat -u 1111 -g 1111 -M -s /sbin/nologin
id tomcat
ln -s apache-tomcat-9.0.41 tomcat
chown -R tomcat.tomcat apache-tomcat-9.0.41/
cat >/usr/lib/systemd/system/tomcat.service<<EOF
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target
[Service]
Type=forking
ExecStart=/usr/local/tomcat/bin/catalina.sh start
ExecReload=/usr/local/tomcat/bin/catalina.sh restart
ExecStop=/usr/local/tomcat/bin/catalina.sh stop
User=tomcat
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl start tomcat
ps -ef|grep tomcat
systemctl stop tomcat
3.部署jpress
wget https://gitee.com/JPressProjects/jpress/attach_files/489467/download/jpress-v3.3.0.war
tomcat root目录/usr/local/tomcat/webapps/
cp /root/jpress-v3.3.0.war /usr/local/tomcat/webapps/ 会自动解压
create database jpress DEFAULT CHARACTER SET utf8;
grant all on jpress.* to jpress@'127.0.0.1' identified by '123456';
flush privileges;
curl http://192.168.122.106:8080/jpress/
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context path="" debug="0" docBase="jpress" reloadable="true"/> 添加这行
curl http://192.168.122.106:8080/
nginx代理
upstream java {
server 192.168.122.106:8080;
server 192.168.122.106:9080;
}
server {
listen 82;
server_name 192.168.122.1;
#root html;
index index.jsp index.html index.htm;
location / {
proxy_pass http://java;
include proxy_params;
}
}
tomcat 多实例
cp -r apache-tomcat-9.0.41 tomcat1
cp -r apache-tomcat-9.0.41 tomcat2
sed -i 's#8005#9005#g' tomcat2/conf/server.xml
sed -i 's#8009#9009#g' tomcat2/conf/server.xml
sed -i 's#8080#9080#g' tomcat2/conf/server.xml
网友评论