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

  1. Copy the files, keeping owners and permissions:
    rsync -a /var/www/example.com/ /data/www/example.com/
  2. Change the root line in the site's server block to /data/www/example.com.
  3. Test and reload: nginx -t && systemctl reload nginx.
  4. 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.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Linux server management

hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.

Was this answer helpful?

Still stuck? Open a ticket