首先下载,安装tomcat。
修改tomcat端口,修改server.xml:
1.修改tomcat端口(默认8080)
<Connector port="8383" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
2.shutdown 端口(默认8005)
<Server port="8006" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
3.修改AJP端口(默认8009)
<!-- Define an AJP 1.3 Connector on port 8009 --> <Connector port="8019" protocol="AJP/1.3" redirectPort="8443" />
同时修改启动两个tomcat,端口分别为8383,8484.
安装nginx,修改nginx.conf文件,配置tomcat.
# tomcat 集群配置 upstream tomcat_cluser{ server 127.0.0.1:8383 weight=1; server 127.0.0.1:8484 weight=1; }
server { listen 80; server_name 127.0.0.1; #charset koi8-r; #access_log logs/host.access.log main; location / { proxy_pass http://tomcat_cluser; root html; index index.html index.htm; } location ~ \.jsp$ { proxy_pass http://tomcat_cluser; } location /schedule { proxy_pass http://tomcat_cluser; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|apk|tar.gz)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } }
启动tomcat,启动nginx.
访问:localhost,即可看到。
时间: 2024-10-24 05:14:29