Put a GeoNode project into Production

In this section, we will update the NGINX and UWSGI daemons to point to our brand new geonode-project instance

  • Stop any currently running instance of GeoNode

workon my_geonode
cd /opt/geonode-project/my_geonode

./manage_dev.sh stop_django

sudo systemctl stop nginx
sudo pkill -9 -f uwsgi
  • Create the new UWSGI app

sudo cp /etc/uwsgi/apps-available/geonode.ini /etc/uwsgi/apps-available/my_geonode.ini
sudo rm /etc/uwsgi/apps-enabled/geonode.ini
sudo ln -s /etc/uwsgi/apps-available/my_geonode.ini /etc/uwsgi/apps-enabled/my_geonode.ini
sudo vim /etc/uwsgi/apps-enabled/my_geonode.ini
--- /etc/uwsgi/apps-available/geonode.ini	2021-07-15 13:59:22.686191424 +0100
+++ /etc/uwsgi/apps-available/my_geonode.ini	2021-09-14 15:21:57.216587290 +0100
@@ -5,12 +5,12 @@
 gid = www-data
 
 plugins = python3
-virtualenv = /home/geonode-vm-321/.virtualenvs/geonode
+virtualenv = /home/geonode-vm-321/.virtualenvs/my_geonode
 
 env = DEBUG=False
 
-env = DJANGO_SETTINGS_MODULE=geonode.settings
-env = GEONODE_INSTANCE_NAME=geonode
+env = DJANGO_SETTINGS_MODULE=my_geonode.settings
+env = GEONODE_INSTANCE_NAME=my_geonode
 env = GEONODE_LB_HOST_IP=
 env = GEONODE_LB_PORT=
  • Restart the services

sudo systemctl start nginx
sudo /etc/init.d/uwsgi restart

image

  • Fix links and paths

cp .env_dev .env_prod
vim .env_prod
--- .env_dev	2021-09-10 11:29:22.415720387 +0100
+++ .env_prod	2021-09-14 15:32:01.768587290 +0100
@@ -39,7 +39,7 @@
 BROKER_URL=amqp://admin:admin@localhost:5672//
 ASYNC_SIGNALS=False
 
-SITEURL=http://localhost:8000/
+SITEURL=http://localhost/
 
 ALLOWED_HOSTS="['django', '*']"
 
@@ -81,9 +81,9 @@
 # #################
 # geoserver
 # #################
-GEOSERVER_WEB_UI_LOCATION=http://localhost:8080/geoserver/
-GEOSERVER_PUBLIC_LOCATION=http://localhost:8080/geoserver/
-GEOSERVER_LOCATION=http://localhost:8080/geoserver/
+GEOSERVER_WEB_UI_LOCATION=http://localhost/geoserver/
+GEOSERVER_PUBLIC_LOCATION=http://localhost/geoserver/
+GEOSERVER_LOCATION=http://localhost/geoserver/
 GEOSERVER_ADMIN_USER=admin
 GEOSERVER_ADMIN_PASSWORD=geoserver
 
@@ -96,7 +96,7 @@
 # Java Options & Memory
 ENABLE_JSONP=true
 outFormat=text/javascript
-GEOSERVER_JAVA_OPTS="-Djava.awt.headless=true -Xms2G -Xmx4G -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=/var/log/jvm.log -XX:PerfDataSamplingInterval=500 -XX:SoftRefLRUPolicyMSPerMB=36000 -XX:-UseGCOverheadLimit -XX:+UseConcMarkSweepGC -XX:ParallelGCThreads=4 -Dfile.encoding=UTF8 -Djavax.servlet.request.encoding=UTF-8 -Djavax.servlet.response.encoding=UTF-8 -Duser.timezone=GMT -Dorg.geotools.shapefile.datetime=false -DGEOSERVER_CSRF_DISABLED=true -DPRINT_BASE_URL=http://geoserver:8080/geoserver/pdf -DALLOW_ENV_PARAMETRIZATION=true -Xbootclasspath/a:/usr/local/tomcat/webapps/geoserver/WEB-INF/lib/marlin-0.9.3-Unsafe.jar -Dsun.java2d.renderer=org.marlin.pisces.MarlinRenderingEngine"
+GEOSERVER_JAVA_OPTS="-Djava.awt.headless=true -Xms2G -Xmx4G -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=/var/log/jvm.log -XX:PerfDataSamplingInterval=500 -XX:SoftRefLRUPolicyMSPerMB=36000 -XX:-UseGCOverheadLimit -XX:+UseConcMarkSweepGC -XX:ParallelGCThreads=4 -Dfile.encoding=UTF8 -Djavax.servlet.request.encoding=UTF-8 -Djavax.servlet.response.encoding=UTF-8 -Duser.timezone=GMT -Dorg.geotools.shapefile.datetime=false -DGEOSERVER_CSRF_DISABLED=true -DPRINT_BASE_URL=http://localhost/geoserver/pdf -DALLOW_ENV_PARAMETRIZATION=true -Xbootclasspath/a:/usr/local/tomcat/webapps/geoserver/WEB-INF/lib/marlin-0.9.3-Unsafe.jar -Dsun.java2d.renderer=org.marlin.pisces.MarlinRenderingEngine"
 
 # #################
 # Security
cp manage_dev.sh manage_prod.sh
vim manage_prod.sh 
--- manage_dev.sh	2021-09-10 10:42:26.571118944 +0100
+++ manage_prod.sh	2021-09-14 15:30:36.132587290 +0100
@@ -1,5 +1,5 @@
 set -a
-. ./.env_dev
+. ./.env_prod
 set +a
 
 python manage.py $@
cp paver_dev.sh paver_prod.sh
vim paver_prod.sh 
--- paver_dev.sh	2021-09-10 10:42:35.615638950 +0100
+++ paver_prod.sh	2021-09-14 15:30:48.284587290 +0100
@@ -1,5 +1,5 @@
 set -a
-. ./.env_dev
+. ./.env_prod
 set +a
 
 paver $@
./manage_prod.sh collectstatic
./manage_prod.sh migrate_baseurl --source-address=localhost:8000 --target-address=localhost
./manage_prod.sh migrate_baseurl --source-address=localhost:8080 --target-address=localhost
  • Update GeoServer http://localhost/geoserver/

    • Login as admin

    image

    • Update the global PROXY BASE URL

    image

    • Update the Role Service

    image

    image

    • Update the OAUTH2 security service

    image

    image

  • Synchronize Layer Metadata

./manage_prod.sh set_all_layers_metadata -d
./manage_dev.sh sync_geonode_datasets --updatepermissions --updateattributes

Next Section: Upgrade GeoNode to Latest Version