Robert Cudmore    archive    tags    search    software


Restart nginx

sudo systemctl restart nginx

start myproject.service

sudo systemctl start myproject.service
sudo systemctl stop myproject.service
sudo systemctl restart myproject.service
sudo systemctl status -l myproject.service

sudo systemctl start mmserver.service
sudo systemctl stop mmserver.service
sudo systemctl restart mmserver.service
sudo systemctl status -l mmserver.service

sudo usermod -aG www-data cudmore

sudo chown -R cudmore:www-data /home/cudmore/PyMapManager/*

sudo ln -s /etc/nginx/sites-available/mmserver /etc/nginx/sites-enabled

Move mmclient/ into /var/www/html/

sudo cp -R ~/PyMapManager/mmclient/ /var/www/html/

Now I can browse

Run uWSGI manually

cd /home/cudmore/mmserver
source venv/bin/activate
uwsgi --socket --protocol=http -w mywsgi:app

When i change, restart service

sudo systemctl restart mmserver.service
sudo systemctl status -l mmserver.service

Contents of /home/cudmore/myproject/

from flask import Flask
application = Flask(__name__)

def page_not_found(e):
    # your processing here
    return 'NOT FOUND XXX'

def api():
    return "<H1>API !!!</H1>"

def hello():
    return "<h1 style='color:blue'>Hello There!</h1>"

if __name__ == "__main__":'')

Contents of /home/cudmore/myproject/

from myproject import application

if __name__ == "__main__":

Contents of /home/cudmore/myproject/myproject.ini

module = mywsgi

master = true
processes = 5

socket = myproject.sock
chmod-socket = 660
vacuum = true

die-on-term = true

Contents of /etc/systemd/system/myproject.service

Description=uWSGI instance to serve mmserver

ExecStart=/home/cudmore/myproject/venv/bin/uwsgi --ini myproject.ini


Contents of /etc/nginx/sites-available/myproject

Change this to /etc/nginx/sites-available/mmserver

Need to change cudmore user group

sudo usermod -aG www-data cudmore

Need to link this file into default nginx configuration

ln -s /etc/nginx/sites-available/myproject /etc/nginx/sites-enabled
server {
    listen 80;

    location / {
        root /var/www/html;
        try_files $uri $uri/ /index.html;

    # not working
    location /mmclient {
        root /home/cudmore/PyMapManager/mmclient;
        #root /var/www/html/testclient;
        try_files $uri $uri/ /index.html;

    location /api/v2 {
        include uwsgi_params;
        #uwsgi_pass unix:/home/cudmore/myproject/myproject.sock;
        uwsgi_pass unix:///home/cudmore/mmserver/mmserver.sock;
Tags: nginx, linux

©2018. Robert Cudmore.