Custom PHP settings per directory with .user.ini files
On ruachost.com, you can override PHP configuration settings on a per‑directory basis using .user.ini files. This is useful when different applications in your account require different PHP settings.
Why Use .user.ini Files?
Section titled “Why Use .user.ini Files?”- Apply custom PHP directives without changing global server settings.
- Configure settings for specific applications or directories.
- Useful for managing multiple apps with different requirements (e.g., CMS vs. custom scripts).
How .user.ini Works
Section titled “How .user.ini Works”- A
.user.inifile is similar tophp.ini, but applies only to the directory where it is placed and its subdirectories. - PHP reads
.user.inifiles every few minutes (default: 300 seconds). - Directives inside
.user.inioverride global settings for that directory.
Steps to Create a .user.ini File
Section titled “Steps to Create a .user.ini File”Step 1: Create the File
Section titled “Step 1: Create the File”-
Log in via FTP, SFTP, or File Manager.
-
Navigate to the directory where you want custom settings.
-
Create a file named:
.user.ini
Step 2: Add PHP Directives
Section titled “Step 2: Add PHP Directives”Insert the settings you want to override. For example:
display_errors = Onmemory_limit = 256Mupload_max_filesize = 20MStep 3: Save and Upload
Section titled “Step 3: Save and Upload”- Save the file in the target directory.
- The settings will apply to scripts in that directory and subdirectories.
Example Use Case
Section titled “Example Use Case”If you have two applications with different requirements:
- App A needs error reporting enabled.
- App B requires higher memory limits.
You can place separate .user.ini files in each application’s directory with the appropriate directives.