关于我在腾讯云买了个服务器,部署springboot、vue前后端分离系统的过程,涉及geoserver、tomcat、nginx ----项目部署篇
在/usr/local/tomcat/apache-tomcat-8.5.55/webapps下导入geoserver。编辑/usr/local/tomcat/apache-tomcat-8.5.55/webapps/geoserver/进入manager,登入tomcat tomcat,进入geoserver,登入admingeoserver。Nginx的可执行文件位于/usr/local/ng
1、tomcat启动geoserver
在/usr/local/tomcat/apache-tomcat-8.5.55/webapps下导入geoserver
启动tomcat、在webapps中生成geoserver文件夹
配置geoserver跨域
linux环境 tomcat下的geoserver的跨域配置
编辑/usr/local/tomcat/apache-tomcat-8.5.55/webapps/geoserver/WEB-INF/web.xml
打开下面几条跨域配置信息xml的注释即可,注意 in Tomcat.
<!-- Uncomment following filter to enable CORS in Tomcat. Do not forget the second config block further down. -->
<filter>
<filter-name>cross-origin</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
<init-param>
<param-name>cors.allowed.origins</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.methods</param-name>
<param-value>GET,POST,PUT,DELETE,HEAD,OPTIONS</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.headers</param-name>
<param-value>*</param-value>
</init-param>
</filter>
<!--
THIS FILTER MAPPING MUST BE THE FIRST ONE, otherwise we end up with ruined chars in the input from the GUI
See the "Note" in the Tomcat character encoding guide:
http://wiki.apache.org/tomcat/FAQ/CharacterEncoding
-->
<filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Uncomment following filter to enable CORS -->
<filter-mapping>
<filter-name>cross-origin</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
访问tomcat 域名:8080
进入manager,登入tomcat tomcat,进入geoserver,登入admin geoserver
(注意:直接部署geoserver,不使用tomcat时,需要放开 <!-- Uncomment following filter to enable CORS in Jetty. --> 的跨域设置,另外需要将lib下的jetty-servlets和jetty-util文件复制到geoserver-2.22.5-bin\webapps\geoserver\WEB-INF\lib内,可以在geoserver-2.22.5-bin\start.ini中配置端口号,)
同时,将打包好的shp数据放置在这里备用
2、 使用geoserver发布数据
新建工作空间
新建存储仓库
发布图层;预览图层
geoserver服务发布成功
3、后端项目配置到服务器
修改springboot后端项目application.yml中连接mysql的域名地址等信息
打jar包
mvn clean package
打war包需要配置一下pom.xml,并加入SpringBootStartApplication类
package com.example.geojmysql;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class SpringBootStartApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(GeojmysqlApplication.class);
}
}
将jar包放置在workspace
使用命令将jar包挂载在后台运行
nohup java -jar geojmysql-0.0.1-SNAPSHOT.jar &
4、前端项目配置到服务器
将前端项目所有访问geoserver的url都设置到服务器域名下
npm run build 打包
生成dist包
部署dist包到服务器的workspace目录下
配置nginx
其中配置了传输文件大小限制
跨域请求配置
user root;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
client_max_body_size 100m;
client_body_buffer_size 128k;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
client_max_body_size 100m;
location / {
root /root/workspace/channel-sys/dist;
index index.html index.htm;
}
location /api/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_pass http://43.138.144.43:9090;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
5、总结、重启服务器注意:
登录管理员模式 sudo su root
mysql:
服务器中mysql自动启动 root 111111
nginx:
未设置开机启动,需手动执行
Nginx的可执行文件位于 /usr/local/nginx/sbin/nginx
启动NGINX
直接执⾏如下命令即可:
/usr/local/nginx/sbin/nginx
如果想停⽌Nginx服务,可执⾏:
/usr/local/nginx/sbin/nginx -s stop
如果修改了配置⽂件后想重新加载Nginx,可执⾏:
/usr/local/nginx/sbin/nginx -s reload
注意其配置⽂件位于:
/usr/local/nginx/conf/nginx.conf
tomcat:
未设置开机启动,需手动执行
tomcat 启动、停止
/usr/local/tomcat/apache-tomcat-8.5.55/bin/startup.sh
/usr/local/tomcat/apache-tomcat-8.5.55/bin/shutdown.sh
geoserver:配置于tomcat内随之启动
jar:/root/workspace
dist:/root/workspace/channel-sys
更多推荐
所有评论(0)