Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
FREEDOM251

Freedom251 › Blog › Apache

How to Move an Apache Web Root to a New Location

By Freedom251 Team · · 10 min read

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Move the site files first, then change DocumentRoot in every virtual host that serves the site. Apache must be able to traverse the new path and read the files, and you should run apachectl configtest before a reload. Keep the original directory until the new location has passed hostname, asset, application, HTTP, HTTPS, and log checks.

What Apache’s web root actually controls

The DocumentRoot directive identifies the filesystem directory that forms a site’s document tree. For a request, Apache takes the URL path and appends it to the configured root when it resolves the file to serve. If the root is /srv/www/example, a request for /images/logo.svg is normally looked up beneath that directory.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A root can be configured globally, but production sites commonly define it inside one or more <VirtualHost> blocks. A host-specific value takes precedence for that host, so changing a global directive may appear to do nothing. HTTP and HTTPS are often separate virtual hosts and may point to different directories. Inventory all active hosts before editing.

On Ubuntu, the default virtual host is commonly /etc/apache2/sites-available/000-default.conf, with /var/www/html as its documented default. Other distributions and installation methods use different paths, service names, enabled-site mechanisms, and runtime users.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Choose the right relocation method

Goal Recommended method What changes Main caveat
Move the entire site while keeping its URLs Edit DocumentRoot All paths under the virtual host resolve from the new directory Every applicable virtual host must be updated
Map one URL prefix to files outside the root Use Alias Only the selected URL subtree maps to another filesystem directory The aliased directory needs its own matching <Directory> access policy
Provide a compatibility bridge to an old path Use a symbolic link only when deliberately permitted The old filesystem path points at the new tree Link-following options, ownership, confinement, and deployment tools can prevent it from working
Prepare a temporary rollback Retain the old tree and revert the directive Configuration switches between old and new locations Do not delete the old copy until traffic and backups are verified

For a complete root relocation, changing DocumentRoot is clearer than rewriting every URL. Use an alias when only a deliberate portion of the URL space belongs elsewhere.

Before you change anything

Inventory the running installation

  1. Identify the Apache installation and its control command. Common controls include apachectl, apache2ctl, or a platform service manager.
  2. List enabled virtual hosts. On Ubuntu, inspect /etc/apache2/sites-enabled and open the corresponding files in /etc/apache2/sites-available.
  3. Search all active configuration for DocumentRoot, including SSL hosts, included files, and possible duplicate definitions. Do not assume the global setting controls every hostname.
  4. Record the configured Apache User and Group, the old root, log locations, PHP-FPM or CGI settings, upload directories, cron jobs, and deployment scripts that may contain the old path.

Make a rollback copy

Back up the active configuration and database or application data according to the site’s normal backup policy. Keep the old web tree intact while testing. A file copy must include hidden files such as .htaccess, application configuration files, ownership, permissions, and any extended attributes required by the operating system or security policy. A migration that copies only visible files can silently remove rewrite rules or environment settings.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Confirm the destination storage

The new location must be an existing, mounted absolute path. If it is on another drive or a network filesystem, ensure it is mounted before Apache starts; otherwise the service can see an empty mount point or fail to serve after a reboot. Confirm available space, expected latency, and the site’s backup and restore coverage before switching production traffic.

Prepare the new directory safely

Create and populate the tree

Create the destination directory with administrative privileges, then copy the site content into it. Preserve the directory structure, hidden files, ownership, modes, symbolic links that are part of the application, and required extended attributes. Compare file counts or checksums where practical. Do not alter the old tree while the new copy is being validated; that copy is your simplest rollback.

Set traversal and read permissions

Apache usually starts with elevated privileges and then serves requests as its configured runtime account. That account needs execute (traverse) permission on every parent directory from the filesystem root to the document root, plus read permission for files and traverse permission for directories it must list or enter. An apparently readable document can still return 403 Forbidden when one parent directory blocks traversal.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Grant only the access the application requires. Avoid making the whole tree world-writable: write access should normally be limited to specific upload, cache, or temporary directories, and those directories should not contain executable application code when the application does not need it. Keep Apache configuration directories and server directories outside the runtime account’s write access.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Account for security confinement

Filesystem modes are not the only control. SELinux labels, AppArmor profiles, container mounts, and service sandboxing can restrict a directory even when Unix ownership looks correct. If the new path is on a different filesystem, verify that its security labels and mount policy permit Apache to read it. Apply the same approved labeling and policy used for the old location rather than disabling the security mechanism.

Edit each active virtual host

Change the absolute path in every virtual host that should serve the moved site. A minimal HTTP example is:

<VirtualHost *:80>
    ServerName example.com
    DocumentRoot "/srv/www/example"
    <Directory "/srv/www/example">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

The <Directory> block controls access to the filesystem path; it is not automatically inferred from DocumentRoot. Use only the directives your application needs. Require all granted allows requests to the directory, while AllowOverride All permits .htaccess files to override settings. If your site does not use .htaccess, a narrower AllowOverride policy is safer. Do not copy a permissive example without checking the application’s requirements.

Update the SSL virtual host as well when HTTPS is configured. A common failure is changing the port 80 host while the port 443 host continues serving the old directory. Check each ServerName and ServerAlias that should use the new root.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord | 6.35mm Jack, Durable Design, Stage and Home Studio Use, Low Noise Shielded Electric Cord for Bass, Keyboard, Amp, Mixer
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

When an alias is the better fit

If only a URL prefix belongs on another filesystem, leave the site’s root unchanged and map that prefix explicitly:

Alias "/downloads" "/srv/files/downloads"
<Directory "/srv/files/downloads">
    Require all granted
</Directory>

The alias and its <Directory> policy are separate from the root’s policy. Confirm that the URL prefix does not collide with an application route and that directory listing, download, and authentication behavior are intentional.

Why a symlink is not a universal solution

A link such as /var/www/html pointing to a directory on another drive can preserve an old filesystem path, but Apache may be prevented from following it by Options, security policy, container boundaries, or mount permissions. Deployment and backup tools may also treat the link differently from a real directory. Use a symlink only when its behavior is understood and tested; for a full move, an explicit DocumentRoot is easier to audit.

Enable the intended site and remove duplicates

On Ubuntu, a2ensite creates the enabled-site symlink and a2dissite removes it. Verify that the edited file is enabled and that an older duplicate virtual host is not still active. A duplicate can win host matching and make a correct edit appear ineffective. Distribution layouts differ, so use the equivalent mechanism supplied by your operating system when these commands are unavailable.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Validate before reloading Apache

Run a configuration test

sudo apachectl configtest

On installations that use the alternate control name, run:

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
sudo apache2ctl configtest

A successful test reports Syntax Ok. Fix every reported error before applying the change. Common causes include a misspelled or nonexistent path, unmatched quotes or tags, a module that is not loaded, duplicate host definitions, and a directive placed in an invalid context.

Check the path independently

  • Confirm the destination and every parent directory exist on the running system.
  • Confirm the Apache runtime account can traverse the parents and read a representative HTML, CSS, JavaScript, image, and server-side file.
  • Check that the mount is present under the same path after a reboot or service restart.
  • Verify that .htaccess, rewrite rules, uploads, cache directories, and application-generated files are present and have the intended permissions.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Apply the change and verify real traffic

Use the platform’s reload or graceful-restart command after the configuration test succeeds. A graceful operation lets existing requests finish while workers adopt the new configuration; the exact service command depends on the operating system and installation method. The Apache control command performs a configuration check before initiating a restart, but running an explicit test first makes errors easier to isolate.

Test by hostname, not only by IP address

Request the site using its real Host name. Testing only an IP address can select a different default virtual host and hide a mistake. Check both HTTP and HTTPS when both are configured, and test any alternate names that use ServerAlias.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Verify the complete request path

  • Load the home page and several deep application routes.
  • Open static assets such as stylesheets, scripts, images, fonts, and downloadable files.
  • Submit a representative form or authenticated request if the application uses them.
  • Confirm redirects, rewrite rules, canonical host behavior, and directory-index handling.
  • Check the access log to confirm requests are being served by the expected virtual host and inspect the error log for permission, missing-file, rewrite, or interpreter errors.

A page that loads is not sufficient proof if its assets still come from the old tree or if only the default virtual host was tested.

Troubleshoot common failures

403 Forbidden after the move

  • Check execute permission on every parent directory, not only the document root.
  • Check read permission on the requested file and traverse permission on its containing directories.
  • Inspect the matching <Directory> block for a restrictive Require rule.
  • If the application relies on .htaccess, confirm the relevant AllowOverride setting and that the file was copied.
  • Check SELinux, AppArmor, container policy, and mount options for the new filesystem.
  • Read the error log at the time of the request; it usually identifies the denied path or policy.

Do not solve a 403 by making the entire tree world-writable. Correct the specific ownership, mode, directive, or security label that blocks the request.

The old site still appears

Another virtual host may still be enabled, the request may use a different hostname, or the HTTPS host may still point to the old root. Recheck enabled-site links, all DocumentRoot directives, ServerName/ServerAlias matching, and both service listeners. Browser and proxy caches can also show old content, so compare a distinctive file and inspect the server logs.

Apache will not reload

Run apachectl configtest and correct the first reported error before investigating later messages. Check path quoting, spelling, duplicate directives, missing modules, and whether the destination exists at reload time. If the new filesystem is mounted late during boot, fix the mount dependency rather than repeatedly restarting Apache.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

PHP, CGI, uploads, or scheduled jobs fail

Moving static files does not automatically update services that reference absolute paths. PHP-FPM pools, CGI configuration, upload and cache directories, cron jobs, queue workers, deployment pipelines, backup rules, and application environment variables may still name the old root. Update each dependency deliberately, preserve the least-privilege ownership model, and test writes only in directories that are intended to be writable.

HTTPS works differently from HTTP

Inspect the TLS virtual host separately. It may have its own DocumentRoot, rewrite rules, authentication policy, or aliases. Test the HTTPS hostname directly and review its access and error log entries rather than assuming the port 80 configuration was inherited.

Rollback and retirement

Use the old tree as a controlled fallback

If validation fails, restore the previous DocumentRoot value in each affected virtual host, run the configuration test, and perform a reload or graceful restart. Keep the new copy in place while diagnosing so you can compare permissions, labels, and file contents. Record which configuration was active at the time of the failure.

Remove the old path only after verification

Once requests consistently come from the new location, backups include it, scheduled jobs and deployment tools have been updated, and the rollback window has ended, archive or remove the old directory according to the site’s retention policy. Deleting it immediately can destroy your fastest recovery option and can break an overlooked script that still references the old path.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Migration checklist

  • All active HTTP and HTTPS virtual hosts and their DocumentRoot values are inventoried.
  • The destination filesystem is mounted, backed up, and available after reboot.
  • Content, hidden files, ownership, modes, links, and required attributes were copied.
  • Apache can traverse every parent directory and read the served files.
  • Security labels, AppArmor or container rules, and mount policy allow access.
  • Each intended virtual host has the new absolute path and an appropriately scoped <Directory> block.
  • Ubuntu site enablement, or the equivalent platform mechanism, points to the intended configuration without duplicates.
  • apachectl configtest or apache2ctl configtest returns Syntax Ok.
  • Hostname-based tests cover HTTP, HTTPS, deep routes, assets, uploads, redirects, and application behavior.
  • Access and error logs show requests using the new location.
  • PHP-FPM, CGI, cron, deployment, backup, and application path references have been reviewed.
  • The old tree remains available until the rollback and backup policy permits retirement.

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.

ApacheDocumentRootLinuxserver administrationUbuntuvirtual hostsweb server

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.