Nginx Installation
How to install OpenDataBio with nginx
2 minute read
These instructions are for an nginx-based installation. If you prefer Apache, use the Apache installation page.
Server requirements
- Supported PHP version >= 8.2 (8.3 recommended).
- Web server: nginx.
- SQL database: MySQL or MariaDB (tested with MySQL 8.0 and MariaDB 10.6+).
- Required PHP extensions:
openssl,pdo,pdo_mysql,mbstring,tokenizer,xml,dom,gd,exif,bcmath,zip,curl,redis. - Redis for queues/cache.
- Tectonic for label PDF generation.
- Pandoc for bibliographic rendering (recommended).
- Supervisor for background jobs.
Nginx site config
Create your site config file (example):
sudo nano /etc/nginx/sites-available/opendatabio
Use this base server block (adjust paths/domain):
server {
listen 80;
server_name your-domain.example;
root /home/odbserver/opendatabio/public;
index index.php index.html;
charset utf-8;
client_max_body_size 300M;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_read_timeout 300;
}
location ~ /\. {
deny all;
}
}
Enable and reload:
sudo ln -s /etc/nginx/sites-available/opendatabio /etc/nginx/sites-enabled/opendatabio
sudo nginx -t
sudo systemctl reload nginx
Content Security Policy (CSP)
Edit the same nginx site file and add inside the server { ... } block:
add_header Content-Security-Policy-Report-Only "
default-src 'self';
base-uri 'self';
form-action 'self';
frame-ancestors 'self';
object-src 'none';
script-src 'self' 'unsafe-eval';
style-src 'self' 'unsafe-inline';
img-src 'self' data: https://server.arcgisonline.com https://*.tile.openstreetmap.org;
font-src 'self' data:;
connect-src 'self';
" always;
Then reload:
sudo nginx -t
sudo systemctl reload nginx
Notes:
- Start with
Report-Only, then move to enforced CSP after validating logs. https://server.arcgisonline.comandhttps://*.tile.openstreetmap.orgare required for map tiles.
Subpath installs (/opendatabio)
If your installation runs under a subpath (for example http://localhost/opendatabio), set in .env:
APP_URL=http://localhost/opendatabio
ASSET_URL=http://localhost/opendatabio
Then refresh generated assets and Livewire files:
php artisan livewire:publish --assets
php artisan optimize:clear
npm run build
Shared application setup
To avoid repeating the same instructions, use these sections from Apache installation (they also apply to nginx deployments):
- PHP settings (php.ini) in Apache Installation
- Configure supervisord in Apache Installation
- Folder permissions in Apache Installation
- Install OpenDataBio in Apache Installation
- Post-install configs in Apache Installation