天天看點

企業實戰(21)基于Linux下安裝部署GeoServer地圖服務

環境介紹:

CentOS 7.5

Java 1.8.0

Geoserver 2.17.2

GeoServer 2.17.2下載下傳:https://nchc.dl.sourceforge.net/project/geoserver/GeoServer/2.17.2/geoserver-2.17.2-bin.zip

安裝部署

企業實戰(21)基于Linux下安裝部署GeoServer地圖服務

1.確定在系統上安裝了Java Runtime Environment(JRE)。GeoServer需要Java 8或Java 11環境,可從OpenJDK,AdoptOpenJDK獲得或由您的OS發行版提供。

[root@test ~]# yum install java-1.8.0-openjdk

[root@test ~]# java -version
openjdk version "1.8.0_262"
OpenJDK Runtime Environment (build 1.8.0_262-b10)
OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)           

複制

2.下載下傳GeoServer

[root@test ~]# yum -y install wget

[root@test ~]# wget https://nchc.dl.sourceforge.net/project/geoserver/GeoServer/2.17.2/geoserver-2.17.2-bin.zip

[root@test ~]# ls
anaconda-ks.cfg  geoserver-2.17.2-bin.zip           

複制

3.解壓下載下傳好的GeoServer安裝包到指定目錄

建議的位置為

/usr/share/geoserver

[root@test ~]# yum search unzip
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.aliyun.com
================================ N/S matched: unzip =================================
unzip.x86_64 : A utility for unpacking zip files

[root@test ~]# yum -y install unzip


[root@test ~]# mkdir /usr/share/geoserver      //建議的位置為/usr/share/geoserver。

[root@test ~]# unzip geoserver-2.17.2-bin.zip -d /usr/share/geoserver/

[root@test ~]# ll -h /usr/share/geoserver/
總用量 268K
drwxr-xr-x.  2 root root   82 7月  22 09:53 bin
drwxr-xr-x. 14 root root 4.0K 7月  22 09:53 data_dir
drwxr-xr-x.  2 root root  276 5月  19 15:23 etc
drwxr-xr-x.  2 root root 4.0K 7月  22 09:53 lib
drwxr-xr-x.  2 root root   98 7月  22 09:53 license
drwxr-xr-x.  2 root root   24 5月  19 15:23 logs
drwxr-xr-x.  2 root root  173 5月  19 15:23 modules
-rw-r--r--.  1 root root  84K 7月  20 02:12 NOTICE.md
-rw-r--r--.  1 root root  423 5月  19 15:23 README.txt
drwxr-xr-x.  2 root root   30 5月  19 15:23 resources
-rw-r--r--.  1 root root 3.9K 7月  20 02:12 RUNNING.txt
-rw-r--r--.  1 root root 2.0K 5月  19 15:23 start.ini
-rw-r--r--.  1 root root 157K 5月  19 15:23 start.jar
-rw-r--r--.  1 root root  333 7月  22 09:44 VERSION.txt
drwxr-xr-x.  3 root root   23 7月  22 09:53 webapps           

複制

4.添加環境變量以儲存GeoServer的位置

[root@test ~]# echo "export GEOSERVER_HOME=/usr/share/geoserver" >> /etc/profile

[root@test ~]# source /etc/profile

[root@test ~]# cat /etc/profile | tail -2
unset -f pathmunge
export GEOSERVER_HOME=/usr/share/geoserver           

複制

5.使自己成為geoserver檔案夾的所有者

[root@test ~]# chown -R root:root /usr/share/geoserver/

[root@test ~]# ll /usr/share/geoserver/
總用量 268
drwxr-xr-x.  2 root root     82 7月  22 09:53 bin
drwxr-xr-x. 14 root root   4096 7月  22 09:53 data_dir
drwxr-xr-x.  2 root root    276 5月  19 15:23 etc
drwxr-xr-x.  2 root root   4096 7月  22 09:53 lib
drwxr-xr-x.  2 root root     98 7月  22 09:53 license
drwxr-xr-x.  2 root root     24 5月  19 15:23 logs
drwxr-xr-x.  2 root root    173 5月  19 15:23 modules
-rw-r--r--.  1 root root  85824 7月  20 02:12 NOTICE.md
-rw-r--r--.  1 root root    423 5月  19 15:23 README.txt
drwxr-xr-x.  2 root root     30 5月  19 15:23 resources
-rw-r--r--.  1 root root   3945 7月  20 02:12 RUNNING.txt
-rw-r--r--.  1 root root   1971 5月  19 15:23 start.ini
-rw-r--r--.  1 root root 160629 5月  19 15:23 start.jar
-rw-r--r--.  1 root root    333 7月  22 09:44 VERSION.txt
drwxr-xr-x.  3 root root     23 7月  22 09:53 webapps           

複制

6.通過進入目錄geoserver/bin并執行startup.sh腳本來啟動GeoServer

[root@test ~]# cd /usr/share/geoserver/bin/

[root@test bin]# ls
shutdown.bat  shutdown.sh  startup.bat  startup.sh

[root@test bin]# ./startup.sh
GEOSERVER DATA DIR is /usr/share/geoserver/data_dir
2020-08-13 20:39:16.372:INFO::main: Logging initialized @1692ms to org.eclipse.jetty.util.log.StdErrLog
2020-08-13 20:39:16.840:WARN:oejx.XmlConfiguration:main: Property 'jetty.port' is deprecated, use 'jetty.http.port' instead
...

[root@test ~]# ss -antulp | grep :8080      //新開指令視窗查詢,因為執行start.sh腳本沒放入背景,會一直占用終端視窗
tcp    LISTEN     0      50       :::8080                 :::*                   users:(("java",pid=5791,fd=313))           

複制

通路GeoServer

http://伺服器IP位址:8080/geoserver

預設的使用者名 :admin 和 密碼:geoserver 登入後,進入主界面

企業實戰(21)基于Linux下安裝部署GeoServer地圖服務
企業實戰(21)基于Linux下安裝部署GeoServer地圖服務

要關閉GeoServer,請關閉永久指令行視窗,或運作bin目錄中的

shutdown.sh

檔案。

解除安裝

如果正在運作,請先停止GeoServer。

删除安裝GeoServer的目錄。