What are PHP settings?

PHP settings (php.ini directives) control how PHP behaves on your hosting account. Common settings include:

  • Upload limits: Maximum file upload size
  • Memory limits: How much RAM PHP scripts can use
  • Execution time: How long scripts can run before timing out
  • Error reporting: What errors are displayed or logged
  • Session settings: Cookie and session behaviour

Common PHP settings you might need to change

Setting Default Recommended Purpose
upload_max_filesize 8M–32M 64M–128M Maximum single file upload size
post_max_size 8M–32M 128M–256M Maximum POST request size
memory_limit 128M–256M 256M–512M PHP script memory allocation
max_execution_time 30–60s 120–300s Maximum script runtime
max_input_time 60s 120–300s Maximum input parsing time

Method 1: Using .user.ini file (recommended)

The easiest way to change PHP settings at 0724 Hosting is using a .user.ini file.

Step 1: Create .user.ini file

  1. Log in to DirectAdmin
  2. Go to File Manager
  3. Navigate to your website root (public_html)
  4. Click Create New File
  5. Name it .user.ini (include the dot at the start)
  6. Click Create

Step 2: Add PHP settings

Edit the .user.ini file and add your settings:

upload_max_filesize = 128M
post_max_size = 128M
memory_limit = 512M
max_execution_time = 300
max_input_time = 300

Save the file. Changes apply within 5 minutes (PHP caches .user.ini files).

Notes about .user.ini

  • Applies to the directory and subdirectories: Place in website root to affect entire site
  • Cache time: Changes take up to 5 minutes to apply
  • Per-directory: Can create .user.ini in specific folders for different settings
  • PHP-FPM required: Works with PHP-FPM handler (standard at 0724 Hosting)

Method 2: Using php.ini file (alternative)

Some servers allow custom php.ini files in the website root.

Creating php.ini

  1. In File Manager, navigate to public_html
  2. Create a file named php.ini
  3. Add your settings in the same format as .user.ini
  4. Save the file

Note: php.ini may not work on all servers. Use .user.ini if php.ini has no effect.

Method 3: Using .htaccess (for specific PHP handlers)

If using mod_php (less common), you can set PHP values in .htaccess:

php_value upload_max_filesize 128M
php_value post_max_size 128M
php_value memory_limit 512M
php_value max_execution_time 300

Warning: .htaccess PHP directives cause 500 errors if using PHP-FPM. Use .user.ini instead.

Method 4: Using ini_set() in PHP code

Set PHP values programmatically in your PHP scripts:

<?php
ini_set('upload_max_filesize', '128M');
ini_set('post_max_size', '128M');
ini_set('memory_limit', '512M');
ini_set('max_execution_time', '300');
?>

Limitations: Some settings cannot be changed with ini_set(). File-based methods are more reliable.

Common PHP setting use cases

Increasing WordPress upload limit

WordPress shows "Maximum upload file size" in Media β†’ Add New. To increase it:

Create .user.ini in your WordPress root:

upload_max_filesize = 128M
post_max_size = 128M

Important: post_max_size must be equal to or larger than upload_max_filesize.

Fixing "Maximum execution time exceeded"

If WordPress updates, plugin installations, or backups timeout:

max_execution_time = 300
max_input_time = 300

This allows scripts to run for 5 minutes instead of 30 seconds.

Resolving "Allowed memory size exhausted"

If PHP runs out of memory:

memory_limit = 512M

WordPress typically needs 256M–512M for complex sites with many plugins.

Enabling error logging

To log PHP errors for debugging:

log_errors = On
error_log = /home/username/domains/yourdomain.co.za/error.log
display_errors = Off

Replace the path with your actual account path (found in DirectAdmin β†’ Account Info).

Disabling dangerous functions

For security, disable risky PHP functions:

disable_functions = exec,passthru,shell_exec,system,proc_open,popen

Warning: Some plugins (e.g., backup plugins) require these functions. Only disable if you are certain they are not needed.

Viewing current PHP settings

Method 1: phpinfo() script

  1. Create a file named info.php in your public_html folder
  2. Add this content:
<?php phpinfo(); ?>
  1. Visit https://yourdomain.co.za/info.php in your browser
  2. You will see all PHP settings and their current values

Security tip: Delete info.php after checking settings (it exposes server configuration).

Method 2: WordPress Site Health

In WordPress admin:

  1. Go to Tools β†’ Site Health
  2. Click the Info tab
  3. Expand Server section
  4. View current PHP settings and limits

PHP settings that cannot be changed

Some PHP settings are controlled by the server administrator and cannot be changed by users:

  • open_basedir: Restricts file access to specific directories (security)
  • allow_url_fopen: Controls remote file access
  • safe_mode: Deprecated security feature (removed in PHP 5.4+)
  • Certain function restrictions: Server-level security policies

If you need changes to these settings, contact 0724 Hosting support.

Troubleshooting PHP settings

Settings not applying

If your changes have no effect:

  • Wait 5 minutes: .user.ini is cached for up to 5 minutes
  • Check file location: Ensure .user.ini is in the correct directory
  • Verify PHP handler: .user.ini requires PHP-FPM (standard at 0724 Hosting)
  • Check syntax: Ensure no typos in setting names or values
  • View phpinfo(): Confirm current settings with phpinfo script

500 Internal Server Error after changes

If the website shows a 500 error:

  • Syntax error: Check .user.ini or .htaccess for typos
  • Invalid directive: Some settings are not allowed in user-level configuration
  • Wrong method: php_value directives in .htaccess cause errors with PHP-FPM
  • Fix: Remove or rename .user.ini/.htaccess temporarily to restore site

Upload limit not increasing

If WordPress still shows old upload limit:

  • Check both settings: Ensure upload_max_filesize AND post_max_size are increased
  • Clear cache: Clear WordPress cache and browser cache
  • Server limits: Contact support if server-level limits are lower than your settings
  • LiteSpeed cache: Flush LiteSpeed cache in WordPress admin

Scripts still timing out

If scripts timeout despite increased max_execution_time:

  • Web server timeout: Separate from PHP timeout (typically 300s at 0724 Hosting)
  • Plugin/theme limits: Some code overrides PHP settings
  • Database queries: Slow database queries cause timeouts regardless of PHP limits
  • External services: API calls to external services can timeout independently

Recommended PHP settings for WordPress

Optimal .user.ini configuration for most WordPress sites:

; File uploads
upload_max_filesize = 128M
post_max_size = 128M

; Memory and execution
memory_limit = 256M
max_execution_time = 300
max_input_time = 300

; Sessions
session.gc_maxlifetime = 1440

; Error handling (disable in production)
display_errors = Off
log_errors = On

Settings for WooCommerce sites

WooCommerce sites with many products need higher limits:

upload_max_filesize = 256M
post_max_size = 256M
memory_limit = 512M
max_execution_time = 600
max_input_vars = 5000

Security considerations

Never enable display_errors in production

Displaying errors exposes sensitive information to visitors:

; Good (production)
display_errors = Off
log_errors = On

; Bad (development only)
display_errors = On

Be cautious with large limits

  • Memory limits: Setting memory_limit too high (>1GB) can cause server resource issues
  • Execution time: Very long timeouts (>600s) may allow abuse or indicate inefficient code
  • Upload limits: Extremely large uploads (>500M) can fill disk space quickly

PHP settings for different hosting plans

Default limits by 0724 Hosting plan:

  • Entry-level plans: 128M memory, 30s execution, 32M upload
  • Mid-tier plans: 256M memory, 60s execution, 64M upload
  • Premium plans: 512M memory, 120s execution, 128M upload
  • Reseller plans: Custom limits (set per customer)

You can increase these limits using .user.ini within your account's resource allocation.

PHP-FPM vs mod_php

0724 Hosting uses PHP-FPM (FastCGI Process Manager) for better performance:

Feature PHP-FPM mod_php
Performance Faster, more efficient Slower
Configuration file .user.ini or php.ini .htaccess or php.ini
Changes apply Within 5 minutes (cached) Immediately
Resource usage Lower memory footprint Higher memory usage

At 0724 Hosting: All accounts use PHP-FPM. Use .user.ini for configuration changes.

Getting help with PHP configuration

If you need assistance adjusting PHP settings, troubleshooting configuration errors, optimising PHP performance, or determining appropriate limits, contact 0724 Hosting support. We can help diagnose issues, recommend optimal settings, and adjust server-level limits if needed.