# GeoNode Fresh Setup @AWS
## Setup AWS
## Create an instance of VM Ubuntu
Follow this
[Launch a Linux Virtual Machine](https://aws.amazon.com/getting-started/tutorials/launch-a-virtual-machine/?trk=gs_card&e=gs&p=gsrc_v3)
Selected the following OS for server

Step 7: Review Instance Launch, accept all default settings.
Connect to the instance with SSH
Windows users can use Git Bash
```
ssh -i 'C:\Users\gakum\.ssh\MyKeyPair.pem' ubuntu@18.204.212.236
```
Note: For ubuntu, username is 'ubuntu' not 'ec2-user'

## Setup Geonode
Follow [GeoNode Core](http://docs.geonode.org/en/2.10.x/install/core/index.html#geonode-core)
Upgrade system packages
```
sudo apt update
sudo apt upgrade
```

-->Selected the first option
```
# Install packages from GeoNode core
sudo apt install -y python-gdal gdal-bin
sudo apt install -y python-pip python-dev python-virtualenv virtualenvwrapper
sudo apt install -y libxml2 libxml2-dev gettext
sudo apt install -y libxslt1-dev libjpeg-dev libpng-dev libpq-dev libgdal-dev libgdal20
sudo apt install -y software-properties-common build-essential
sudo apt install -y git unzip gcc zlib1g-dev libgeos-dev libproj-dev
sudo apt install -y sqlite3 spatialite-bin libsqlite3-mod-spatialite
# Install Openjdk
sudo -i apt update
sudo apt install openjdk-8-jdk-headless default-jdk-headless -y
sudo update-java-alternatives --jre-headless --jre --set java-1.8.0-openjdk-amd64
```
Error? After
sudo update-java-alternatives --jre-headless --jre --set java-1.8.0-openjdk-amd64

-->
sudo update-alternatives --config java

Then select the preferred version.
-->For our case, 'java-1.8.0' so select 'java-8'

But, does not look like something running...
But with `java -version`, we can confirm the following, so should be fine

```
# Install VIM
sudo apt install -y vim
sudo apt update -y
sudo apt upgrade -y
sudo apt autoremove -y
sudo apt autoclean -y
sudo apt purge -y
sudo apt clean -y
```
Create a Dedicated User
```
# Follow the prompts to set the new user's information.
# It is fine to accept the defaults to leave all of this information blank.
sudo adduser geonode
```
password
maryun
Other: default

```
# The following command adds the user geonode to group sudo
sudo usermod -aG sudo geonode
# make sure the newly created user is allowed to login by ssh
# (out of the scope of this documentation) and switch to User geonode
su geonode
```
GeoNode Installation
## use a python virtual environment
```
# Create the GeoNode Virtual Environment (first time only)
sudo virtualenv geonode
```
If the command prompt does NOT shows a (geonode) prefix...
How to activate
```
go to the following directory, and activate (geonode) by source ./activate
/home/ubuntu/geonode/bin$ source ./activate
```
```
The next time you need to access the Virtual Environment just run
sudo workon geonode
```
```
# Let's create the GeoNode core base folder and clone it
sudo mkdir -p /opt/geonode/
sudo usermod -a -G www-data geonode
sudo chown -Rf geonode:www-data /opt/geonode/
sudo chmod -Rf 775 /opt/geonode/
# Clone the GeoNode source code on /opt/geonode
cd /opt
git clone https://github.com/GeoNode/geonode.git geonode
```
```
# Install the Python packages
cd /opt/geonode
pip install -r requirements.txt --upgrade --no-cache --no-cache-dir
```
Error

```
ERROR: parse-type 0.5.2 has requirement six>=1.11, but you'll have six 1.10.0 which is incompatible.
ERROR: kombu 4.6.5 has requirement amqp==2.5.1, but you'll have amqp 2.5.2 which is incompatible.
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/home/ubuntu/geonode/lib/python2.7/site-packages/PIL'
Consider using the `--user` option or check the permissions.
```
--> Use sudo! as follows.
```
sudo pip install -r requirements.txt --upgrade --no-cache --no-cache-dir
```
```
sudo pip install -e .
```

```
# Install GDAL Utilities for Python
sudo pip install pygdal=="`gdal-config --version`.*"
```
## Run GeoNode for the first time in DEBUG Mode
```
# Prepare the GeoNode SQLite database (the first time only)
sudo paver setup
sudo paver sync
```
```
# Run the server in DEBUG mode
sudo paver start
```

Installation was done successfuly. However, unfortunately,
**due to lack of memory, geonode cannnot be run.**

[http://18.204.212.236:8000/](http://18.204.212.236:8000/)