[GIS] Using DATA_DIR relative path in GeoServer

geoservergeoserver-rest-api

I am using REST API with curl to populate geoserver with layers on the server. I am not setting GEOSERVER_HOME so Geoserver itself decides what the actual path is. However, when I download the populated geoserver to my laptop and run it with startup.sh script, layers are not published as the datastore location still aims to the server location (/var/www/user/…).

How do I make geoserver independent on the environment it is run in? I would like the datastores to use relative paths, so instead of /var/www/user/... they should be using data_dir/datastore_dir.

Is this possible?

Best Answer

I would move the data directory in a location outside the GeoServer since if you deploy in an application container and then you want to do an update or upgrade of GeoServer you might lose the GeoServer configuration as the update/upgrade most probably will wipe out the data dir itself! Internal data director is used mostly for prototyping not for production use.

That said, you can configure everything in GeoServer to use paths relative to the data directory. Infact paths can be either absolute or relative to the root of the data directory. Both should work out of the box.

Related Question