Move an Nginx document root by copying the site files to the new directory, changing the active server block’s root directive, checking any location-specific overrides, testing the configuration, and reloading Nginx. Keep the original directory until requests for the home page, a nested asset, and an application route all work from the new path.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
What Nginx’s web root actually controls
The root directive defines the filesystem base Nginx uses for a request. Nginx appends the request URI to that base. With root /srv/my-site/html;, a request for /images/logo.png maps to /srv/my-site/html/images/logo.png. The directive can be set at server level or inside a location block.
As an Amazon Associate I earn from qualifying purchases.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →A root migration therefore has two separate jobs: put the content at the new filesystem path and make sure the server block selected for the request points there. Copying files without changing configuration leaves Nginx serving the old directory; changing configuration without copying them produces 404 responses.
Find the configuration Nginx is using
Do not assume that every installation uses the same directory layout. Distribution packages commonly place configuration below /etc/nginx, while source builds and non-Linux systems may use another path. Ask the installed binary for its compiled configuration path:
#1 Best Overall
- BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
- EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
- COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
- LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
- WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
nginx -V 2>&1 | awk -F: '/configure arguments/ {print $2}'
Look for the --conf-path argument. That file is the main configuration entry point; it may include a directory containing individual server blocks.
Ubuntu and Debian package layout
On Ubuntu, the default virtual host is commonly enabled at /etc/nginx/sites-enabled/default. The editable counterpart is normally in /etc/nginx/sites-available/. If the site uses a custom hostname, inspect all enabled files rather than editing the default blindly:
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutesudo grep -R "^[[:space:]]*root[[:space:]]" /etc/nginx/sites-enabled /etc/nginx/conf.d 2>/dev/null
Also identify the server_name that matches the hostname you test. Nginx can select a different server block for the same IP and port, making a correct edit appear ineffective.
Record the current state before changing it
- Write down the current
rootpath and the activeserver_name. - Note any
root,alias, andtry_filesdirectives inside nested locations. - Keep the old directory unchanged until verification and rollback checks are complete.
Create the destination and copy the site
Create the new directory with its intended ownership and parent structure. The following path is a valid example:
sudo mkdir -p /srv/my-site/html
Copy the existing document-root contents into it. For a live site, preserve file modes, ownership, symbolic links, and extended attributes as required by your deployment model. A straightforward local copy is:
Rank #2
- WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
- AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
- PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
- ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
- COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
sudo cp -a /var/www/html/. /srv/my-site/html/
The -a option preserves common metadata and follows the source tree in archive mode; inspect the result rather than assuming it matches your production policy. If the old root contains a symlink, decide whether the link should remain a link or whether its target should move as well. A link that still points to a removed or inaccessible target can cause a 404 or 403 after the migration.
Check the copied tree
sudo find /srv/my-site/html -maxdepth 2 -type f | head
sudo ls -la /srv/my-site/html
Confirm that the expected index file, static assets, upload directories, and application entry points are present. Do not delete the old tree at this stage.
Edit the server block
Open the server-block file that handles the site and change only the document-root path first:
server {
listen 80;
server_name example.com www.example.com;
root /srv/my-site/html;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
}
Keep the existing index directive, proxy settings, FastCGI parameters, TLS directives, headers, and other application handlers unless the application specifically requires a related change. A root move is not automatically a rewrite of URL routing.
Understand the try_files interaction
In the example, try_files $uri $uri/ =404; checks for a file or directory under the current root and returns 404 if neither exists. Because the root changed, every candidate is now evaluated below /srv/my-site/html. If a single-page application uses a fallback such as try_files $uri $uri/ /index.html;, ensure that the fallback file exists in the new tree.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteRank #3
- Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
- Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
- Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
- ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
- Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
Audit location-specific roots, aliases, and symlinks
A server-level root is not necessarily the only path in use. Nginx chooses the most specific matching location, and a root declared there can override the server-level value. Search the complete configuration for these directives:
sudo nginx -T | grep -nE '(^|[[:space:]])(root|alias|try_files)[[:space:]]'
nginx -T prints the configuration Nginx has loaded, including included files. Review each match in context.
root versus alias
| Directive | URI-to-filesystem behavior | Use when | Migration concern |
|---|---|---|---|
root |
Nginx appends the complete request URI to the configured directory. | The URL path should be retained beneath a common document root. | Every relevant URI is resolved below the new base; nested locations can still override it. |
alias |
Nginx replaces the matching location prefix with the configured filesystem path. | A URL prefix should map to a different directory whose name does not mirror that prefix. | Re-check location and trailing-slash behavior; a path that worked with root can map differently with alias. |
For example, with location /media/ { root /srv/my-site/html; }, /media/a.jpg maps beneath /srv/my-site/html/media/a.jpg. With location /media/ { alias /srv/uploads/; }, the same URI maps to /srv/uploads/a.jpg. Do not replace one directive with the other merely to move the main root; retain the existing semantics unless the URL-to-filesystem relationship must change.
Set traversal and read permissions safely
Nginx’s worker account must be able to traverse every parent directory and read the requested files. Ubuntu’s basic example uses:
sudo chmod -R 755 /srv/my-site/html
This is a broad baseline, not a universal security recommendation. Adapt ownership, group membership, file modes, private upload directories, and deployment rules to the application. A directory can be readable while one parent directory blocks traversal; check every component from the filesystem root to the file:
Rank #4
- Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
- Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
- 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
- Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
- USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
namei -l /srv/my-site/html/index.html
Find the worker account in the service configuration or process list, then verify that account’s effective access. Avoid making secrets, environment files, backups, or writable upload areas world-readable just to eliminate a 403.
Mandatory access controls
On systems using SELinux, AppArmor, or another mandatory-access-control policy, ordinary Unix modes may look correct while the policy still denies Nginx. The exact remediation depends on the distribution, policy, and labeling rules. Check the security audit log and apply the platform’s documented method for assigning the appropriate web-content context or profile permission; do not disable the protection as a first response.
Validate and reload without stopping the service
Always test syntax and file references before asking Nginx to load the change:
Free tools Windows power users keep installed
One-click scans. No signup required.
sudo nginx -t
A successful test reports that the configuration syntax is okay and the test is successful. If it fails, fix the reported file and line before reloading. Common causes include a missing semicolon, an edit to a file that is not included, a misspelled directory, or a duplicate/conflicting directive.
After a successful test, reload Nginx:
sudo systemctl reload nginx
A reload applies the new configuration while allowing existing workers to finish their current requests; it avoids an intentional full stop. Use the equivalent reload command for the service manager on another operating system.
Best Value
- Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
- Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
- Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
- Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
- Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
Verify the new root from outside and inside the server
Test more than the home page. Use the hostname that selects the intended server block:
curl -I http://example.com/
curl -I http://example.com/css/site.css
curl -i http://example.com/app/route
Replace the sample paths with one known index page, one nested static asset, and one representative application route. Check both status code and response content. A 200 response from an old cached asset is not proof that the new root is active; use a distinctive test file or inspect the returned content when necessary.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Inspect logs when behavior is wrong
Nginx’s access and error logs are the first diagnostic tools. The access log shows which URI was requested and the returned status. The error log often identifies permission denials, missing files, failed symlink resolution, or upstream problems. Follow the paths configured by your installation:
sudo tail -f /var/log/nginx/access.log /var/log/nginx/error.log
If those files do not exist, inspect the loaded configuration for custom access_log and error_log destinations.
Fix the common post-migration failures
A 403 Forbidden response
- Check execute permission on every parent directory and read permission on the requested file.
- Check whether the request resolves to a directory with no configured index file. Nginx may refuse directory listing rather than expose its contents.
- Inspect symlink targets and verify that the worker account can traverse the target path.
- Review SELinux, AppArmor, or another mandatory-access-control policy if Unix permissions are correct.
- Read the error log for the exact path Nginx attempted to open.
The old content is still served
- Confirm that the request’s hostname and port select the edited
serverblock. - Search for a more specific
locationcontaining its ownrootoralias. - Check for a deployment symlink or include file that still points at the former directory.
- Run
sudo nginx -Tand verify that the loaded configuration contains the new path, then reload after any correction.
A 404 appears only for assets or application routes
- Confirm that the corresponding files were copied, including case-sensitive filenames.
- Recalculate the path produced by
rootoraliasfor that exact URI. - Inspect
try_filesfallbacks and make sure their target files exist in the new tree. - Check application-specific proxy or FastCGI handlers; a root move does not change an upstream application’s own filesystem path.
nginx -t succeeds but the result does not change
The test may have examined a configuration different from the service’s startup configuration, or the reload may have targeted a different installation. Compare the service unit’s executable and configuration arguments with the nginx -V output, then inspect the running configuration with nginx -T. Verify the reload command returned successfully and check the service status.
Rollback safely
If representative requests fail and the cause is not immediately clear, revert the server block’s root line to the original path, run sudo nginx -t, and reload. Because the original directory was retained, this restores the previous content without reconstructing files. Leave the copied destination in place while investigating so you can compare permissions, symlinks, and file lists. Remove the old tree only after the new path has passed normal traffic checks and any deployment or backup process has been updated.
Quick Recap
Migration checklist
- Identify the compiled configuration path and the server block selected by the site hostname.
- Create the destination directory and copy content with the metadata your application requires.
- Change the correct
rootdirective; preserve unrelated handlers. - Audit nested
locationblocks,aliasdirectives,try_filesrules, and symlinks. - Verify parent-directory traversal, file readability, and mandatory-access-control policy.
- Run
sudo nginx -t, thensudo systemctl reload nginx. - Request the home page, a nested asset, and an application route; inspect access and error logs.
- Keep the old root until the migration is proven, and revert the root line if rollback is required.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




