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

On an Nginx server using PHP-FPM, set cgi.fix_pathinfo=0 in the php.ini loaded by the FPM service, restart that same PHP-FPM service, and verify the effective value. Do not assume the file used by the PHP command-line tool is the one used by FPM: paths vary by operating system, PHP version, and package.

What cgi.fix_pathinfo controls

cgi.fix_pathinfo is a PHP CGI path-handling directive, not an Nginx directive. PHP documents it as an INI_SYSTEM boolean that “Provides real PATH_INFO/PATH_TRANSLATED support for CGI (Common Gateway Interface).” The documented default is 1.

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

With the value 1, PHP CGI attempts to fix paths so they conform to the CGI specification. With 0, PHP uses the older behavior. The setting affects how a request containing a script path and additional path information is interpreted before PHP executes it.

For the standard Nginx plus PHP-FPM hardening procedure, the PHP Nginx installation guide recommends setting the directive to 0. This helps prevent Nginx from handing PHP-FPM a request for a script file that does not actually exist. It does not replace correct Nginx routing, a correct SCRIPT_FILENAME mapping, or protection of the FPM listener.

#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.

Should the value be 0 or 1 with Nginx?

Value Typical effect When it may be appropriate Risk or limitation
0 Disables PHP’s CGI path-fixing behavior. The usual Nginx and PHP-FPM hardening configuration, especially when Nginx performs explicit file checks. Applications that intentionally depend on legacy PATH_INFO or PATH_TRANSLATED behavior may need routing changes.
1 Enables the documented CGI path-fixing behavior; this is PHP’s stated default. Legacy or specially designed applications that require this interpretation of path information, after testing. It can allow unsafe request-path handling when the Nginx FastCGI configuration passes nonexistent script paths to PHP-FPM.

The safer choice for a conventional Nginx deployment is 0, provided the application does not rely on the alternate behavior. A value of 0 cannot compensate for an exposed FPM socket or TCP port, an incorrect SCRIPT_FILENAME, or a location block that forwards arbitrary filenames.

Find the php.ini used by PHP-FPM

The active file depends on your operating system, package source, PHP version, and installation method. A source installation may copy php.ini-development to /usr/local/php/php.ini. Distribution packages commonly use versioned directories, such as /etc/php/7.0/fpm/php.ini; the version and directory on your server may be different.

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

Why the CLI php.ini can be the wrong file

PHP has separate server application programming interfaces (SAPIs). The command-line SAPI and the FPM SAPI can load different configuration files and additional configuration directories. Therefore, a value shown by php --ini describes the CLI runtime, not necessarily the worker pool serving Nginx.

Use php --ini as a clue about how PHP is packaged, but confirm the FPM SAPI before editing. Record the PHP major and minor version and the service name so that the file, restart command, and verification step all refer to the same installation.

Identify the FPM service and package layout

First determine which PHP-FPM service is attached to the Nginx virtual host. On a systemd-based distribution, list likely services:

systemctl list-units --type=service | grep -i fpm
systemctl list-unit-files | grep -i fpm

Common service names include a versioned form such as php7.0-fpm.service, but the installed version may produce a different name. Check the running process and package configuration directories when more than one version is installed:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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
ps aux | grep '[p]hp-fpm'
ls -la /etc/php/

Do not edit a file belonging to an unused PHP version. Nginx may be connected to a Unix socket or TCP listener owned by another FPM service.

Confirm the FPM SAPI configuration

Use a controlled administrative diagnostic to identify the configuration loaded by FPM. Depending on the package, this can be done through FPM’s startup output, the service’s process information, or a temporary diagnostic endpoint that reports the server’s PHP configuration. If you create an endpoint, restrict access to administrators, check it while the change is being made, and remove it immediately afterward.

The important result is the FPM SAPI’s “Loaded Configuration File” path, not merely the path printed by the CLI binary. If the diagnostic reports a configuration scan directory, check for later files there that might override the value in the main php.ini.

Set cgi.fix_pathinfo to 0

  1. Back up the active FPM configuration file and note the PHP version and service that use it.
  2. Open the file with administrative privileges. For example, a package using the documented versioned layout might use /etc/php/7.0/fpm/php.ini; substitute the path reported by your FPM runtime.
  3. Search for cgi.fix_pathinfo. If the line begins with a semicolon, remove the semicolon. Set one authoritative value:
cgi.fix_pathinfo=0
  1. Save the file and check that there is not a second active configuration file later in the FPM scan directory setting a different value.
  2. Keep the setting in the FPM configuration, not in application code. PHP classifies this directive as INI_SYSTEM, so an application-level ini_set() call is not the appropriate control.

Whitespace around the equals sign is accepted, but keeping the line simple makes it easier to audit. Do not add several competing copies of the directive; an administrator troubleshooting a later override may otherwise edit the wrong line.

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

Restart PHP-FPM and reload Nginx when needed

Configuration changes are read by new PHP-FPM workers. Restart the service that actually serves the Nginx virtual host. A documented example edits /etc/php/7.0/fpm/php.ini and then runs:

systemctl restart php7.0-fpm.service

Replace that service name with the one installed on your server. Check the result and recent log entries:

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.
systemctl status php7.0-fpm.service
journalctl -u php7.0-fpm.service --since "10 minutes ago"

If you changed only PHP’s php.ini, Nginx usually does not need a restart. If you also changed its FastCGI location, socket, SCRIPT_FILENAME expression, or file-existence rules, validate and reload Nginx:

nginx -t
systemctl reload nginx

A reload applies Nginx configuration without unnecessarily terminating existing connections. A failed syntax check should be fixed before reloading.

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

Verify the effective runtime value

Do not assume a successful service restart means the intended file was loaded. Verify the value from the FPM runtime that handles requests.

  1. Use a restricted diagnostic endpoint or FPM status tooling to inspect the effective cgi.fix_pathinfo value.
  2. Confirm that the endpoint is served by the expected PHP version and FPM pool.
  3. Check that the reported value is 0, then remove the endpoint or protect it from all untrusted users.
  4. Exercise the application’s normal routes, including any route that uses path information after a PHP script name.

A CLI check can still be useful for comparison, but it is not proof of the FPM value. If CLI and FPM disagree, treat the FPM result as authoritative for Nginx requests and investigate the separate configuration paths.

Check the Nginx FastCGI configuration too

cgi.fix_pathinfo is one control in the request path. Review the Nginx server block that forwards PHP requests.

Map SCRIPT_FILENAME to the intended document root

The FastCGI parameters must map SCRIPT_FILENAME to the actual PHP file under the virtual host’s document root. A wrong root or variable can make a legitimate request appear missing or can map a request to an unintended file. Confirm that the root used by Nginx matches the directory where the application is deployed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.

The PHP core documentation recommends that scripts use SCRIPT_FILENAME rather than PATH_TRANSLATED. Keep that distinction in mind when reviewing older framework or server snippets.

Reject nonexistent scripts before forwarding

Use an Nginx file-existence check so a request for a PHP filename that is not present is rejected instead of sent to FPM. The exact directives depend on the application’s routing design, but the objective is consistent: only an existing, permitted script should be passed as the FastCGI script.

Test both a real PHP entry point and a deliberately nonexistent filename. The nonexistent request should be handled by Nginx according to your site’s error policy and should not result in PHP-FPM executing another script.

Allow only the PHP locations your application needs

A broad regular-expression location that forwards every path ending in .php can expose administrative files, backups, or uploads if they are present below the document root. Restrict PHP execution to the intended directories and entry points where practical, and ensure that uploaded content cannot be interpreted as PHP merely because it has a PHP-like extension.

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

Why passing a nonexistent PHP file is dangerous

The Nginx installation guidance describes cgi.fix_pathinfo=0 as a defense against Nginx passing a nonexistent file to PHP-FPM and the resulting possibility of script injection. The problem generally appears when a request path contains a valid-looking PHP suffix but the script named by the request is not the file the administrator expected, while the FastCGI mapping and path handling allow PHP to resolve it incorrectly.

Set the directive, reject missing scripts in Nginx, and verify the mapping together. Treating only one of these as a complete fix leaves a gap in the request chain.

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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Protect the PHP-FPM listener

PHP-FPM’s manual warns that “php-fpm must not be reachable from an untrusted network.” A client that can open a FastCGI connection can control request configuration, including auto_prepend_file, and may be able to execute arbitrary code.

  • Prefer a local Unix socket when Nginx and PHP-FPM run on the same host.
  • If FPM must use TCP, bind it to a trusted interface rather than every network interface.
  • Use host and network firewall rules to permit only the Nginx host or other explicitly trusted clients.
  • Check the FPM pool configuration and the listener address after package upgrades or topology changes.
  • Do not expose FPM’s port directly to the public Internet.

Listener isolation is an independent security boundary. Even a correctly set cgi.fix_pathinfo=0 does not make an untrusted FastCGI endpoint safe.

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

Compatibility considerations before changing the value

Some applications intentionally use PATH_INFO for front-controller routing, legacy URLs, or compatibility with older CGI deployments. Changing the value to 0 can alter how those requests are interpreted.

Test in staging first

  • Exercise front-controller routes with and without trailing path information.
  • Test file downloads, image or asset routes, API endpoints, and authentication callbacks that include path segments.
  • Check rewrite rules and framework configuration for assumptions about PATH_TRANSLATED.
  • Review access and PHP error logs for changed status codes, missing routes, or script-resolution warnings.

If a required route fails, do not simply restore 1 and stop. First correct the Nginx rewrite and SCRIPT_FILENAME mapping where possible, then determine whether the application genuinely requires the CGI path-fixing behavior. The PHP core guidance favors SCRIPT_FILENAME over PATH_TRANSLATED for script identification.

Troubleshooting by symptom

Symptom Likely cause Checks and corrective action
The value appears to remain 1. The CLI configuration was edited, a different FPM version is serving Nginx, or a scanned configuration file overrides the main file. Inspect the FPM SAPI’s loaded file, confirm the service and socket used by Nginx, search the FPM scan directory, restart the matching service, and verify through FPM.
Nginx returns “502 Bad Gateway” after the change. FPM failed to restart, the socket path changed, permissions are wrong, or Nginx points to a stopped version. Run systemctl status and inspect the FPM journal; compare the Nginx fastcgi_pass target with the active FPM listener; run nginx -t.
All PHP requests return “File not found.” SCRIPT_FILENAME does not match the document root, or Nginx is forwarding a path that does not exist. Confirm the real file path on disk, the server block’s root, the FastCGI parameter, and the file-existence rule.
Only URLs containing extra path segments fail. The application relied on PATH_INFO behavior that changed when the value became 0. Test the route in staging, inspect rewrite rules, and update the application to use an explicit script mapping where possible.
A nonexistent PHP URL still reaches PHP-FPM. The Nginx location lacks an effective file check or another location block handles the request first. Inspect location matching, add the appropriate existence check, test a guaranteed-missing filename, and review FPM access logs.
Security testing reports an exposed FastCGI service. FPM is listening on an untrusted TCP address or firewall rules permit external access. Move to a local Unix socket or restrict the TCP listener and firewall to trusted clients; retest from an untrusted network.

A repeatable change procedure

  1. Identify the PHP version, FPM service, listener, and virtual host serving the site.
  2. Confirm the FPM SAPI’s loaded php.ini; do not rely solely on CLI output.
  3. Back up that file and set exactly cgi.fix_pathinfo=0.
  4. Check for an overriding file in the FPM configuration scan directory.
  5. Restart the matching PHP-FPM service.
  6. Check service status and logs for startup errors.
  7. If Nginx configuration also changed, run nginx -t and reload Nginx.
  8. Verify the effective FPM value through a restricted diagnostic, then remove or protect the diagnostic.
  9. Test real routes, path-information routes, a missing PHP filename, and application error handling.
  10. Confirm that the FPM listener is local or restricted to trusted networks.

Frequently asked questions

Is cgi.fix_pathinfo an Nginx setting?

No. It is a PHP CGI directive configured in the PHP runtime used by PHP-FPM. Nginx still needs its own FastCGI mapping and file-existence controls.

Can I change it with ini_set()?

No. PHP classifies it as INI_SYSTEM. Set it in the FPM configuration and restart the service.

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.

Why does php –ini show a different file?

The command-line SAPI and FPM SAPI can load separate configuration files. Verify the configuration loaded by the FPM workers serving Nginx.

Do I have to restart Nginx after editing php.ini?

Restart the matching PHP-FPM service. Nginx generally needs only a reload when its own FastCGI configuration has changed.

Is setting the value to 0 sufficient protection?

No. Reject nonexistent scripts in Nginx, map SCRIPT_FILENAME correctly, and keep PHP-FPM inaccessible to untrusted networks.

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.

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