-
Notifications
You must be signed in to change notification settings - Fork 5
Deployment: Nginx & uWSGI
These directions come primarily from a very helpful tutorial created by Vladik Khononov.
-
Install nginx.
# This package will keep nginx up to date. $ sudo yum install epel-release $ sudo yum install nginx # Confirmation step: $ sudo service nginx start
When you navigate to your server's public address in a browser, you should see a generic "Welcome to nginx" page.
-
Install uwsgi in your Library Simplified repo's virtual environment.
# If you're not already in your LS repo, go there, e.g. $ cd YOUR_LS_APP_DIR # Pop into your Python environment & install uWSGI $ source env/bin/activate $ pip install uwsgi
-
Create an appropriately-named directory in a location where nginx will have access. We'll refer to it in the next step as YOUR_UWSGI_SOCKET_DIR. Make sure that both nginx and ec2-user has permissions.
$ mkdir /var/www/circulation $ sudo chown nginx:nginx /var/www/circulation $ sudo chmod 777 /var/www/circulation -
In your LS repo, configure nginx with an
nginx.conffile. For the most up-to-date example, use the file found here. Be sure to change theuwsgi_passvariable to referenceunix:YOUR_UWSGI_SOCKET_DIR/uwsgi.sock. -
Then create a symbolic link to it and restart nginx.
$ sudo ln -s /var/www/circulation/nginx.conf /etc/nginx/conf.d/circulation.conf $ sudo service nginx restart
Now when you navigate to your server's address in a web browser, you should get a 502 error. Fantastic!
-
In your LS repo, configure uWSGI with an
uwsgi.inifile. For the most up-to-date example, use the file found here. Be sure to set thebasevariable to YOUR_LS_APP_DIR, and thesocketvariable toYOUR_UWSGI_SOCKET_DIR/%n.sock -
Enter the virtual environment, and confirm that your uWSGI configuration works.
$ cd YOUR_LS_APP_DIR $ source env/bin/activate $ uwsgi --ini uwsgi.iniYou'll see a single line of text in your terminal:
[uWSGI] getting INI configuration from uwsgi.ini, followed by a blank link. Before ending the process, visit your server's address in the web browser, and you should an OPDS feed that represents your LS app! Make sure that if you're configuring the Metadata Wrangler, you try the/lookuproute for a feed, as the home index is not currently being used. -
If you experience errors during step #7, look to
/var/log/nginx/errors.logand/var/log/uwsgi/emperor.logfor information about what's going wrong. -
Once things are working, run uWSGI in the background:
$ source env/bin/activate $ uwsgi --ini uwsgi.ini &