# Publ: Apache+mod_proxy or nginx

Last updated:

Configuring Publ to work with Apache or nginx is largely the same either way, the difference being in how you point the server to your Publ instance.

First, you need to decide which local port to run the site on. For this guide we’ll use an example port of 5120, but any port that isn’t taken by another service is fine. (Advanced users might want to consider using a UNIX-domain socket instead, but setting that up is outside the scope of this guide.)

## Running the Publ instance

Your Publ environment needs to have a WSGI server installed. This guide assumes you’re using gunicorn although any WSGI server should work. On that note, you’ll probably need to install gunicorn into your Publ environment; if you’re using pipenv that’ll be

pipenv install gunicorn


Next, you need something to launch your site onto the assigned port; here are a few options:

### systemd

If you’re on a UNIX that uses systemd, the preferred approach is to run the site as a system service. Here is an example systemd launcher (e.g. /etc/systemd/system/example.com.service):

[Unit]
Description=example.com website
After=network.target

[Service]
Restart=always
ExecStart=/home/USERNAME/.local/bin/pipenv run gunicorn -b 127.0.0.1:5120 main:app

[Install]
WantedBy=multi-user.target

### cron

Another approach is to use cron as your service launcher; first, make a file like cron-launcher.sh in your site’s directory:

#!/bin/sh

cd $(dirname "$0")