Linux geoserver安装

安装geoserver

  • 下载
wget https://jaist.dl.sourceforge.net/project/geoserver/GeoServer/2.15.1/geoserver-2.15.1-bin.zip
  • 解压
unzip geoserver-2.15.1-bin.zip 
  • 修改端口
cd geoserver-2.15.1
vi start.ini 

修改下面的内容

jetty.port=8003
  • 启动程序
cd bin
./startup.sh

设置GEOSERVER_HOME

不设置GEOSERVER_HOME,只能进入到geoserver的根目录下执行startup.sh;设置GEOSERVER_HOME以后,就可以在任何目录来启动geoserver

vi /etc/profile

增加以下代码:

export GEOSERVER_HOME=/opt/geoserver-2.15.1

保存后使配置生效:

source /etc/profile

支持跨域

  • 下载jetty-servlets
    http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-servlets/下载对应版本的jetty。对应关系可以去geoserver中的lib目录下查看
    当前对应版本为 jetty-servlets-9.4.12.v20180830.jar
    下载后将此jar上次到 geoserver-2.15.1/webapps/geoserver/WEB-INF/lib

  • 修改web.xml
    修改geoserver-2.15.1/webapps/geoserver/WEB-INF/web.xml以支持跨域
    把以下两块的注释去掉,变成如下:

 <!-- Uncomment following filter to enable CORS -->
   <filter>
        <filter-name>cross-origin</filter-name>
        <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
       <init-param>
           <param-name>chainPreflight</param-name>
           <param-value>false</param-value>
       </init-param>
       <init-param>
           <param-name>allowedOrigins</param-name>
           <param-value>*</param-value>
       </init-param>
       <init-param>
           <param-name>allowedMethods</param-name>
           <param-value>GET,POST,PUT,DELETE,HEAD,OPTIONS</param-value>
       </init-param>
       <init-param>
           <param-name>allowedHeaders</param-name>
           <param-value>*</param-value>
       </init-param>
    </filter>

   <!-- Uncomment following filter to enable CORS -->
    <filter-mapping>
        <filter-name>cross-origin</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
  • 拷贝jetty-util
    同时把geoserver-2.15.1/lib下的jetty-util-xxxx.jar包copy到geoserver-2.15.1/webapps/geoserver/WEB-INF/lib

修改缓存路径

  • 默认缓存路径可以通过以下方式查看


    查看缓存路径

    查看缓存路径
  • 修改默认路径
vi webapps/geoserver/WEB-INF/web.xml

增加以下配置

<context-param>
    <param-name>GEOWEBCACHE_CACHE_DIR</param-name>
    <param-value>/tmp/geowebcache</param-value>
</context-param>

推荐阅读更多精彩内容