Updated: 28 September 2026 · Applies to: Ubuntu 24.04 LTS
Ubuntu 18.04 is no longer supported, so this guide now uses Ubuntu 24.04 LTS.
Move a site's files to another location, for example a larger disk mounted at /data, and point Nginx to it.
Steps
- Copy the files, keeping owners and permissions:
rsync -a /var/www/example.com/ /data/www/example.com/
- Change the
rootline in the site's server block to/data/www/example.com. - Test and reload:
nginx -t && systemctl reload nginx. - Check the site, then remove the old copy.
Note: Every folder in the new path must be readable by the Nginx user. On AlmaLinux 9 / Rocky Linux 9 also set the SELinux label: semanage fcontext -a -t httpd_sys_content_t "/data/www(/.*)?" && restorecon -R /data/www.