setting.rst 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. .. _datadir_setting:
  2. Setting the data directory location
  3. ===================================
  4. The procedure for setting the location of the GeoServer data directory is dependent on the type of GeoServer installation. Follow the instructions below specific to the target platform.
  5. .. note:: If the location of the GeoServer data directory is not set explicitly, the directory ``data_dir`` under the root of the GeoServer installation will be chosen by default.
  6. Windows
  7. -------
  8. On Windows platforms the location of the GeoServer data directory is controlled by the ``GEOSERVER_DATA_DIR`` environment variable.
  9. To set the environment variable:
  10. #. Open the System Control Panel.
  11. #. Click :guilabel:`Advanced System Properties`.
  12. #. Click :guilabel:`Environment Variables`.
  13. #. Click the ``New`` button and create a environment variable called ``GEOSERVER_DATA_DIR`` and set it to the desired location.
  14. .. figure:: img/envvar_win.png
  15. Setting an environment variable on Windows
  16. Linux
  17. -----
  18. On Linux platforms the location of the GeoServer data directory is controlled by the ``GEOSERVER_DATA_DIR`` environment variable. Setting the variable can be achieved with the following command (in the terminal):
  19. .. code-block:: console
  20. export GEOSERVER_DATA_DIR=/var/lib/geoserver_data
  21. To make the variable persist, place the command in the ``.bash_profile`` or ``.bashrc`` file. Ensure that this done for the user running GeoServer.
  22. Mac OS X
  23. --------
  24. For the binary install of GeoServer on Mac OS X, the data directory is set in the same way as for Linux.
  25. For the Mac OS X install, set the ``GEOSERVER_DATA_DIR`` environment variable to the desired directory location. See `this page <http://developer.apple.com/mac/library/qa/qa2001/qa1067.html>`_ for details on how to set an environment variable in Mac OS X.
  26. Web archive
  27. -----------
  28. When running a GeoServer WAR inside a servlet container, the data directory can be specified in a number of ways.
  29. See :ref:`application_properties` section for details on setting this location using java system property, web context parameter, or environmental variable.
  30. Context parameter
  31. ^^^^^^^^^^^^^^^^^
  32. To specify the data directory using a servlet context parameter, create the following ``<context-param>`` element in the ``WEB-INF/web.xml`` file for the GeoServer application:
  33. .. code-block:: xml
  34. <web-app>
  35. ...
  36. <context-param>
  37. <param-name>GEOSERVER_DATA_DIR</param-name>
  38. <param-value>/var/lib/geoserver_data</param-value>
  39. </context-param>
  40. ...
  41. </web-app>
  42. Java system property
  43. ^^^^^^^^^^^^^^^^^^^^
  44. It is also possible to specify the data directory location with a Java system property. This method can be useful during upgrades, as it avoids the need to set the data directory after every upgrade.
  45. .. warning:: Using a Java system property will typically set the property for all applications running in the servlet container, not just GeoServer.
  46. The method of setting the Java system property is dependent on the servlet container:
  47. * For **Tomcat**, edit the file :file:`bin/setclasspath.sh` under the root of the Tomcat installation. Specify the ``GEOSERVER_DATA_DIR`` system property by setting the ``CATALINA_OPTS`` variable:
  48. .. code-block:: console
  49. CATALINA_OPTS="-DGEOSERVER_DATA_DIR=/var/lib/geoserver_data"
  50. * For **Glassfish**, edit the file :file:`domains/<<domain>>/config/domain.xml` under the root of the Glassfish installation, where ``<<domain>>`` refers to the domain that the GeoServer web application is deployed under. Add a ``<jvm-options>`` element inside the ``<java-config>`` element:
  51. .. code-block:: xml
  52. ...
  53. <java-config>
  54. ...
  55. <jvm-options>-DGEOSERVER_DATA_DIR=/var/lib/geoserver_data</jvm-options>
  56. </java-config>
  57. ...
  58. Require files to exist
  59. ----------------------
  60. If the data directory is on a network filesystem, it can be desirable for security reasons to require one or more files or directories to exist before GeoServer will start, to prevent GeoServer from falling back into a default insecure configuration if the data directory appears to be empty because of the loss of this network resource.
  61. To require files or directories to exist, use any of the methods above to set ``GEOSERVER_REQUIRE_FILE``. Do not specify a mount point as this will still exist if a network filesystem is unavailable; instead specify a file or directory *inside* a network mount. For example:
  62. Environment variable:
  63. .. code-block:: console
  64. export GEOSERVER_REQUIRE_FILE=/mnt/server/geoserver_data/global.xml
  65. Servlet context parameter:
  66. .. code-block:: xml
  67. <web-app>
  68. ...
  69. <context-param>
  70. <param-name>GEOSERVER_REQUIRE_FILE</param-name>
  71. <param-value>/mnt/server/geoserver_data/global.xml</param-value>
  72. </context-param>
  73. ...
  74. </web-app>
  75. Java system property:
  76. .. code-block:: console
  77. CATALINA_OPTS="-DGEOSERVER_REQUIRE_FILE=/mnt/server/geoserver_data/global.xml"
  78. Multiple files
  79. ^^^^^^^^^^^^^^
  80. To specify multiple files or directories that must exist, separate them with the path separator (``:`` on Linux, ``;`` on Windows):
  81. Environment variable:
  82. .. code-block:: console
  83. export GEOSERVER_REQUIRE_FILE=/mnt/server/geoserver_data/global.xml:/mnt/server/data
  84. Servlet context parameter:
  85. .. code-block:: xml
  86. <web-app>
  87. ...
  88. <context-param>
  89. <param-name>GEOSERVER_REQUIRE_FILE</param-name>
  90. <param-value>/mnt/server/geoserver_data/global.xml:/mnt/server/data</param-value>
  91. </context-param>
  92. ...
  93. </web-app>
  94. Java system property:
  95. .. code-block:: console
  96. CATALINA_OPTS="-DGEOSERVER_REQUIRE_FILE=/mnt/server/geoserver_data/global.xml:/mnt/server/data"