diff --git a/README.md b/README.md index b3c1e502723dba62fee58f96f7f50bc84bca3b33..48eb11ec061e117c4625175c0861b06449ad5afe 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ AKPlanning has two types of requirements: System requirements are dependent on o * Virtualenv * for production using uwsgi: * C compiler e.g. gcc + * uwsgi * uwsgi Python3 plugin * for production using Apache (in addition to uwsgi) * the mod proxy uwsgi plugin for apache2 @@ -79,7 +80,6 @@ Remember to use a secret key that is not stored in any repository or similar, an 1. activate virtualenv ``source env/bin/activate`` 1. update tools ``pip install --upgrade setuptools pip wheel`` 1. install python requirements ``pip install -r requirements.txt`` -1. install uwsgi ``pip install uwsgi`` 1. create the file ``AKPlanning/settings_secrets.py`` (copy from ``settings_secrets.py.sample``) and fill it with the necessary secrets (e.g. generated by ``tr -dc 'a-z0-9!@#$%^&*(-_=+)' < /dev/urandom | head -c50``) (it is a good idea to restrict read permissions from others) 1. if necessary enable uwsgi proxy plugin for Apache e.g.``a2enmod proxy_uwsgi`` 1. edit the apache config to serve the application and the static files, e.g. on a dedicated system in ``/etc/apache2/sites-enabled/000-default.conf`` within the ``VirtualHost`` tag add: @@ -94,39 +94,13 @@ Remember to use a secret key that is not stored in any repository or similar, an ProxyPass / uwsgi://127.0.0.1:3035/ ``` - or create a new config (.conf) file under ``/etc/apache2/sites-available``, fill it with something like: - - ```` - <VirtualHost *:80> - - ServerName $SUBDOMAIN - - ServerAdmin $MAILADDRESS - - ErrorLog ${APACHE_LOG_DIR}/error.log - CustomLog ${APACHE_LOG_DIR}/access.log combined - - Alias /static /srv/AKPlanning/static - <Directory /srv/AKPlanning/static> - Require all granted - </Directory> - - ProxyPassMatch ^/static/ ! - ProxyPass / uwsgi://127.0.0.1:3035/ - - RewriteEngine on - RewriteCond %{SERVER_NAME} =$SUBDOMAIN - RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] - </VirtualHost> - ```` - - replacing $SUBDOMAIN with the subdomain the system should be available under, and $MAILADDRESS with the e-mail address of your administrator. Then symlink it to ``sites-enabled`` e.g. by using ``ln -s /etc/apache2/sites-available/akplanning.conf /etc/apache2/sites-enabled/akplanning.conf``. + or create a new config (.conf) file (similar to ``apache-akplanning.conf``) replacing $SUBDOMAIN with the subdomain the system should be available under, and $MAILADDRESS with the e-mail address of your administrator. Copy or symlink it to ``/etc/apache2/sites-available``. Then symlink it to ``sites-enabled`` e.g. by using ``ln -s /etc/apache2/sites-available/akplanning.conf /etc/apache2/sites-enabled/akplanning.conf``. 1. restart Apache ``sudo systemctl restart apache2.service`` 1. create a dedicated user, e.g. ``adduser django`` 1. transfer ownership of the folder to the new user ``chown -R django:django /srv/WannaDB`` -1. change to the new user ``sudo su django`` -1. change into the Django project folder ``cd WannaDB`` -1. start uwsgi using the configuration file ``uwsgi --ini uwsgi-akplanning.ini`` +1. Copy or symlink the uwsgi config in ``uwsgi-akplanning.ini`` to ``/etc/uwsgi/apps-available/`` and then symlink it to ``/etc/uwsgi/apps-enabled/`` using e.g., ``ln -s /srv/AKPlanning/uwsgi-akplanning.ini /etc/uwsgi/apps-available/akplanning.ini`` and ``ln -s /etc/uwsgi/apps-available/akplanning.ini /etc/uwsgi/apps-enabled/akplanning.ini`` +start uwsgi using the configuration file ``uwsgi --ini uwsgi-akplanning.ini`` +1. restart uwsgi ``sudo systemctl restart uwsgi`` 1. execute the update script ``./Utils/update.sh --prod`` diff --git a/apache-akplanning.conf b/apache-akplanning.conf new file mode 100644 index 0000000000000000000000000000000000000000..7d1b54ee60bea7feb601f49639e0aa7a738e77c8 --- /dev/null +++ b/apache-akplanning.conf @@ -0,0 +1,21 @@ +<VirtualHost *:80> + + ServerName $SUBDOMAIN + + ServerAdmin $MAILADDRESS + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + + Alias /static /srv/AKPlanning/static + <Directory /srv/AKPlanning/static> + Require all granted + </Directory> + + ProxyPassMatch ^/static/ ! + ProxyPass / uwsgi://127.0.0.1:3035/ + + RewriteEngine on + RewriteCond %{SERVER_NAME} =$SUBDOMAIN + RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] +</VirtualHost>