Set up · 03
VPS server setup
The production target is one Ubuntu VPS under /srv/perfumz. This runbook installs the host, database, application service and Nginx edge in the order that keeps the first deploy boring.
Host prerequisites
- Ubuntu 22.04/24.04 with a non-root
perfumzaccount and key-based SSH. - A DNS record for
perfumz.comandwww. Add the optional short host only if you will use it. - At least 2 GB RAM and enough disk for the database, media and backups.
- Outbound HTTPS for payment, email and social providers.
sudo apt update
sudo apt install -y python3 python3-venv python3-dev \
postgresql postgresql-client libpq-dev \
nginx certbot python3-certbot-nginx curl unzip
Upload and extract the purchased release
Download the release ZIP from the marketplace where you bought Perfumz. There is no repository to clone and no developer checkout to request.
# From your workstation:
scp perfumz-<edition>-<version>.zip perfumz@<host>:/tmp/
# On the server:
sudo install -d -o perfumz -g perfumz /srv
sudo -u perfumz unzip /tmp/perfumz-<edition>-<version>.zip -d /srv
cd /srv/perfumz
sudo chown -R perfumz:perfumz /srv/perfumzThe archive contains a top-level perfumz/ directory. The unit files, Nginx aliases and scripts use /srv/perfumz by convention, not by requirement. For a home-directory or shared-VPS install, use the placeholder demo service and Nginx templates and keep the service, aliases, database and port aligned; see deploy/DEMO_DEPLOY.md.
Keep the original release ZIP and its SHA-256 sidecar. You will use the next ZIP for updates and the previous ZIP for application rollback.
PostgreSQL
sudo -u postgres psql <<'SQL'
CREATE USER perfumz WITH PASSWORD 'change-me';
CREATE DATABASE perfumz OWNER perfumz;
ALTER ROLE perfumz SET client_encoding TO 'utf8';
ALTER ROLE perfumz SET default_transaction_isolation TO 'read committed';
ALTER ROLE perfumz SET timezone TO 'UTC';
SQLUse a strong password, store it in .env, and keep PostgreSQL bound to loopback or a private network. The production settings use DB_HOST=127.0.0.1 by default.
Environment and bootstrap
Create the production environment from the template and fill in the secret, database password, email credentials and canonical URL:
bash deploy/prod_setup.sh
# edit .env, then:
bash deploy/prod_setup.sh --bootstrap--bootstrap creates the built-in CMS pages (home, shop, journal, about, contact, help, legal and library routes) without demo products, users or orders. Add --seed only when you explicitly want the demo showroom on a fresh database; change the seeded passwords immediately.
Do not run --seed against a database with real customers. It creates demo users, products and orders by design. To repair missing pages on an existing storefront, run seed_perfumz --pages-only.
systemd units
sudo cp deploy/perfumz.service \
deploy/perfumz-jobs.service deploy/perfumz-jobs.timer \
/etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now perfumz perfumz-jobs.timer| Unit | Responsibility |
|---|---|
perfumz.service | Gunicorn WSGI on 127.0.0.1:8007; systemd notify, worker recycling and service hardening. |
perfumz-jobs.timer | Runs run_scheduled_jobs every five minutes. |
There is no Daphne, Celery or Redis unit. The application is WSGI-only and the scheduled work is handled by the jobs command.
Nginx and TLS
sudo cp deploy/nginx.conf /etc/nginx/sites-available/perfumz.conf
sudo ln -sfn /etc/nginx/sites-available/perfumz.conf \
/etc/nginx/sites-enabled/perfumz.conf
sudo rm -f /etc/nginx/sites-enabled/default
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx \
-d perfumz.com -d www.perfumz.comInstall deploy/nginx-tls.conf after the certificate exists. Nginx serves /static/, /media/ and /documentations/ directly and proxies everything else to Gunicorn.
For the optional short-link host, add its DNS record, set SHORTLINK_DOMAIN, and include it in the certificate. The /i/<code>/ form needs no extra DNS.
Optional S3 + CloudFront
Local media remains the default. To use S3/CloudFront, create the bucket and distribution, set the storage values in .env, then install the credential drop-in and restart the service:
sudo install -d -m 750 -o root -g perfumz /etc/perfumz
sudo install -m 640 -o root -g perfumz deploy/aws-storage.env.example /etc/perfumz/aws-storage.env
sudo install -d /etc/systemd/system/perfumz.service.d
sudo install -m 644 deploy/aws-storage.conf /etc/systemd/system/perfumz.service.d/aws-storage.conf
sudo systemctl daemon-reload
sudo systemctl restart perfumzRun collectstatic after the restart and verify a public image, the authenticated private-media route and the CDN purge controls in the media library.
Verify the host
curl -fsS http://127.0.0.1:8007/health/ready/
curl -fsSI https://perfumz.com/ | head -20
sudo systemctl status perfumz --no-pager
systemctl list-timers 'perfumz*'
sudo journalctl -u perfumz -n 100 --no-pagerReadiness must report database: ok and cache: ok. A public response should include HSTS, X-Content-Type-Options, X-Frame-Options: DENY and the secure session cookie after sign-in.