GeoServer在Linux上源码安装、启动、发布地图服务
作者:互联网
1. 环境准备
笔者此次使用的Linux系统是CentOS 8 ,没错,目前已经停止维护,但就操作而言,和其他Linux发行版大同小异
目前的GeoServer版本是2.21
1.1 Git环境
yum install git
Git用来获取GitHub上的源代码
1.2 Maven环境
yum install maven
Maven是GeoServer使用的管理工具
同时,Maven依赖于Java,yum在安装Maven时也下载好了Java 1.8
[root@3a310ba0df96 /]# java -version
openjdk version "1.8.0_312"
OpenJDK Runtime Environment (build 1.8.0_312-b07)
OpenJDK 64-Bit Server VM (build 25.312-b07, mixed mode)
1.3 拉取GeoServer源代码
GeoServer源代码:https://github.com/geoserver/geoserver
git clone https://github.com/geoserver/geoserver.git
1.4 使用Maven构建
参考官方手册:https://docs.geoserver.org/latest/en/developer/quickstart/maven.html
官方Github构建指南:https://github.com/geoserver/geoserver#building
cd geoserver/src
mvn install -D skipTests -T 2C
等待Maven下载jar包,直到构建完成:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] GeoServer 2.21-SNAPSHOT ............................ SUCCESS [ 8.281 s]
[INFO] Core Platform Module ............................... SUCCESS [ 3.460 s]
[INFO] Open Web Service Module ............................ SUCCESS [ 0.684 s]
[INFO] Main Module ........................................ SUCCESS [04:19 min]
[INFO] GeoServer Security Modules ......................... SUCCESS [ 3.105 s]
[INFO] GeoServer Security Tests Module .................... SUCCESS [ 4.552 s]
[INFO] GeoServer JDBC Security Module ..................... SUCCESS [ 45.418 s]
[INFO] GeoServer LDAP Security Module ..................... SUCCESS [ 49.383 s]
[INFO] Web Coverage Service Module ........................ SUCCESS [ 3.819 s]
[INFO] Web Coverage Service 1.0 Module .................... SUCCESS [ 47.645 s]
[INFO] Web Coverage Service 1.1 Module .................... SUCCESS [ 50.148 s]
[INFO] Web Coverage Service 2.0 Module .................... SUCCESS [ 8.879 s]
[INFO] Web Feature Service Module ......................... SUCCESS [01:00 min]
[INFO] Web Map Service Module ............................. SUCCESS [01:43 min]
[INFO] KML support for GeoServer .......................... SUCCESS [ 7.563 s]
[INFO] gs-rest ............................................ SUCCESS [ 6.339 s]
[INFO] GeoWebCache (GWC) Module ........................... SUCCESS [ 46.647 s]
[INFO] gs-restconfig ...................................... SUCCESS [ 53.957 s]
[INFO] gs-restconfig-wcs .................................. SUCCESS [ 1.968 s]
[INFO] gs-restconfig-wfs .................................. SUCCESS [ 2.216 s]
[INFO] gs-restconfig-wms .................................. SUCCESS [ 1.335 s]
[INFO] WMTS REST configuration ............................ SUCCESS [ 1.512 s]
[INFO] GeoServer Web Modules .............................. SUCCESS [ 0.159 s]
[INFO] Core UI Module ..................................... SUCCESS [01:07 min]
[INFO] WMS UI Module ...................................... SUCCESS [ 3.021 s]
[INFO] GWC UI Module ...................................... SUCCESS [ 3.348 s]
[INFO] WFS UI Module ...................................... SUCCESS [ 1.546 s]
[INFO] Demos Module ....................................... SUCCESS [ 8.639 s]
[INFO] WCS UI Module ...................................... SUCCESS [ 1.684 s]
[INFO] Security UI Modules ................................ SUCCESS [ 0.108 s]
[INFO] Security UI Core Module ............................ SUCCESS [ 4.154 s]
[INFO] Security UI JDBC Module ............................ SUCCESS [ 1.378 s]
[INFO] Security UI LDAP Module ............................ SUCCESS [ 4.270 s]
[INFO] REST UI Module ..................................... SUCCESS [ 1.372 s]
[INFO] GeoServer Web Application .......................... SUCCESS [01:15 min]
[INFO] Community Space .................................... SUCCESS [ 0.161 s]
[INFO] GeoServer Extensions 2.21-SNAPSHOT ................. SUCCESS [ 0.133 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 09:22 min (Wall Clock)
[INFO] Finished at: 2022-04-23T03:56:07Z
[INFO] ------------------------------------------------------------------------
BTW:GeoServer是基于Spring框架构建的,目前Spring cloud如火如荼,GeoServer也在往这方面发展,详见:Cloud Native GeoServer, 不过,截至目前,该项目还未正式完成
1.5 运行GeoServer
切换目录:
cd web/app
运行GeoServer:
mvn jetty:run
等待Jetty启动完成,使用浏览器输入网址:http://localhost:8080/geoserver/
点击 图层预览,发现一个图层也没有哇:
2. 发布地图服务
此处笔者使用的是一个shapefile的线状矢量图层,数据来源于官方自带的示例数据,位于geoserver/data/release/data/shapefiles/states.shp
2.1 图层预览
在QGIS里,图层看起来是这样的:
2.2 登陆GeoServer
默认账户和密码:
- 账户:admin
- 密码:geoserver
2.3 创建一个新的工作空间
官方文档:工作区由名称和命名空间URI(统一资源标识符)定义。工作区名称限制为10个字符,不能包含空格。URI类似于URL,只是URI不需要指向web上的实际位置,只需要是唯一的标识符。对于工作区URI,我们建议使用与项目关联的URL,可能使用不同的尾随标识符。例如, http://www.openplans.org/topp
是“topp”工作区的URI
勾选授权所有人:
点击保存
2.4 添加存储数据
此处选择Shapefile:
选择或填写相应的数据:
点击保存
2.5 发布地图
点击发布:
边框部分可以从数据中计算,其他默认即可:
2.6 图层预览
点击图层预览:
在openlayers中预览地图:
3. 参考资料
标签:INFO,geoserver,SUCCESS,GeoServer,Module,源码,UI,Linux 来源: https://www.cnblogs.com/jiujiubashiyi/p/16183376.html