To run PHP through Nginx, install PHP-FPM, make Nginx’s fastcgi_pass endpoint exactly match the PHP-FPM pool’s listen value, and set SCRIPT_FILENAME to a real file beneath the site’s document root. On a single VPS, a correctly permissioned Unix socket is usually the safest and simplest connection.
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
How the Nginx–PHP-FPM connection works
Nginx does not execute PHP itself. It serves files such as HTML, CSS, JavaScript and images directly. When a request matches a PHP location, Nginx sends the request to PHP-FPM using FastCGI. PHP-FPM starts or reuses a worker, executes the script, and returns the response to Nginx, which then sends it to the client.
As an Amazon Associate I earn from qualifying purchases.
Three values must agree for the arrangement to work:
- The document root: Nginx must point to the directory that actually contains the application’s PHP files.
SCRIPT_FILENAME: this FastCGI parameter must resolve to the requested PHP file under that document root.- The FPM endpoint: Nginx’s
fastcgi_passmust be the same Unix socket path or TCP address and port configured by the pool’slistendirective.
A mismatch commonly produces a 502 Bad Gateway, while an incorrect document root or a missing script generally produces a 404.
#1 Best Overall
- [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.
Prerequisites and distribution differences
You need a Linux VPS with administrative access, a DNS name or IP for testing, and a site directory that Nginx can read. Install Nginx and the distribution’s PHP-FPM package with the operating system package manager. Package names, service names, configuration directories and socket filenames vary by distribution and PHP version, so do not copy an old php5-fpm example into a current system.
On Debian-based systems, the package is commonly named php-fpm. A typical installation is:
sudo apt update
sudo apt install nginx php-fpm
Other distributions may split PHP-FPM into a versioned package. Use that distribution’s package manager, then record the installed version:
php --version
Find the service that was installed rather than assuming its name. For example, list PHP-related systemd units and inspect the package’s service status:
systemctl list-unit-files | grep -i fpm
systemctl --type=service | grep -i fpm
sudo systemctl status <your-php-fpm-service>
Replace the angle-bracketed service name with the unit present on your VPS. Start and enable it using that exact name:
sudo systemctl enable --now <your-php-fpm-service>
Find the active PHP-FPM pool and its listener
PHP-FPM uses pool files written in PHP’s INI-style syntax. The pool’s listen directive is mandatory and can contain a Unix socket path, a port, or an IP address plus port. Before editing Nginx, inspect the pool that the running service actually loads.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsRank #2
- 【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.
Common locations include a distribution-specific PHP configuration directory under /etc/php/ or /etc/php-fpm.d/, but the exact path depends on the operating system and PHP version. Search the configuration tree:
sudo grep -R "^[[:space:]]*listen[[:space:]]*=" /etc/php /etc/php-fpm.d 2>/dev/null
Also inspect the pool’s ownership and mode settings when a Unix socket is used:
sudo grep -R -E "^[[:space:]]*listen.(owner|group|mode)[[:space:]]*=" /etc/php /etc/php-fpm.d 2>/dev/null
Write down the uncommented listen = value from the active pool. Do not infer it from a blog post or from the PHP version number. The value you record is the value Nginx must use later.
Configure the PHP-FPM pool
Use a local Unix socket on a single VPS
For Nginx and PHP-FPM on the same machine, a Unix-domain socket avoids exposing a network listener and is the normal secure default. A pool might contain a setting such as:
listen = /run/php/php-fpm.sock
The filename above is only an example. Keep the path already used by your pool, or choose a new path and use it consistently in both configurations.
Set socket ownership and mode so the Nginx worker can connect. The exact account is distribution-dependent; identify the account used by the Nginx master and workers, often shown in the Nginx configuration’s user directive or by the running process list.
Rank #3
- [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
listen.owner = <nginx-user>
listen.group = <nginx-group>
listen.mode = 0660
A mode of 0660 allows the owner and group to read and write the socket without granting access to every local user. The group must include the Nginx worker account. If the socket exists but Nginx cannot open it, check these three directives and the parent directory’s execute permission.
Use TCP only when the topology requires it
TCP can be appropriate when Nginx and PHP-FPM run in separate services or containers. Bind it to loopback for a same-host deployment, for example an address in the 127.0.0.0/8 range, rather than to every interface. If a non-loopback address is unavoidable, restrict who can connect with the pool’s listen.allowed_clients setting and enforce firewall rules.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →PHP’s documentation warns that an exposed FastCGI endpoint allows arbitrary code execution and that PHP-FPM must not be reachable from an untrusted network. A listener bound to a public interface is therefore a critical security failure, not merely an alternate performance setting.
Keep executable extensions narrow
Set security.limit_extensions to the PHP extensions your application actually executes. Restricting this list helps prevent a web-server configuration mistake from passing unrelated file types to PHP-FPM. The appropriate value depends on the application; do not add extensions simply because a file happens to exist in the document root.
Build the Nginx server block
Create or edit the server block for the site. The block needs the correct document root and an index list that includes index.php when the application uses it:
server {
listen 80;
server_name example.com;
root /var/www/example.com/public;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ .php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php-fpm.sock;
}
}
Replace the domain, root directory and socket with your values. The fastcgi_pass line must exactly match the pool’s listen value. For a TCP pool, the syntax would instead be an address and port, such as 127.0.0.1:9000, provided that the pool listens on that exact endpoint.
Recommended Free Tools
Rank #4
- 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.
Why each PHP directive matters
| Directive | Purpose | Failure when incorrect |
|---|---|---|
try_files $uri =404; |
Passes only an existing file to PHP-FPM. | A missing script is rejected with 404 instead of being sent for execution. |
include fastcgi_params; |
Loads the distribution’s FastCGI request parameters. | Required request metadata may be absent, especially for POST requests. |
fastcgi_param SCRIPT_FILENAME ... |
Tells PHP which physical script file to execute. | PHP may report that the script cannot be found or may execute an unintended path. |
fastcgi_pass ... |
Chooses the FPM Unix socket or TCP endpoint. | Nginx returns 502 when the endpoint is wrong, unavailable or inaccessible. |
The SCRIPT_FILENAME parameter is the value PHP uses to determine the script name. Constructing it from $document_root and $fastcgi_script_name works when the server block’s root is the real application root. If your distribution provides fastcgi.conf with a suitable parameter set, use that file according to its contents; do not define conflicting parameters twice.
For POST requests, Nginx must pass the request method, content type and content length. The distribution’s fastcgi_params or fastcgi.conf should provide these values. Inspect the include file if an application receives empty POST bodies.
Unix socket versus loopback TCP
| Consideration | Unix socket | Loopback TCP |
|---|---|---|
| Best fit | Nginx and FPM on one VPS. | Separate local services, containers or a topology that requires a network endpoint. |
| Nginx setting | fastcgi_pass unix:/path/to/socket; |
fastcgi_pass 127.0.0.1:port; or the exact local address and port in the pool. |
| Main security control | Socket owner, group, mode and directory permissions. | Bind locally and restrict clients; never expose the endpoint to an untrusted network. |
| Typical failure | Missing socket or permission denied. | Wrong port, firewall rule or an unexpectedly public listener. |
Neither option removes the need for least-privilege file permissions, updates, firewall policy and secure handling of application secrets. The choice is primarily about topology and exposure.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Apply configuration changes safely
- Check the PHP pool file. Confirm the active
listen, socket ownership and mode, process manager settings, andsecurity.limit_extensions. - Check the Nginx root and endpoint. Verify that
rootis the directory containing the PHP file and thatfastcgi_passis character-for-character identical tolisten. - Validate Nginx syntax. Run the distribution’s configuration test, commonly
sudo nginx -t. Do not reload if the test reports an error. - Reload Nginx. After a successful test, run
sudo systemctl reload nginx. - Reload or restart PHP-FPM. When a pool file changed, apply it with the matching service, for example
sudo systemctl reload <your-php-fpm-service>. Restart it if that service does not support a graceful reload. - Confirm the socket or port. Check that the endpoint exists after FPM starts. For a socket, use a file listing such as
sudo ls -l /run/php/; for TCP, inspect listening sockets with the operating system’s socket tool.
Reloading Nginx alone does not apply a changed FPM pool. Conversely, restarting FPM does not fix an Nginx syntax or document-root error.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Verify PHP without leaving a diagnostic file online
Create a temporary file beneath the configured document root, not in a different directory:
printf '%sn' "<?php echo 'ok';" | sudo tee /var/www/example.com/public/fpm-test.php
Request http://example.com/fpm-test.php from a browser or with an HTTP client. A response containing ok confirms that Nginx reached FPM and FPM executed the file. Remove the file immediately after testing:
Best Value
sudo rm /var/www/example.com/public/fpm-test.php
Do not use a test file containing phpinfo() on a public server. It reveals paths, modules and environment details that help attackers. When troubleshooting, read Nginx’s error log and the PHP-FPM pool log instead of displaying diagnostics in the HTTP response.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows 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 reinstallDiagnose common errors
502 Bad Gateway
A 502 indicates that Nginx could not obtain a valid response from FPM. Check these causes in order:
- Wrong socket path or TCP endpoint: compare the Nginx
fastcgi_passvalue with the pool’s uncommentedlistenvalue. - FPM is stopped or failed to start: inspect
systemctl statusand the service journal for configuration errors. - Socket permissions: verify that the socket exists, its owner and group include the Nginx worker account, and its mode permits access.
- Parent-directory permissions: Nginx needs execute permission on every directory leading to the socket.
- Stale configuration: reload or restart the correct versioned FPM service after editing its pool.
The Nginx error log normally distinguishes “No such file or directory” from “Permission denied,” making the next action clear.
404 from try_files
This generally means the requested script is not under the server block’s configured root, the URL points to the wrong filename, or the file does not exist. Confirm the physical path, capitalization and permissions. If the application uses a public subdirectory, that subdirectory—not the project’s parent—usually belongs in root.
PHP source downloads or appears as text
Nginx is serving the file as a static asset instead of matching the PHP location. Check that the location expression is present, braces are balanced, the server block handling the request is the one you edited, and Nginx was successfully reloaded. Never solve this by making the entire document root executable by PHP; restrict execution to the intended extensions.
Free tools Windows power users keep installed
One-click scans. No signup required.
POST data is missing or requests time out
Inspect the FastCGI include for request method, content type and content length parameters. For slow operations, Nginx’s fastcgi_read_timeout controls how long it waits between successive reads from FPM. Increase it only for endpoints that genuinely need more time, and investigate slow application code rather than applying a large timeout globally.
Tune PHP-FPM for the VPS
FPM pools support process management, logging, slow logs and status features. The process manager determines how workers are created:
| Mode | Behavior | Trade-off |
|---|---|---|
dynamic |
Keeps a configured baseline of idle workers and grows toward the maximum as demand rises. | Balances latency and memory, but requires sensible idle and maximum settings. |
ondemand |
Starts workers when requests arrive and removes idle workers after the configured idle period. | Can reduce idle memory use, with possible process-start latency during bursts. |
static |
Maintains a fixed number of workers. | Predictable capacity, but reserves that worker memory continuously. |
pm.max_children limits simultaneous FPM workers. Do not copy a universal worker count: measure the application’s typical worker memory, reserve RAM for the operating system, Nginx, databases and background jobs, and then choose a conservative limit. Raising the value beyond available memory causes swapping or out-of-memory failures rather than guaranteed throughput.
Use the pool’s slow log and status features to find expensive requests. If a particular application has different traffic or memory characteristics, give it a separate pool with its own user, socket and process limits instead of weakening limits for every site.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Quick Recap
Production security checklist
- Use a Unix socket for same-host Nginx and FPM unless a different topology requires TCP.
- Keep any TCP listener on loopback or a private network, restrict clients, and block untrusted access with firewall rules.
- Set socket owner, group and mode for the Nginx worker only; avoid world-writable sockets and directories.
- Keep
security.limit_extensionsrestricted to extensions the application must execute. - Use HTTPS, current operating-system and PHP updates, least-privilege file ownership, and protected environment files or secrets.
- Remove diagnostic scripts and disable unnecessary status pages after testing.
- Review Nginx and FPM logs for repeated failures, slow requests and unexpected paths.
A repeatable deployment checklist
- Install Nginx and the correct PHP-FPM package for the distribution.
- Record the PHP version and identify the service and active pool file.
- Read the pool’s
listenvalue; choose a local socket unless topology requires TCP. - Set socket ownership and mode so the Nginx worker can connect.
- Set a restricted
security.limit_extensionsvalue appropriate for the application. - Set the Nginx
root, includeindex.phpwhen needed, and add the PHP location. - Make
SCRIPT_FILENAMEresolve beneath that root and makefastcgi_passmatchlistenexactly. - Run
nginx -t, reload Nginx, and reload or restart the matching FPM service. - Test one temporary PHP file over HTTP, remove it, and inspect logs if the result is not
ok.
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.




