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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

One VPS can serve many independent websites with Nginx virtual servers (also called server blocks) and PHP-FPM. Each domain gets its own document root, logs, application settings and, when needed, PHP-FPM pool. Nginx reads the request’s Host header, selects the matching server_name, serves static files directly and forwards PHP scripts to the configured FastCGI socket or TCP endpoint.

The reliable sequence is: prepare isolated site directories, create one HTTP server block per hostname, connect each block to the correct PHP-FPM service, verify DNS, add certificates and HTTPS blocks, then test every domain before redirecting HTTP traffic. The examples below are intentionally adaptable because package names, PHP versions, socket paths and certificate locations vary by Linux distribution.

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.

How Nginx chooses the right website

Nginx permits multiple server directives inside the http context; each directive defines a virtual server. The request’s Host header is compared with the server_name values in those blocks, so several domains can share one public IP address. See the Nginx virtual-server documentation.

Name matching has a defined precedence: an exact name wins first, followed by the longest matching wildcard, followed by the first matching regular expression. The search stops at the first match, as described in the Nginx server-name reference. If no name matches the request’s Host header, Nginx uses the default server for that listen port; the request-processing documentation explains this fallback.

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application: attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.

That fallback matters operationally. A typo in DNS, a missing www alias or a request made directly to the IP can display the default site’s content. Define an intentional default server, or make the default response a controlled error, rather than allowing an unrelated site to appear.

Plan the VPS before adding domains

Use a separate document root for every site

Create a directory layout that makes ownership, backups and log inspection unambiguous. For example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
/var/www/site-a/public
/var/www/site-b/public

Place each application’s public files in its own public directory. Keep uploads, caches and other writable directories limited to what that application actually needs. Do not make an entire shared parent directory writable by the web server merely to simplify deployment.

Choose an ownership model

Decide which account deploys each site and which account runs its PHP-FPM workers. A per-site Unix user gives clearer separation of files and credentials; a shared deployment account is simpler but increases the impact of a compromised application. Whichever model you choose, document it before creating permissions, and test that Nginx can read public files while PHP can write only the directories intended for uploads or caches.

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth

Install supported packages

Provision the VPS with your distribution’s maintained Nginx, PHP and PHP-FPM packages. Keep the PHP-FPM service aligned with the PHP version used by each application. Package names and service paths differ between distributions, so use the target distribution’s package and service documentation rather than copying a command intended for another release.

Create one HTTP server block per domain

For every site, create a separate configuration file in the location used by your distribution and enable it according to that distribution’s Nginx layout. A basic block looks like this:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
server {
    listen 80;
    server_name site-a.example www.site-a.example;

    root /var/www/site-a/public;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ .php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/run/php/php-fpm.sock;
    }

    location ~* .(?:css|js|jpg|jpeg|png|gif|svg|ico|webp|woff2?)$ {
        try_files $uri =404;
    }
}

Replace the domain, root and PHP-FPM endpoint with values that exist on your VPS. The fastcgi_pass line can point to a Unix-domain socket or a TCP address. The SCRIPT_FILENAME parameter tells PHP-FPM which script to execute. Nginx documents both behaviors in its FastCGI module reference.

List every hostname deliberately

If a site should answer for both the apex domain and its www form, list both names in the same server_name directive. Add other aliases only when DNS and the application are prepared for them. An omitted alias is not automatically covered by the apex name.

Rank #3
Sale
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black | LED mouse pad with 14 lighting modes, covers keyboard & mouse, anti-slip rubber base, waterproof surface, USB powered
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.

Keep static and PHP handling separate

The front-controller example sends unknown paths to index.php, which is appropriate for applications designed that way. A site that does not use a front controller should use a simpler static rule, such as try_files $uri $uri/ =404. Do not pass arbitrary missing paths to PHP: it can hide broken links and create unnecessary interpreter work. Add application-specific rewrites only when the application requires them.

Use the maintained FastCGI parameter include

POST requests need parameters including REQUEST_METHOD, CONTENT_TYPE and CONTENT_LENGTH. Use the FastCGI parameter include maintained by your distribution when one is supplied, and verify that it contains the parameters your application expects. The Nginx FastCGI documentation covers these request variables and directive behavior.

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.

Connect each site to PHP-FPM

Find the actual socket or listener

PHP-FPM commonly exposes a Unix socket, but it may instead listen on a TCP address. Use the endpoint created by the installed service; do not assume that a socket name from another PHP version exists. Before reloading Nginx, confirm that the socket path is present and readable by the Nginx worker account, or that the configured TCP listener is reachable.

A version-specific path might resemble /run/php/php-fpm.sock, but that path in the example is illustrative, not a universal default. If your distribution creates a versioned socket, use that exact filename in fastcgi_pass.

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.

Shared pool versus per-site pools

You can send several server blocks to one PHP-FPM pool, or create a pool for each site. The choice affects isolation and memory use rather than Nginx’s virtual-host matching.

Architecture Isolation Memory use Failure blast radius Operational complexity
One shared PHP-FPM pool Lower separation between applications Usually lower overhead because workers are shared A pool outage or saturated worker set can affect all sites using it Simpler to configure and monitor
One pool per site Stronger process and credential separation when users and permissions are also separated Higher overhead because each pool has its own workers and limits A failing or overloaded pool is more likely to be confined to one site More pool files, limits, logs and upgrades to maintain

There is no universal worker count or memory threshold. Measure the actual applications and VPS, then set pool limits so one workload cannot consume all available memory. Keep pool configuration, environment variables and database credentials scoped to the site that needs them.

Point DNS at the VPS and test HTTP first

  1. Create the required A records for each domain and AAAA records when the VPS has working IPv6. Point them to the VPS addresses.
  2. Wait for the records to resolve through the DNS resolvers used by your visitors. Check both the apex and every alias listed in server_name.
  3. Before requesting certificates, send test requests with each intended hostname in the Host header. This confirms that Nginx selects the correct root instead of its default server.
  4. Place a harmless test file in each site’s document root, request it, and verify that the response comes from the expected domain. Remove the file immediately after testing.

Testing the hostname before TLS separates DNS and virtual-server errors from certificate errors. Inspect the access and error logs for the specific site while making these requests.

Add HTTPS for every hostname

TLS Server Name Indication (SNI) lets a browser send the requested hostname during the TLS handshake, so multiple HTTPS sites can share one IP address and still receive the appropriate certificate. Nginx describes this mechanism in its HTTPS configuration guide.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

Create an HTTPS block for each site

After DNS resolves correctly and a certificate covers every hostname the site will answer for, add a TLS server block. A representative structure is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
server {
    listen 443 ssl;
    server_name site-a.example www.site-a.example;

    root /var/www/site-a/public;
    index index.php index.html;

    ssl_certificate     /etc/ssl/site-a/fullchain.pem;
    ssl_certificate_key /etc/ssl/site-a/privkey.pem;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ .php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/run/php/php-fpm.sock;
    }
}

Use the certificate and key paths produced by your certificate process, protect the private key, and ensure the certificate includes every name users will enter. Repeat the block for each domain, changing its names, root and certificate paths.

Redirect HTTP only after HTTPS works

Once each HTTPS block serves the correct site, replace that site’s port-80 content with a redirect:

server {
    listen 80;
    server_name site-a.example www.site-a.example;
    return 301 https://$host$request_uri;
}

Test each hostname separately after the redirect. An SNI or certificate mistake can affect one domain while another appears healthy, so do not infer that all sites work from a single browser test.

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

Validate safely before every reload

  1. Run sudo nginx -t. Do not reload if the syntax test reports an error.
  2. Reload Nginx using the service manager after the test succeeds.
  3. Request a static file from every domain and confirm the expected status code and content.
  4. Request a harmless PHP file, verify that it executes through the intended PHP-FPM endpoint, then delete it. Never leave a diagnostic file containing environment details on a public site.
  5. Exercise each application’s login, uploads, redirects and forms. These paths expose incorrect permissions, missing POST parameters, wrong URL detection and incomplete HTTPS configuration.
  6. Review each site’s access and error logs, and configure rotation so logs cannot consume the VPS disk.

Troubleshoot by symptom

The wrong website appears

  • Check that the request hostname exactly matches a server_name value, including whether it uses www.
  • Confirm that DNS points to this VPS rather than an old address.
  • Look for overlapping wildcards or regular expressions; Nginx’s documented matching order determines which block wins.
  • If the hostname does not match any block, inspect the default server for that port.

Nginx returns 502 Bad Gateway for PHP

  • Verify that PHP-FPM is running and that the socket or TCP listener in fastcgi_pass exists.
  • Check permissions on a Unix socket and confirm that the Nginx worker can connect.
  • Ensure the Nginx configuration points to the PHP-FPM version actually installed, not a stale versioned path.
  • Read both the Nginx error log and the PHP-FPM service log for connection or worker-limit errors.

PHP downloads instead of executing

  • Confirm that the PHP location is present in the active server block and that its regular expression matches the requested filename.
  • Check that fastcgi_pass, the FastCGI include and SCRIPT_FILENAME are all inside that location.
  • Run the configuration test again and verify that you reloaded the configuration you edited.

Forms fail or applications report missing request data

Inspect the FastCGI parameter include and ensure that method, content type and content length are passed. Compare the active include with the distribution-maintained version rather than inventing a custom parameter list.

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

HTTPS shows the wrong certificate

  • Test the exact hostname, not only the IP address.
  • Confirm that the TLS block lists that hostname and that its certificate covers it.
  • Check for another default TLS server or an overlapping name that is selected first.
  • Verify that the certificate and key belong together and that Nginx was reloaded after the change.

Secure and operate several sites on one VPS

  • Give each application only the filesystem access it needs. Keep private configuration and database credentials outside publicly served directories.
  • Limit writable paths to uploads, caches or other documented application directories.
  • Apply operating-system, Nginx, PHP and application updates on a schedule, testing compatibility before production changes.
  • Use a firewall that exposes only required services, normally HTTP, HTTPS and restricted administration access.
  • Set Nginx request-size, timeout and rate limits according to each application’s behavior; these values are workload-specific, not universal constants.
  • Configure PHP-FPM worker limits and monitor memory, CPU, disk and process counts. A VPS can run out of memory even when Nginx itself is lightweight.
  • Back up site files, databases, Nginx configuration, PHP-FPM pool configuration and certificate renewal data. Periodically perform a restore test.
  • Keep separate logs or clearly tagged log streams so an error on one domain can be diagnosed without guessing which application generated it.

One VPS or separate VPS instances?

Consolidating sites reduces the number of operating systems and Nginx installations to maintain, but it also concentrates risk. Separating sites increases cost and maintenance effort while improving isolation.

Decision axis Several sites on one VPS Separate VPS per site
Cost One instance and shared infrastructure Multiple instances and duplicated baseline services
Maintenance burden Updates and monitoring are centralized, but one change can affect several sites Each instance is smaller in scope, but updates and monitoring repeat for every site
Noisy-neighbor risk One busy or compromised application can compete for shared CPU, memory, disk or PHP workers Resource contention is contained to the instance hosting that site
Credential and update isolation Requires careful users, permissions, pools and deployment boundaries Physical or virtual separation makes boundaries clearer
Failure scope VPS, kernel, storage or network failure can take all sites offline A failure normally affects one site’s instance

Choose consolidation when the applications have compatible maintenance windows and the VPS has measured headroom. Choose separate instances when contractual, security or availability requirements justify stronger boundaries. Capacity thresholds must come from your own traffic and workload measurements; authoritative Nginx documentation does not define a universal number of sites per VPS.

A repeatable checklist for adding the next site

  1. Create the site’s user, document root and restricted writable directories.
  2. Install or select the supported PHP runtime and decide whether the site uses a shared or dedicated PHP-FPM pool.
  3. Add an Nginx server block with the exact apex and alias names, unique root, index files, static-file behavior and PHP location.
  4. Confirm the configured socket or TCP endpoint exists and that SCRIPT_FILENAME resolves into the new site’s root.
  5. Point A and, when applicable, AAAA records to the VPS.
  6. Test HTTP with the intended hostname and inspect the site’s logs.
  7. Install a certificate covering every hostname, add the port-443 block and verify SNI by testing that domain independently.
  8. Only then enable the HTTP-to-HTTPS redirect.
  9. Run the configuration test before reloading, exercise static files, PHP, forms, login and uploads, remove test files, and record the final configuration for backups.

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.