-
Notifications
You must be signed in to change notification settings - Fork 0
Setup
Akshat Shah edited this page Dec 15, 2020
·
2 revisions
These instructions assume an Ubuntu system.
Install Nodejs LTS version:
Either install Neo4j server (which then runs as a service), or install Neo4j Desktop. Don't install both of them. For GUI control of different databases, install Neo4j Desktop.
Note that Java 11 is a prerequisite for Neo4j. Install it from OpenJDK.
- Use the following commands. Note that the installation commands for Neo4j will install Java 11.
sudo add-apt-repository -y ppa:openjdk-r/ppa
sudo apt-get update
- Make sure that Java points to the correct verion:
sudo update-java-alternatives --jre --set <java11name>
- Add the repository
wget -O - https://debian.neo4j.com/neotechnology.gpg.key | sudo apt-key add -
echo 'deb https://debian.neo4j.com stable latest' | sudo tee -a /etc/apt/sources.list.d/neo4j.list
sudo apt-get update
- Install Neo4j Community Edition
sudo apt-get install neo4j=1:4.2.1
- Start Neo4j service
sudo service neo4j start
- Test whether Neo4j is running by going to
http://localhost:7474
- Install the AppImage file from https://neo4j.com/download-v2/?ref=product
- Make the AppImage file executable by
sudo chmod +x <name of file>
- Run the AppImage file
- When Neo4j Desktop opens, create a new database and start it
- Add the repository
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |sudo tee /etc/apt/sources.list.d/pgdg.list
- Install PostgreSQL
sudo apt update
sudo apt -y install postgresql-12 postgresql-client-12
- During this installation, a
postgresuser is created automatically. Change to thepostgresuser by:
sudo -su postgres
- Reset the password:
psql -c "alter user postgres with password 'password'"
- Start
psqlprompt
psql
-
CREATEa database and connect to it using\c. - Optionally, install pgAdmin 4.
sudo apt install pgadmin4 pgadmin4-apache2
During installation, set the username and password for pgAdmin. Check if the set up is working properly by going to localhost/pgadmin from the browser.
Log in and add a server, and connect it to port 5432. Also specify connection details in the Connection tab while adding a new server.
- Install PostGIS 3
sudo apt install postgis postgresql-12-postgis-3
- Create a template database:
sudo -su postgres
createdb template_postgis
psql -d template_postgis -c "CREATE EXTENSION postgis;"
psql -d template_postgis -c "CREATE EXTENSION postgis_topology;"
psql -d template_postgis -c "CREATE EXTENSION postgis_sfcgal;"
Mark this database as a template:
psql -d template_postgis -c "UPDATE pg_database SET datistemplate = 'true' WHERE datname = 'template_postgis';"
- Clone this repository using
git cloneorgh clone repo. - Move to the api directory. Install all dependencies:
npm i
- Move to the client directory. Install all dependencies:
npm i
- Edit details in the file
api/config/keys.js. - Edit details in the file
client/src/config/keys.js. - If you want, edit details in the file
api/config/options.js. - If you want, edit details in the file
client/src/config/options.js. - Set up a PostgreSQL database instance.
createdb -T template_postgis test
CREATE TABLE Stage
(
stageId VARCHAR(36) NOT NULL,
stageLat numeric,
stageLon numeric,
stageGeom geometry(POINT,4326)
);
CREATE TABLE Transfer
(
transferId VARCHAR(36) NOT NULL,
sourceId VARCHAR(36) NOT NULL,
destinationId VARCHAR(36) NOT NULL,
transferLat numeric,
transferLon numeric,
transferGeom geometry(POINT,4326)
);
- Load both the databases with initial data about stages and products.
- Make sure that both database instances are running
- Run the api.
node api/app.js
- Run the React app
cd client
npm start
- Go to
http://localhost:3000 - Note that certain functions require the Android App associated with this project. See this repo.
- Since this project uses Create-React-App, simply run
npm run buildinclient/. - Serve these files using Express itself using the
staticmiddleware, or use another server, like Nginx. To use Nginx:
- Install nginx:
wget --quiet http://nginx.org/keys/nginx_signing.key && sudo apt-key add nginx_signing.key
sudo apt update
sudo apt install nginx
- Check whether the nginx service is running. If it isn't, restart it.
sudo systemctl status nginx
sudo systemctl enable nginx
sudo systemctl status nginx
- If another process is using port 80, you will get an error. Disable any processes or services that are using port 80 (a common service is apache2 -
sudo service apache2 stop) - Create a directory
scmo.lan/in/var/www/ - Move the
builddirectory inclient/to/var/www/scmo.lan. - Go to
/etc/nginx/conf.d. Create ascmo.conffile, and enter the following configuration in it.
server {
listen 80; # IPv4
listen [::]:80; #IPv6
# scmo.lan is the domain name
server_name app.scmo.lan;
# Root dir for static files
root /var/www/scmo.lan/build/;
index index.html;
# Forward API requests to the backend API, running at port 5000
location /api/ {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://192.168.29.2:5000/;
}
# Serve static files from the scmo.lan/build directory
location / {
try_files $uri /$uri /index.html;
}
}
- Add the following line in the
/etc/hostsfile:
<YOUR_IP_ADDRESS> app.scmo.lan
- The application should be served now when you go to
http://app.scmo.lan/