Install OpenEats without Docker and run on Apache2
Install dependencies
apt-get install python3 python3-pip git build-essential
Nodejs
Install nodejs
curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh
bash nodesource_setup.sh
Further help to installing nodejs: https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-debian-8
Database
We will use Mariadb but if you have working MySQL server you can skip the Mariadb installation part.
install Mariadb
Add mariadb repository to /etc/apt/sources.list.d/mariadb.conf
apt-get install software-properties-common dirmngr
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://ftp.bme.hu/pub/mirrors/mariadb/repo/10.1/debian stretch main'
apt-get update
apt-get install mariadb-server
Create openeats user and database in mariadb (ssh)
Log into your MySQL database
mysql -p
Create database
create database openeats;
Create a database user and password
Change username and password. You will have to change in configuration files too-
grant all privileges on openeats.* to 'username'@'localhost' identified by "password";
Commit changes
flush privileges;
Exit from mysql
exit;
Create directory infrastructure
mkdir /opt/openeats/
mkdir /opt/openeats/openeats-apache2/
Set up the openeats-api
cd /opt/openeats/
Get the source of openeats-api from git
git clone https://github.com/open-eats/openeats-api.git
cd /opt/openeats/openeats-api
Install the python requirements
pip3 install -r /opt/openeats/openeats-api/base/requirements.txt
Create .env environment file
touch /opt/openeats/openeats-api/.env
Edit the created .env file and insert the following data in it
Read the comments carefully and change the necessary parts to your configuration.
Our api will listen on port 5210.
# Database config
MYSQL_HOST=localhost
MYSQL_DATABASE=openeats
MYSQL_USER=username
MYSQL_ROOT_PASSWORD=password
# Django config
API_URL=0.0.0.0:5210
API_PORT=5210
DJANGO_SECRET_KEY=CHANGE_THIS:SECRETKEY
DJANGO_SETTINGS_MODULE=base.settings
DJANGO_DEBUG=False
ALLOWED_HOST=openeats.domain.com # if you running from a domain you have to specify the hostname here [default value was localhost]
# If you are serving content behind an HTTPS proxy,
# Set this to `true`.
# See: https://docs.djangoproject.com/en/1.10/ref/settings/#secure-proxy-ssl-header
HTTP_X_FORWARDED_PROTO=true # We are using ssl maybe you need to change it back to false
# Node config
NODE_ENV=development
NODE_URL=openeats.domain.com:5200 # As far as I tested the port can be anything here we wont use it
NODE_API_URL=https://openeats.domain.com # the openeats domain with http or https
NODE_LOCALE=en
Edit the /opt/openeats/openeats-api/base/prod-entrypoint.sh
file
The paths should be adjusted to your infrastructure
#!/usr/bin/env sh
BASEDIR=/opt/openeats/openeats-api
# Update the DB if it needs it and compile static files.
python3 $BASEDIR/manage.py migrate --no-input
python3 $BASEDIR/manage.py collectstatic --no-input
# Start up gunicorn
bash $BASEDIR/base/gunicorn_start.sh
Edit the /opt/openeats/openeats-api/base/gunicorn_start.sh
file
The paths should be adjusted to your infrastructure
#!/usr/bin/env sh
NAME="OpenEats" # Name of the application
DJANGODIR=/opt/openeats/openeats-api # Django project directory
USER=root # the user to run as
GROUP=root # the group to run as
NUM_WORKERS=5 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=base.settings # which settings file should Django use
DJANGO_WSGI_MODULE=base.wsgi # WSGI module name
echo "Starting $NAME as `whoami`"
# Activate the virtual environment
cd $DJANGODIR
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH
# Start your Django Unicorn
# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon)
exec gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers $NUM_WORKERS \
--user=$USER --group=$GROUP \
--bind=$API_URL
Create systemd service to run the api
Create and edit /lib/systemd/system/openeats.service
[Unit]
Description=OpenEats
After = mariadb.service systemd-user-sessions.service network-online.target systemd-networkd.service
[Service]
Type=simple
User=root
EnvironmentFile=/opt/openeats/openeats-api/.env
ExecStart =/usr/bin/ionice -c 3 /usr/bin/nice -n 18 /bin/bash /opt/openeats/openeats-api/base/prod-entrypoint.sh
Restart = always
RestartSec = 1
# Configures the time to wait before service is stopped forcefully.
TimeoutStopSec=2000
[Install]
WantedBy=multi-user.target
Start the api
systemctl start openeats.service
Check if the api running correctly
systemctl status openeats.service
Set up the openeats-web
cd /opt/openeats/
Get the source of openeats-Web from git
git clone https://github.com/open-eats/openeats-web.git
cd /opt/openeats-web/
Create environment file in /opt/openeats-web/
touch /opt/openeats-web/.env
Edit the created .env file and insert the following data in it
Read the comments carefully and change the necessary parts to your configuration.
This should contain the same values like .env in the openeats-api directory, but every line should start with export Our api will listen on port 5210.
# Database config
export MYSQL_HOST=localhost
export MYSQL_DATABASE=openeats
export MYSQL_USER=username
export MYSQL_ROOT_PASSWORD=password
# Django config
export API_URL=0.0.0.0:5210
export API_PORT=5210
export DJANGO_SECRET_KEY=CHANGE_THIS_SECRETKEY_TO_RANDOM_STRING
export DJANGO_SETTINGS_MODULE=base.settings
export DJANGO_DEBUG=False
export ALLOWED_HOST=openeats.domain.com # if you running from a domain you have to specify the hostname here [default value was localhost]
# If you are serving content behind an HTTPS proxy,
# Set this to `true`.
# See: https://docs.djangoproject.com/en/1.10/ref/settings/#secure-proxy-ssl-header
export HTTP_X_FORWARDED_PROTO=true # We are using ssl maybe you need to change it back to false
# Node config
export NODE_ENV=development
export NODE_URL=openeats.domain.com:5200 # As far as I tested the port can be anything here we wont use it
export NODE_API_URL=https://openeats.domain.com # the openeats domain with http or https
export NODE_LOCALE=en
Load the environment values
cd /opt/openeats-web/
. ./.env
install the dependecies
npm install
npm install yarn
Build openeats-web
$ /opt/openeats-web/node_modules/yarn/bin/yarn start
This will create a build
directory in /opt/openeats-web/
Apache 2
Install Apache2
apt-get install apache2
Create symbolic links for Apache2
cd /opt/openeats/openeats-apache2/
ln -s /opt/openeats/openeats-web/build /opt/openeats/openeats-apache2/public-ui
ln -s /opt/openeats/openeats-api/static-files /opt/openeats/openeats-apache2/static-files
ln -s /opt/openeats/openeats-api/site-media /opt/openeats/openeats-apache2/site-media
Openeats will create the site-media directory when you upload the first image.
Edit /etc/apache2/sites-available/default.conf
<VirtualHost *:80>
ServerName openeats.domain.com
ServerAdmin postmaster@domain.com
Header always set Strict-Transport-Security "max-age=15768000"
DocumentRoot "/opt/openeats/openeats-apache2/public-ui"
<Directory "/opt/openeats/openeats-apache2/public-ui">
# HANDLE 404 ERROR ON REFRESH
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
# HANDLE 404 ERROR ON REFRESH END
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
Alias /static /opt/openeats/openeats-apache2/public-ui/static
<Location "/static/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
</Location>
<Location "/api/">
ProxyPass http://127.0.0.1:5210/api/
ProxyPassReverse http://127.0.0.1:5210/api/
</Location>
<Location "/admin/">
ProxyPass http://127.0.0.1:5210/admin/
ProxyPassReverse http://127.0.0.1:5210/admin/
</Location>
Alias /static-files /opt/openeats/openeats-apache2/static-files
<Directory "/opt/openeats/openeats-apache2/static-files">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
Alias /site-media /opt/openeats/openeats-apache2/site-media
<Directory "/opt/openeats/openeats-apache2/site-media">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
</VirtualHost>
Reload Apache configuration
service apache2 reload
Your openeats installation should run on your http://openeats.domain.com
Updating openeats
cd /opt/openeats/
Get the update from git sources
git clone https://github.com/open-eats/openeats-api.git
git clone https://github.com/open-eats/openeats-web.git
Update the paths in your configuration files
Rebuild openeats-web
Restart services
systemctl restart openeats.service
systemctl reload apache2.service
No Comments