Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon 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×
Skip to content
VGSources
Blog

How to Move a PHP Site From Windows to a Linux Server: A Complete Migration Guide

Move a PHP site safely from Windows to Linux by rebuilding the runtime, migrating files and database data separately, translating IIS and Windows assumptions, testing privately, and cutting over DNS with rollback protection.
Length12 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Move a PHP site from Windows to Linux as a controlled rebuild and cutover, not as a simple file copy. Inventory the Windows application, reproduce its PHP version and extensions on Linux, migrate the database and uploads separately, translate IIS and Windows-specific settings, test on a private staging hostname, then change DNS only after the Linux copy passes the same business-critical checks. Keep the Windows server available so you can roll back if a defect appears.

What actually changes when a PHP site moves from Windows to Linux?

PHP source code is usually portable, but the environment around it is not automatically portable. A Windows installation may depend on IIS and FastCGI, Windows drive letters, case-insensitive filename lookups, IIS rewrite rules, Windows service accounts, Task Scheduler, CRLF line endings, and extensions compiled or configured for Windows. Linux uses different paths, permissions, service managers, web-server configuration, and commonly case-sensitive filesystems.

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.

The migration therefore has five separate deliverables:

  • A Linux web stack with the required PHP version, SAPI, extensions, database client, and dependency tools.
  • The application code, public assets, and user-uploaded files.
  • A complete, restorable database copy.
  • Equivalent environment variables, rewrite rules, mail settings, workers, and scheduled jobs.
  • A tested DNS cutover and a documented rollback path.

Copying only the PHP directory leaves out data, uploads, scheduled work, and server configuration. Those omissions are common causes of broken logins, missing images, failed email, and incomplete orders after a move.

#1 Best Overall
Sale
LAPGEAR Home Office Pro Lap Desk - Black Carbon, Fits 15.6” Laptops | Built-In Mouse Pad & Phone Slot, Wide Cushioned Wrist Rest, Dual-Bolster Microbead Cushion, Carry Handle
  • Spacious Design: Measuring 21.1" wide and 14.1" deep, our lap desk comfortably fits most laptops up to 15.6". Extra room for accessories ensures convenience.
  • Enhanced Functionality: Packed with handy features, including a 5x9" precision tracking mouse pad and a built-in phone slot for seamless work or video calls. Plus, enjoy ergonomic support with the integrated cushioned wrist rest.
  • Cool Comfort: Enjoy a stable surface with our lap desk's dual bolster cushion, designed for comfort and airflow, keeping your lap cool during extended use.
  • Durable Surface: Work with confidence on our lap desk's solid surface, featuring a sleek black carbon color, ensuring optimal air circulation to prevent your laptop from overheating.
  • On-the-Go Convenience: With an integrated handle and lightweight design (2.8 lbs), our lap desk is portable for travel or moving around the house, offering flexibility in any space.

1. Freeze the Windows site and create a recovery point

Start at a time when you can briefly stop writes. Put the site into maintenance or read-only mode if the application supports it. If that is impossible, schedule the final write freeze for the cutover window and identify every process that can change data, including queue workers, imports, APIs, and scheduled scripts.

Back up every stateful component

  • Export the database with its native dump utility and verify that the dump can be read.
  • Copy the complete uploads and user-generated-content directories, including files outside the document root.
  • Save the active php.ini, web-server configuration, rewrite rules, environment variables, and dependency lock files.
  • Record scheduled tasks, background workers, mail settings, TLS certificate details, DNS records, and external API credentials.
  • Keep the original Windows server powered on and unchanged until the Linux installation has passed its observation period.

A backup is useful only if it is restorable. Test the database dump by importing it into a temporary database or validation instance, and compare file counts or checksums for the upload archive. Do not treat a screenshot of settings or a zipped code directory as a complete recovery plan.

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

2. Inventory the Windows application before provisioning Linux

Write down the current runtime instead of guessing from the application’s framework files. PHP’s installation documentation describes several Windows installation modes, so identify the one in use before selecting the Linux equivalent.

Record the runtime and web server

  • PHP version and patch level.
  • SAPI: IIS FastCGI, Apache module, CGI, or CLI.
  • Enabled extensions, including database drivers, image processing, XML, multibyte-string, archive, and caching modules.
  • Important php.ini values such as memory limit, upload limits, execution time, timezone, error reporting, session storage, and mail transport.
  • IIS site bindings, document root, default documents, URL Rewrite rules, MIME types, and HTTPS redirects.

Record application assumptions

  • Every Windows drive-letter path such as C:sitesportaluploads.
  • Directories that must be writable for uploads, cache, sessions, logs, generated images, or temporary files.
  • Include paths, autoload paths, hard-coded filenames, and case differences between files and references.
  • Composer or other dependency requirements and the lock file used in production.
  • Windows Task Scheduler jobs, long-running workers, command-line scripts, and their run frequency.
  • Database engine and version, character set, collation, SQL mode, timezone, stored routines, events, and connection parameters.

Capture the current DNS records, certificate configuration, SMTP provider, payment or analytics integrations, webhooks, and firewall allowlists. These external dependencies can make a technically correct Linux deployment appear broken if their endpoints still point to the Windows server.

3. Provision a Linux runtime that matches the application

Choose a supported Linux distribution and install the application’s required PHP version and extensions rather than simply selecting the newest available package. Match the database compatibility and confirm that the host provides SSH or SFTP, backups, TLS, logs, monitoring, and a way to run scheduled jobs.

Rank #2
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Apache with PHP-FPM

For modern Apache deployments, the PHP manual states: “For all modern deployments, use PHP-FPM (FastCGI Process Manager) with Apache httpd’s mod_proxy_fcgi module.” PHP-FPM separates PHP worker management from Apache, supports process isolation and independent restarts, and works with Apache event-based MPM configurations. Configure an Apache virtual host that passes PHP requests to the FPM socket or TCP listener, and keep the site on a staging hostname or temporary IP while you test.

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

Nginx with PHP-FPM

Nginx also normally passes PHP requests to PHP-FPM. Recreate the Windows document root, index-file behavior, HTTPS redirect, static-file handling, request-size limits, and front-controller routing in an Nginx server block. Nginx does not read IIS web.config rules, so every rewrite and access rule must be translated deliberately.

Install dependencies and isolate the site

  • Install the selected PHP version, all required extensions, Composer or the project’s dependency tool, and the database client.
  • Create a dedicated deployment owner and a separate service account for the web/PHP process where the distribution supports it.
  • Configure a virtual host or server block, TLS, log locations, and a staging DNS name that is not yet used by public traffic.
  • Keep administrative services such as SSH restricted by firewall rules and key-based authentication where possible.

Do not copy Windows service binaries, IIS modules, or web.config files into Linux and expect them to work. Transfer application code and data; rebuild operating-system and web-server integration.

4. Transfer PHP files and uploads safely

Use authenticated SFTP or an equivalent secure transfer method. Transfer the application tree, public assets, configuration templates, and uploads separately so you can verify each category and avoid exposing secrets in a public document root.

  1. Create the destination directories and assign the intended deployment owner.
  2. Upload the code and assets through SFTP, preserving directory structure.
  3. Upload user-generated files, including nested directories and files whose names contain spaces or non-ASCII characters.
  4. Compare source and destination file counts, sizes, or checksums.
  5. Recreate dependency directories with the project’s supported install command when appropriate; do not assume a Windows-built binary dependency can run on Linux.

Keep environment files, database credentials, private keys, and backups outside the public document root. If the application currently stores any of those inside its web tree, move them and update the configuration before opening the staging hostname.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Yilador Webcam Cover 3 Pack, 0.03 inch Ultra Thin Laptop Camera Cover Slide
  • Note: Not suitable for MacBooks released after 2023 or devices with a protruding front camera; Not applicable to full-screen or notch-style tempered glass screen protectors; Do not use on the rear camera of the phone.
  • 💻 Why Do You Need a Webcam Cover Slide? — Safeguard your privacy by covering your webcam with our reliable webcam cover when not in use. Don't let anyone secretly watch you. Stay protected!
  • ✅ Thin & Stylish — Enhance your laptop's functionality and aesthetics with our 0.027" ultra-thin webcam covers. Seamlessly close your laptop while adding a touch of sophistication.
  • ✅ Fits Most Devices — Compatible with laptops, phones, tablets, desktops! Keep your privacy intact on Ap/ple, Mac/Book, iPh/one, iP/ad, H/P, L/novo, De/ll, Ac/er, As/us, Sa/msung devices.
  • ✅ 365 Days Protection — Our upgraded 3.0 adhesive ensures a strong hold that won't damage your equipment. Experience reliable, long-term privacy protection day in and day out.

5. Migrate the MySQL or compatible database

A database-backed PHP site requires a separate data migration. The code directory does not contain accounts, orders, content, sessions, or configuration rows stored in the database.

Export and import

  1. During the write freeze, create a native database dump. For MySQL-compatible systems, an illustrative export is mysqldump -u migration_user -p --single-transaction app_db > app_db.sql; use options appropriate to the engine and workload.
  2. Transfer the dump over SFTP or another authenticated channel.
  3. Create the destination database and a least-privilege application account. Grant only the permissions the application needs.
  4. Import the dump into the destination database, then inspect the import output for errors rather than assuming completion means success.
  5. Update the Linux environment or configuration file with the destination host, database name, username, password, port, and socket settings.

Validate data compatibility

  • Check character set and collation so accented characters, emoji, and case comparisons behave as expected.
  • Compare database and application timezones, especially for scheduled publishing, expiration dates, and reports.
  • Verify SQL mode, stored routines, triggers, scheduled events, views, and generated columns.
  • Search database rows for Windows drive letters or absolute file paths and convert them to Linux paths.
  • Run representative reads and writes through the application, not only a database-client query.

Take a second, final dump immediately before cutover. If the site accepted writes during testing, apply that final delta or repeat the import according to the application’s downtime plan; otherwise the Linux copy will be behind the Windows source.

6. Translate Windows-specific configuration and code

Convert paths and filename assumptions

Replace drive-letter paths with Linux absolute or project-relative paths. Linux distinguishes uppercase and lowercase names, so a reference to Logo.png will not necessarily find logo.png. Search templates, autoloaders, image URLs, include statements, and database values for case mismatches before users encounter them.

Use the application’s path helper or configuration layer instead of scattering operating-system-specific strings through source code. Confirm that the PHP process can resolve the working directory when scripts run from the command line, a web request, and a scheduled job; those contexts may start in different directories.

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.

Translate rewrite rules

Convert IIS web.config URL Rewrite rules to Apache .htaccess directives or Nginx server-block directives. Test direct routes, front-controller fallbacks, trailing-slash behavior, static assets, denied files, and HTTPS redirects. A rule that works on the home page can still break POST routes, encoded characters, or API endpoints.

Rank #4
AboveTEK Portable Laptop Lap Desk w/Retractable Left/Right Mouse Pad Tray, Non-Slip Heat Shield Tablet Notebook Computer Stand Table w/Sturdy Stable Work Surface for Bed Sofa Couch or Travel
  • Anti-Slip Surface - Transform your laptop into a mobile workstation with the AboveTEK portable laptop lap desk. The anti-slip surface provides a strong grip for laptops up to 15.6 inches(Diagonal), while the double rubber strip on the bottom ensures a stable display or typing experience on your lap, couch, or bed.
  • Retractable Mouse Pad - Retractable laptop mouse pad extends on both directions for the left/right handed with elevation along the edges for stopping mouse from falling off. The size of laptop tray is 14" X 9.7" and the size of mouse pad is 7.4" X 6.1".
  • Effective Heat Shield - The effective heat shield made of sturdy and thick material protects your laptop from overheating. Prioritizes your comfort and safety, an ideal lap pad or board for working anywhere.
  • EASY to Carry and Store - With an ergonomic and simplistic design, the lap desk is portable to store in a backpack. Only 15" in size, 2.2 lb of weight and with slim 0.6 inch thickness, it is ready to be easily carried around.
  • Widely Applicable - The smooth platform accommodates laptops and tablets up to 15.6 inches(Diagonal), making it a versatile accessory and one of the best gifts for mom, dad, students and professionals. Perfect for use as a laptop bed tray or tablet holder anywhere at home, library, or park.

Normalize text and scripts

Windows and Linux use different line-ending conventions. Normalize shell scripts, configuration files, and generated command files if the Linux shell reports parsing errors or an otherwise valid script fails with an unexpected-character message. Check executable permissions after transfer; a script copied through a file manager may not retain its execute bit.

Recreate services and scheduled work

Rebuild mail transport, queues, workers, cache backends, environment variables, and scheduled jobs on Linux. Replace Windows Task Scheduler entries with the destination’s supported scheduler, commonly cron or a service manager, and run each command manually under the same account before scheduling it. Record the job’s timezone, working directory, output log, lock behavior, and retry policy.

7. Set Linux ownership and permissions deliberately

Do not make the entire site writable by the web server or by everyone. Assign the document root to a non-root deployment owner and the web/PHP service account, then grant write access only to directories that genuinely need it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Keep PHP source, dependency files, and configuration read-only to the web process whenever possible.
  • Grant write access to upload, cache, session, generated-output, and temporary directories only.
  • Ensure the service account can traverse every parent directory without granting unnecessary write permission.
  • Protect logs, environment files, database dumps, and private keys from direct HTTP access.
  • Test uploads, image generation, session creation, cache writes, and temporary-file creation as the actual PHP service account.

The underlying issue is the same as on IIS, where the service identity needs MODIFY permission on the temporary directory: the runtime account must be able to write exactly where the application expects. When a Linux request fails, inspect both filesystem permissions and the PHP/web-server error log instead of applying a blanket permission change.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

8. Test the Linux site privately before DNS changes

Use a staging hostname, temporary IP, or local hosts-file entry so real users continue reaching Windows while you exercise Linux. Prevent search indexing and ensure test email cannot accidentally reach customers if the application supports a non-production mail mode.

Best Value
Sale
LAPGEAR Home Office Lap Desk – Pink, Fits 15.6” Laptops
  • Spacious Design: Measuring 21.1" wide and 12" deep, our lap desk comfortably fits most laptops up to 15.6". Extra room for accessories ensures convenience.
  • Enhanced Functionality: Packed with handy features, including a 5x9" precision tracking mouse pad and a built-in phone slot for seamless work or video calls. Plus, enjoy laptop support with the integrated device ledge.
  • Cool Comfort: Enjoy a stable surface with our lap desk's dual bolster cushion, designed for comfort and airflow, keeping your lap cool during extended use.
  • Durable Surface: Work with confidence on our lap desk's solid surface, featuring a blush pink color, ensuring optimal air circulation to prevent your laptop from overheating.
  • On-the-Go Convenience: With an integrated handle and lightweight design (2.14 lbs), our lap desk is portable for travel or moving around the house, offering flexibility in any space.

Functional test checklist

  • Open representative public pages, authenticated pages, administrative screens, and API endpoints.
  • Log in, log out, expire a session, reset a password, and verify cookies over HTTPS.
  • Submit forms with validation errors and successful writes.
  • Upload, resize, download, and delete files; test filenames with mixed case and non-ASCII characters.
  • Generate PDFs, images, exports, and other files produced by PHP extensions.
  • Read and write the migrated database, including searches, pagination, reports, and transactions.
  • Send test email, process a queue item, run each scheduled job, and verify webhook or API callbacks.
  • Check HTTP-to-HTTPS redirects, canonical URLs, 404 handling, rewrite rules, cache headers, and robots behavior.

Confirm the runtime

Compare the enabled modules with the Windows inventory using php -m and, where safe, a temporary phpinfo() page that is removed after testing. Verify the PHP version, loaded configuration file, timezone, upload limits, memory limit, session handler, and error-log destination. Run the application’s own test suite or health-check command if one exists.

Compare critical rendered pages and business outcomes with the Windows site, not merely HTTP status codes. A page that returns 200 can still omit images, use the wrong currency timezone, or silently fail to send an email.

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

9. Cut over with a final data sync

  1. Lower the DNS TTL ahead of the planned change where practical, allowing cached records to expire sooner.
  2. Announce a short maintenance window and stop writes on Windows, including workers and scheduled imports.
  3. Take the final database dump and copy any files uploaded since the staging transfer.
  4. Import the final data or apply the agreed delta on Linux, then run a focused smoke test.
  5. Change the DNS record or load-balancer target to Linux and confirm the certificate covers the production hostname.
  6. Monitor access logs, PHP-FPM or web-server errors, database errors, latency, queue depth, scheduled jobs, and user reports.

DNS caches mean users may reach either server for a period. Keep Windows in a safe, read-only state after the switch so a late request cannot create data that exists only on the old system. Document the exact cutover time, final dump name, DNS changes, and person responsible for rollback.

10. Keep and test the rollback plan

Rollback means more than restoring a DNS record. If Linux accepted writes after cutover, switching DNS back can discard those writes or create conflicting records. Define in advance whether rollback is allowed only before new writes, or whether you can export and reconcile a post-cutover delta.

  • Retain the Windows code, database backup, uploads, DNS values, and credentials needed to restore service.
  • Set an observation period long enough to include at least one normal scheduled-job cycle and a representative traffic period.
  • Specify the critical defects that trigger rollback, such as failed logins, missing transactions, data corruption, or unavailable payment callbacks.
  • If rollback is required, stop writes, preserve Linux logs and a final database dump, restore the previous DNS target, and communicate which transactions need reconciliation.

Do not decommission Windows immediately after DNS changes. Remove it only after monitoring confirms that the Linux site is stable and the agreed rollback window has closed.

Common migration failures and their fixes

Symptom Likely cause What to check
Every dynamic URL returns 404 Rewrite rules were not translated or the front controller is not selected. Apache .htaccess or Nginx directives, document root, index files, and route-specific tests.
Images or includes fail only on Linux Filename case mismatch or a Windows drive-letter path remains. Actual filename casing, application path settings, and database rows containing absolute paths.
Uploads fail with a permission error The PHP service account cannot write to the upload, temporary, or session directory. Ownership, directory permissions, parent-directory traversal, and the PHP error log.
Login works but sessions disappear Session storage, cookie security, hostname, or writable session directory differs. Session handler, cookie domain and HTTPS flags, timezone, and service-account write access.
Database import completes but pages show wrong characters Character set or collation differs between source, destination, connection, and tables. Database defaults, table definitions, connection settings, and representative non-ASCII data.
Scheduled tasks never run The Windows Task Scheduler job was not recreated or runs under the wrong account and path. Scheduler entry, executable permissions, working directory, environment variables, timezone, and logs.
Email or webhooks fail SMTP credentials, firewall rules, callback URLs, certificates, or allowlists still reference Windows. Outbound connectivity, provider settings, DNS, TLS, and integration logs.
PHP reports an undefined function or class An extension or dependency available on Windows is missing on Linux. php -m, CLI versus FPM configuration, dependency installation, and PHP version parity.

How to evaluate a Linux destination

The right destination depends on the inventory, not on the operating-system label alone. Compare prospective hosts or managed VPS plans against these concrete requirements:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Support for the application’s PHP version and every required extension.
  • Apache or Nginx configuration access and PHP-FPM availability.
  • Database version compatibility, backup and restore tooling, and a documented recovery process.
  • SSH/SFTP access for authenticated transfer and emergency maintenance.
  • TLS certificate management, DNS controls, firewall configuration, and outbound SMTP/API access.
  • Centralized logs, resource monitoring, alerting, and access to PHP-FPM and database diagnostics.
  • Reliable scheduled-job and worker support.
  • A practical rollback option, including snapshots or independently restorable backups.

A provider that cannot match a required PHP extension, run the application’s scheduler, or restore the database on demand is a poor fit regardless of advertised CPU or storage.

Final migration checklist

  • Windows site frozen or a final freeze window defined.
  • Restorable database dump verified.
  • Uploads and user-generated files copied and checked.
  • PHP version, SAPI, extensions, configuration, paths, and writable directories inventoried.
  • Linux PHP-FPM, Apache or Nginx, database client, dependencies, TLS, and logs configured.
  • IIS rewrite rules, Windows paths, case assumptions, line endings, services, and scheduled jobs translated.
  • Database character set, collation, timezone, SQL mode, routines, events, and stored paths checked.
  • Staging tests completed for authentication, writes, uploads, generated files, email, workers, jobs, redirects, and integrations.
  • DNS TTL, final dump, delta transfer, monitoring, and rollback responsibilities documented.
  • Windows server retained until the Linux observation period is complete.

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.

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.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
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.