最近由於項目需求,需要用到GeoServer進行地圖發布。之前草草的學習過一段時間的GeoServer,但是都沒有記錄下來,到現在用的時候很多東西都需要重新查閱。所以現在將步驟記錄下來,以供查閱。
GeoServer簡介
GeoServer定義
是 OpenGIS Web 服務器規范的 J2EE 實現,利用 GeoServer 可以方便的發布地圖數據,允許用戶對特征數據進行更新、刪除、插入操作,通過 GeoServer 可以比較容易的在用戶之間迅速共享空間地理信息。
GeoServer 主要特性
兼容 WMS 和 WFS 特性;支持 PostgreSQL、 Shapefile 、 ArcSDE 、 Oracle 、 VPF 、 MySQL 、 MapInfo ;支持上百種投影;能夠將網絡地圖輸出為 jpeg 、 gif 、 png 、 SVG 、 KML 等格式;能夠運行在任何基於 J2EE/Servlet 容器之上;嵌入 MapBuilder 支持 AJAX 的地圖客戶端OpenLayers;除此之外還包括許多其他的特性。
一、GeoServer下載
GeoServer的下載地址:http://geoserver.org/release/stable/
下載頁面包括了GeoServer的安裝文件,war包和文檔及擴展。如下圖:
我這里下載好了這些文件,百度網盤:http://pan.baidu.com/s/1mi6bqkw 分享密碼:4d9w
二、GeoServer的安裝
GeoServer的安裝方式有多種,幫助文檔中建議Windows和Mac OS采用獨立安裝方式。
這里需要注意的是:
Note
To run GeoServer as part of an existing servlet container such as Tomcat, please see the Web archive section.
Warning
GeoServer requires a Java 7 environment (JRE) to be installed on your system. This must be done prior to installation.
Windows 安裝
The Windows installer provides an easy way to set up GeoServer on your system, as it requires no configuration files to be edited or command line settings.
-
Make sure you have a Java Runtime Environment (JRE) installed on your system. GeoServer requires a Java 8 environment. The Oracle JRE is preferred, but OpenJDK has been known to work adequately. You can download JRE 8 from Oracle.
Note
Java 9 is not currently supported.
-
Navigate to the GeoServer Download page.
-
Select the version of GeoServer that you wish to download. If you’re not sure, selectStable.
-
Click the link for the Windows installer.
Downloading the Windows installer
-
After downloading, double-click the file to launch.
-
At the Welcome screen, click Next.
Welcome screen
-
Read the License and click I Agree.
GeoServer license
-
Select the directory of the installation, then click Next.
GeoServer install directory
-
Select the Start Menu directory name and location, then click Next.
Start menu location
-
Enter the path to a valid Java Runtime Environment (JRE). GeoServer requires a valid JRE in order to run, so this step is required. The installer will inspect your system and attempt to automatically populate this box with a JRE if it is found, but otherwise you will have to enter this path manually. When finished, click Next.
Note
A typical path on Windows would be C:\Program Files\Java\jre8.
Note
Don’t include the \bin in the JRE path. So if java.exe is located atC:\Program Files (x86)\Java\jre8\bin\java.exe, set the path to be C:\Program Files(x86)\Java\jre8.
Selecting a valid JRE
-
Enter the path to your GeoServer data directory or select the default. If this is your first time using GeoServer, select the Default data directory. When finished, click Next.
Setting a GeoServer data directory
-
Enter the username and password for administration of GeoServer. GeoServer’s Web administration interface requires authentication for management, and what is entered here will become those administrator credentials. The defaults are admin / geoserver. It is recommended to change these from the defaults. When finished, clickNext.
Setting the username and password for GeoServer administration
-
Enter the port that GeoServer will respond on. This affects the location of the GeoServer Web administration interface, as well as the endpoints of the GeoServer services such as Web Map Service (WMS) and Web Feature Service (WFS). The default port is 8080, though any valid and unused port will work. When finished, click Next.
Setting the GeoServer port
-
Select whether GeoServer should be run manually or installed as a service. When run manually, GeoServer is run like a standard application under the current user. When installed as a service, GeoServer is integrated into Windows Services, and thus is easier to administer. If running on a server, or to manage GeoServer as a service, select Install as a service. Otherwise, select Run manually. When finished, clickNext.
Installing GeoServer as a service
-
Review your selections and click the Back button if any changes need to be made. Otherwise, click Install.
Verifying settings
-
GeoServer will install on your system. When finished, click Finish to close the installer.
-
If you installed GeoServer as a service, it is already running. Otherwise, you can start GeoServer by going to the Start Menu, and clicking Start GeoServer in the GeoServer folder.
-
Navigate to http://localhost:8080/geoserver (or wherever you installed GeoServer) to access the GeoServer Web administration interface.
If you see the GeoServer logo, then GeoServer is successfully installed.
![]()
GeoServer installed and running successfully
Windows binary 安裝
Note
For the wizard-based installer on Windows, please see the section on the Windows installer. For installing on Windows with an existing application server such as Tomcat, please see the Web archive section.
An alternate way of installing GeoServer on Windows is to use the platform-independent binary. This version is a GeoServer web application bundled inside Jetty, a lightweight and portable application server. It has the advantages of working very similarly across all operating systems and is very simple to set up.
Installation
Make sure you have a Java Runtime Environment (JRE) installed on your system. GeoServer requires a Java 8 environment. The Oracle JRE is preferred, but OpenJDK has been known to work adequately. You can download JRE 8 from Oracle.
Note
Java 9 is not currently supported.
Navigate to the GeoServer Download page.
Select the version of GeoServer that you wish to download. If you’re not sure, selectStable.
Select Platform Independent Binary on the download page.
Download the archive and unpack to the directory where you would like the program to be located.
Note
A suggested location would be C:\Program Files\GeoServer.
Setting environment variables
You will need to set the JAVA_HOME environment variable if it is not already set. This is the path to your JRE such that %JAVA_HOME%\bin\java.exe exists.
- Navigate to Control Panel ‣ System ‣ Advanced ‣ Environment Variables.
- Under System variables click New.
- For Variable name enter JAVA_HOME. For Variable value enter the path to your JDK/JRE.
- Click OK three times.
Note
You may also want to set the GEOSERVER_HOME variable, which is the directory where GeoServer is installed, and the GEOSERVER_DATA_DIR variable, which is the location of the GeoServer data directory (which by default is %GEOSERVER_HOME\data_dir). The latter is mandatory if you wish to use a data directory other than the default location. The procedure for setting these variables is identical to setting the JAVA_HOME variable.
Running
Note
This can be done either via Windows Explorer or the command line.
- Navigate to the bin directory inside the location where GeoServer is installed.
- Run startup.bat. A command-line window will appear and persist. This window contains diagnostic and troubleshooting information. This window must be left open, otherwise GeoServer will shut down.
- Navigate to http://localhost:8080/geoserver (or wherever you installed GeoServer) to access the GeoServer Web administration interface.
If you see the GeoServer logo, then GeoServer is successfully installed.
![]()
GeoServer installed and running successfully