Some useful nginx config files for sites.
- Copy the appropriate config file and save into nginx site config directory, usually located at
/etc/nginx/sites-available
, and name it like domain name as a good practice. - Edit the config file to satisfy your requirements, then save.
- Symbol link to
/etc/nginx/sites-enabled/
. - Restart nginx service
Those steps can be illustrated as follow commands:
$ sudo vi /etc/nginx/sites-available/example.com
-- edit file then save
$ sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
$ sudo nginx -t
$ sudo systemctl reload nginx
Application | Type | Download | Notes |
---|---|---|---|
WordPress | Simple | Click to Download | - |
WordPress | Advanced | Click to Download | - |
Laravel | Simple | Click to Download | - |
Laravel | Advanced | Click to Download | - |
Drupal | Generic | Click to Download | applied to Drupal v8+ |
Symfony | Simple | Click to Download | applied to Symfony v4+. Reference |
Once you add the config to nginx, you can add Let's Encrypt config to site config via certbot
.
$ sudo certbot --nginx -d example.com -d www.example.com
All necessary config fields for SSL will be added automatically, so you don't have to do anything at this point.