Hardening PHP 7 and below using cPanel
If your application is still running on PHP 7.0 or earlier, it is important to harden your environment to reduce security risks. On ruachost.com, you can configure PHP settings directly in cPanel to improve security and performance.
Why Harden PHP?
Section titled “Why Harden PHP?”- PHP 7 and below are end‑of‑life and no longer receive official security updates.
- Hardened settings reduce exposure to vulnerabilities.
- Helps prevent exploits such as remote file inclusion, code injection, and information leakage.
Steps to Harden PHP in cPanel
Section titled “Steps to Harden PHP in cPanel”Step 1: Check Your PHP Version
Section titled “Step 1: Check Your PHP Version”-
Log in to cPanel.
-
Go to Software → Select PHP Version.
-
Confirm the current version.
- Ruachost supports multiple versions (4.4 through 8.4).
- If possible, upgrade to PHP 8.x for better security.
Step 2: Configure PHP Settings
Section titled “Step 2: Configure PHP Settings”In cPanel → Select PHP Version → Options tab, adjust the following:
-
Remote connection settings
Section titled “Remote connection settings”-
Disable remote file access:
- Clear
allow_url_fopen - Clear
allow_url_include
- Clear
-
-
Script processing time
Section titled “Script processing time”-
Limit execution time:
- Set
max_input_time = 30 - Set
max_execution_time = 30
- Set
-
-
Memory usage
Section titled “Memory usage”-
Reduce memory limit:
- Change
memory_limitfrom default (e.g., 768M) to a lower value (e.g., 128M–256M).
- Change
-
-
PHP exposure
Section titled “PHP exposure”-
Hide PHP version in headers:
- Clear
expose_php
- Clear
-
-
Error handling
Section titled “Error handling”-
Prevent information leakage:
- Clear
display_errors - Enable
log_errorsand set a secureerror_logpath
- Clear
-
-
File uploads
Section titled “File uploads”-
Disable if not needed:
- Clear
file_uploads
- Clear
-
If required, set a reasonable
upload_max_filesize(e.g., 10M).
-
Step 3: Test Your Application
Section titled “Step 3: Test Your Application”- Visit your site and confirm functionality.
- Check logs for errors.
- Adjust settings as needed to balance security and usability.