Visitors must not be able to request app/etc/env.php. Adobe’s nginx.conf.sample, included from the vhost, serves the shop from pub even when $MAGE_ROOT points at the project root. A missing sites-enabled folder, a missing nano, and a certbot lock error are three different problems. Only the first one is about where the vhost lives.

ls: cannot access '/etc/nginx/sites-enabled': No such file or directory
bash: nano: command not found
[Errno 13] Permission denied: '/var/log/letsencrypt/.certbot.lock'
nano is an editor. Its absence does not stop TLS. Use vi, or install nano if you want that editor. Do not treat the install as the certificate fix.
Debian and Ubuntu include /etc/nginx/sites-enabled. RHEL, many Docker images, and some panels include /etc/nginx/conf.d/*.conf and never create sites-enabled. Creating sites-enabled and a symlink does nothing if nginx.conf does not include that directory.
nginx -V 2>&1 | tr ' ' '\n' | grep conf-path
grep -n include /etc/nginx/nginx.conf
Put the Magento file in a directory that include already names. Then:
sudo nginx -t && sudo systemctl reload nginx
nginx -t must say syntax is ok before you reload. A reload of a bad file drops the sites that were working.
Adobe’s Nginx install page is the file to follow. The vhost sets $MAGE_ROOT to the project root and includes nginx.conf.sample. The sample then serves files from pub. The docroot note says the same thing: with that include, you are already serving pub. Do not also set root to pub yourself and fight the sample.
Ubuntu keeps vhosts in sites-available and enables one with a symlink into sites-enabled. CentOS and many containers use conf.d and have no sites-enabled at all. Use the directory this Nginx already includes.
upstream fastcgi_backend {
server unix:/run/php/php8.3-fpm.sock;
}
server {
listen 80;
server_name shop.example;
set $MAGE_ROOT /var/www/shop;
include /var/www/shop/nginx.conf.sample;
}
Replace the socket with the one listen = in your php-fpm pool. Replace the paths. Then sudo nginx -t and reload.
The sample’s deny rules are the security control. If you skip the include and point root at the project root, env.php is on the internet. If you write your own server block, the document root has to be pub, and you still need equivalent deny rules.
After HTTPS works, set Magento’s secure and unsecure base URLs to https://your-host/ and flush config cache. A certificate with an HTTP base URL still posts the storefront to HTTP.
Permission denied on /var/log/letsencrypt/.certbot.lock means this user cannot write Let’s Encrypt’s log directory. Someone else, usually root, created it. Paste the mode from ls -ld into the chmod calculator to see whether owner, group, or other can write.
ls -ld /var/log/letsencrypt /var/log/letsencrypt/.certbot.lock
Run certbot the same way the package expects, which on Linux is root:
sudo certbot --nginx
Use the instructions for your OS and web server. --nginx only works when the Nginx plugin can edit the vhost. If Nginx was installed from a layout certbot does not know, use webroot or a DNS challenge instead of inventing sites-enabled.
If a certbot process is running, leave the lock. Deleting .certbot.lock while certbot is mid-renew corrupts the run. Delete it only when ps shows no certbot and you still cannot start because the file is stale and owned by a user you are not.
An expired certificate is not the lock error. After certbot can write the directory, sudo certbot certificates shows the expiry. Renew, reload Nginx, and only then change Magento’s base URL if it was still HTTP.
Run sudo nginx -t before every reload. A syntax error in the vhost keeps the previous config running, so a reload that prints nothing useful is not proof that the sample file was included.
curl -I https://your-host/ returns 200 or a Magento redirect, and the certificate name matches the host.curl -I https://your-host/static/ is not a listing of the Magento root.https://your-host/app/etc/env.php is denied.https.nginx -t fails on the sample because root or the fastcgi socket path is wrong. Fix the path it names. Do not comment out the deny rules to get a green test.Not if you include nginx.conf.sample. Set MAGE_ROOT to the project root and let the sample serve pub.
Often no. CentOS and many containers include conf.d instead. Put the vhost where nginx.conf already includes files.
Only when no certbot process is running and the file is stale. Deleting it mid-renew corrupts the run.