A literal php.ini is normally global to a PHP installation, not a file that PHP reads separately in every folder. For a single application directory, create a .user.ini file when PHP runs through CGI, FastCGI, or PHP-FPM. If PHP is loaded as an Apache module, use that virtual host or directory’s .htaccess rules instead. The correct method depends on the web server SAPI, the directive’s changeability mode, and PHP’s cache interval.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
What “per-directory php.ini” actually means
PHP reads its main configuration file when the PHP runtime starts. That file establishes installation-wide defaults such as the loaded extensions, execution limits, error behavior, and upload settings. A second, literal php.ini placed inside an application folder is not the normal per-directory mechanism and is generally ignored.
As an Amazon Associate I earn from qualifying purchases.
Recommended Free Tools
PHP does provide per-directory configuration. With CGI, FastCGI, and PHP-FPM, it looks for a user INI file—named .user.ini by default—starting in the directory containing the requested PHP script and then walking upward toward the document root. A setting in a child directory can therefore apply only to that application or subdirectory, while a setting in a parent directory can be inherited by several applications.
When PHP is compiled and loaded as an Apache module, the PHP manual directs administrators to use Apache’s .htaccess mechanism for the same kind of directory scope. The syntax and permitted directives depend on the PHP version and server configuration, so an .htaccess example for PHP-FPM should not be copied into an Apache-module deployment without checking the active SAPI.
#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.
Choose the right configuration method
| Method | Works with | Scope | Operational behavior | Main limitation |
|---|---|---|---|---|
.user.ini |
CGI, FastCGI, PHP-FPM | The script’s directory and its descendants, with PHP searching upward toward the document root | Per-application file; changes are reread according to user_ini.cache_ttl |
Only directives classified as INI_ALL, INI_PERDIR, or INI_USER can be changed |
.htaccess |
PHP loaded as an Apache module | The Apache directory context where the file is enabled | Apache applies the rule for requests in that directory; exact syntax depends on the PHP and Apache setup | Not the normal control plane for PHP-FPM or other FastCGI deployments |
Main php.ini |
All SAPIs using that installation | Global to the PHP installation | Read at startup; module SAPIs read it when the web server starts, while CGI and CLI read it per invocation | Too broad when only one application should change |
Host/path sections in main php.ini |
CGI and FastCGI installations that support them | A named host or an exact filesystem path | Centrally managed rules in the main configuration | Cannot set extension or zend_extension; matching must be exact |
Before editing anything, identify the SAPI that serves the affected request. A command-line PHP binary can use a different configuration file from the web worker, so a successful CLI test does not prove that the web application has loaded the same values.
Set up .user.ini for CGI, FastCGI, or PHP-FPM
1. Locate the application directory
Find the directory containing the PHP scripts that need the override. For an application rooted at /var/www/example/app, a file in that directory affects scripts there and in descendant directories. A file in /var/www/example would be a broader parent-level policy.
Do not put the file in the project repository merely because that is convenient. Place it in the directory actually visible to the PHP worker, which may be a document root, a release directory, or a symlinked deployment path.
2. Create the correctly named file
Create a plain-text file named exactly .user.ini:
; /var/www/example/app/.user.ini
memory_limit = 256M
upload_max_filesize = 20M
post_max_size = 24M
max_input_vars = 2000
PHP’s default user_ini.filename is .user.ini. An administrator can change that filename, or disable per-directory scanning entirely by setting user_ini.filename to an empty string. If your file appears to be ignored, confirm the effective filename before changing the contents.
Use one directive per line. Whitespace around the equals sign is accepted, comments begin with a semicolon, and size values may use PHP’s normal suffixes such as M for megabytes. Keep the file in the encoding expected by the deployment and avoid saving it as a rich-text document.
3. Add only directives allowed in a user INI file
Each PHP directive has a changeability mode. A .user.ini file accepts directives marked INI_ALL, INI_PERDIR, or INI_USER. Directives marked INI_SYSTEM are not available there, and some settings are restricted to the main php.ini.
| Directive | Typical mode relevant to this task | Example per-directory use |
|---|---|---|
memory_limit |
Per-directory or user-changeable in standard PHP builds | Give one application more working memory without changing every virtual host |
upload_max_filesize |
INI_PERDIR |
Raise the maximum size of an individual uploaded file |
post_max_size |
INI_PERDIR |
Raise the maximum size of a complete POST request; it should normally be at least as large as the upload limit |
max_input_vars |
INI_PERDIR |
Allow forms with more input variables |
extension and zend_extension |
Main configuration only | Not valid as a per-directory extension-loading mechanism |
The mode shown in the PHP manual for your installed version is authoritative. A directive that is valid in the global file may still be rejected or ignored in .user.ini if its mode does not permit per-directory changes. Raising a limit also does not bypass operating-system limits, reverse-proxy limits, web-server request limits, or application-level validation.
4. Set ownership and permissions
The PHP worker must be able to read the file. Set ownership and permissions according to the account used by PHP-FPM or the web server, while avoiding world-writable configuration. A typical deployment gives the service read access through group membership or a controlled owner/group arrangement.
Rank #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.
Prevent the web server from returning .user.ini as downloadable text. Although the file is a dotfile, a server misconfiguration or alternate static-file handler could expose it. The PHP manual’s user notes warn that a publicly readable user INI file can reveal sensitive settings. Add a deny rule in the server configuration appropriate to your stack and test an HTTP request for the file; the expected result is a refusal or a not-found response, not the file contents.
5. Allow PHP to reread the file
The default user_ini.cache_ttl is 300 seconds, or five minutes. PHP can continue using the previous values until that interval expires. On a controlled system, restarting or reloading the PHP worker can make the change take effect sooner, but the exact command depends on the service manager and hosting platform.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteDo not assume that restarting Apache reloads a separately managed PHP-FPM pool, or that restarting one pool updates another. Restart the worker that handles the application request, and account for multiple web nodes or containers in a load-balanced deployment.
6. Verify through the web request path
Create a temporary diagnostic script in the same directory as the application, request it through the same hostname and web server, and then remove it:
<?php
echo 'memory_limit=' . htmlspecialchars((string) ini_get('memory_limit'), ENT_QUOTES, 'UTF-8');
For a more complete check, inspect only the settings needed for the change and protect the endpoint while it exists. Do not leave a publicly accessible configuration dump in production because it can disclose paths, extensions, and environment details.
Use php --ini separately when investigating CLI behavior. That command reports the CLI binary’s loaded configuration and scanned files; it does not establish what the web SAPI loaded. A browser request, an application health check, or a server-side request executed by the same PHP-FPM pool is the relevant test for a web application.
Windows 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 reinstallOutdated 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 matchUnderstand inheritance and precedence
For a request targeting /var/www/example/app/public/index.php, PHP starts looking for the user INI file in the script’s directory and then checks parent directories toward the document root. This makes a parent file useful for shared defaults and a child file useful for an application-specific exception.
Keep inherited policy intentional. If two directories contain settings for the same directive, the value seen by the script depends on the directory search and configuration processing rules of the active PHP version. Test the exact path rather than assuming that a file placed in a sibling directory will apply. A file in /var/www/example/app does not automatically affect /var/www/other-app.
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
Directory inheritance also interacts with deployment layouts. If the web root points to a release directory through a symlink, verify which physical path PHP associates with the script and place the file where the worker’s directory scan will find it. During atomic releases, copy the intended .user.ini into each release or maintain it in a stable parent directory that is part of the scan path.
Use .htaccess only for Apache-module PHP
If PHP is loaded directly into Apache as a module, the per-directory control is Apache’s .htaccess context. The exact directives depend on the PHP version and whether the host permits overrides. A deployment may use forms such as php_value or php_flag, but the server administrator must confirm that those directives are enabled for the directory.
Free tools Windows power users keep installed
One-click scans. No signup required.
# Example shape for an Apache-module deployment; validate syntax for the installed PHP and Apache configuration
php_value memory_limit 256M
php_value upload_max_filesize 20M
php_value post_max_size 24M
Do not use this example unchanged with PHP-FPM. In a FastCGI deployment Apache serves as a proxy to a separate PHP worker, so an Apache-module directive can produce a 500 error or have no effect. Conversely, a perfectly valid .user.ini may be ignored when the request is handled by module PHP.
Check the SAPI from a protected diagnostic page with php_sapi_name() or PHP_SAPI, then remove the page. Typical values identify CGI/FastCGI or an Apache module, but hosting panels and proxies can obscure the architecture; confirm with the server configuration when in doubt.
Manage host- and path-specific rules centrally
Some CGI and FastCGI installations need central administration rather than files deployed with each application. The main php.ini can contain optional host and path sections:
[HOST=dev.example.com]
display_errors = On
[PATH=/var/www/example/secure]
auto_prepend_file = security.php
A [HOST=...] section applies directives to the named host. A [PATH=...] section applies them to scripts from the named filesystem path. Match the host name and path exactly as PHP sees them; a different alias, case, symlink target, or virtual-host name can prevent a match.
These sections are not a way to load extensions. The PHP manual excludes both extension and zend_extension from host/path sections. Configure those in the main installation configuration and restart the relevant SAPI.
Host/path sections are centrally governed and therefore easier to audit across many applications, while .user.ini keeps an application’s ordinary limits beside its code. Choose one control plane for each setting so that operators know where the authoritative value lives.
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.
Know which configuration PHP is loading
The main php.ini is read when PHP starts. Server-module SAPIs read it when the web server starts; CGI and CLI read it per invocation. PHP can also scan an additional directory containing alphabetically loaded .ini files. The PHP_INI_SCAN_DIR environment variable can replace or augment the compiled scan directory.
This additional scan is separate from per-directory .user.ini discovery. An extension or setting found in a CLI scan directory does not prove that the web worker has the same scan directory, environment variables, binary, or startup file. When comparing contexts, record the SAPI, PHP version, executable path, loaded configuration path, and scanned directory rather than comparing one value in isolation.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →For CLI inspection, run:
php --ini
php -r 'echo PHP_SAPI, "n", php_ini_loaded_file(), "n";'
Use a web request for the final result. The CLI output is a separate diagnostic context, not a substitute for testing the application’s request path.
Troubleshoot an ignored or ineffective file
The file name is wrong
Confirm that the file is exactly .user.ini, including the leading dot and lowercase spelling, unless the installation deliberately changed user_ini.filename. Editors on some systems can silently append .txt; list the directory and inspect the actual filename.
The SAPI does not scan user INI files
Verify whether the request uses CGI, FastCGI, or PHP-FPM. If it uses Apache-module PHP, move the setting to the supported .htaccess mechanism or to a centrally managed configuration section. If the host disables user INI scanning by setting user_ini.filename to an empty value, only an administrator can change that policy.
The directive is not changeable at directory scope
Check the directive’s changeability classification in the manual for the installed PHP version. INI_SYSTEM and php.ini-only settings will not become effective merely because they are spelled correctly. Extension loading is a common example: configure it globally rather than in .user.ini or a host/path section.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →The cache has not expired
Wait up to the default 300-second interval, or restart/reload the worker that actually serves the request. In a cluster, confirm that every node has the same file and that requests are not being routed to an unchanged instance.
You tested the wrong execution context
Compare a web request served from the affected directory with the application’s expected value. A CLI command may use another PHP version, another php.ini, or another PHP_INI_SCAN_DIR. Test through the same hostname, virtual host, pool, and directory as the failing request.
Best Value
The value is overridden elsewhere
Inspect parent directories, the main php.ini, scanned startup files, host/path sections, web-server request limits, and application configuration. For uploads, remember that post_max_size constrains the entire request and should not be lower than upload_max_filesize. A PHP value can be correct while a reverse proxy or web server still rejects the request.
A host/path section does not match
Check the exact host string and filesystem path. A request arriving under an alias or a script resolved through a different release directory may not match the section you wrote. Confirm the path from the web SAPI rather than relying on the path shown by a separate CLI process.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
The file is exposed or unreadable
Check file permissions from the PHP worker’s account and request the URL directly from a test client. A permission failure prevents the setting from being read; an HTTP response containing the file indicates a security problem that must be fixed immediately. Deny direct access at the web-server layer and remove any diagnostic scripts used during verification.
Practical configuration patterns
Give one application more memory
Place this in the application directory when the web SAPI supports .user.ini:
memory_limit = 256M
Verify the value through a request handled by the application’s PHP worker. This changes the PHP memory ceiling for that directory only; it does not increase the memory available to the operating system, database server, queue worker, or command-line jobs.
Support larger uploads safely
upload_max_filesize = 20M
post_max_size = 24M
The first value limits an individual uploaded file, while the second limits the complete POST body, including all fields and files. Set the request limit high enough to contain the intended file plus form overhead, then check any proxy or web-server body-size limit separately.
Handle a large form
max_input_vars = 2000
Use this only when the application genuinely submits more variables and has validation for them. Raising the limit can increase parsing work and should be paired with application-side bounds on array sizes and request complexity.
Deployment checklist
- Identify whether the request uses CGI/FastCGI/PHP-FPM or Apache-module PHP.
- Choose
.user.ini,.htaccess, or a central configuration section accordingly. - Place the file in the directory scanned for the actual PHP script.
- Confirm the filename, ownership, permissions, and server rule that blocks direct downloads.
- Check every directive’s allowed changeability mode.
- Account for the 300-second default user INI cache or reload the correct worker.
- Verify through the application’s web request path, then remove diagnostic code.
- Check parent directories, startup files, host/path matches, proxy limits, and application settings when the result still differs.
The reliable pattern is therefore not a second global php.ini in each folder. Use a protected .user.ini for supported FastCGI-style SAPIs, .htaccess for Apache-module PHP, and centrally managed host/path sections or the main php.ini when the setting must be administered across applications.
Quick Recap
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.

