PHP info page is not working
Introduction
If your PHP info page is not reflecting changes on your VPS, it is usually due to the PHP configuration not being loaded correctly. This solution ensures that your custom php.ini file is properly applied using CGI.
Prerequisites
- Access to VPS via SSH
- cPanel environment
- Basic knowledge of file editing (vi/nano)
- Correct username and directory path
Implementation
- Copy PHP CGI file :
Copy the default PHP CGI file to your user directory:
cp /usr/local/cpanel/cgi-sys/php5.cgi /home/username/public_html/cgi-bin
- Create a CGI script
Navigate to the cgi-bin directory and create a file:
cd /home/username/public_html/cgi-bin
vi phpini.cgi
Add the following content:
#!/bin/sh
export PHPRC=/home/username/public_html
exec /home/username/public_html/cgi-bin/php5.cgi
- Add the php.ini file
Place your custom php.ini file in:
/home/username/public_html
- Update .htaccess
Edit the .htaccess file in your public_html directory and add:
AddHandler php-cgi .php
Action php-cgi /cgi-bin/phpini.cgi
- Set permissions
Ensure the CGI script has the correct permissions:
chmod 755 /home/username/public_html/cgi-bin/phpini.cgi
- Verify
Now check your PHP info page in the browser.
Conclusion
By configuring PHP to use a custom php.ini via CGI, your changes should reflect correctly on the PHP info page. This method ensures your VPS uses the intended configuration file.
