CentOS8迁移至Ubuntu18.04后CodeIgniter 1.7.2空白页问题求助
Hey there, let's tackle this blank page issue with your old CodeIgniter 1.7.2 setup on Ubuntu 18.04 — I’ve dealt with similar legacy CI headaches before, so here are some targeted steps to dig up the root cause:
1. Force CodeIgniter to Log Its Own Errors
Even if PHP’s error reporting is enabled, CI 1.7.2 has its own internal logging system that might be disabled by default. Head to application/config/config.php and update these settings:
$config['log_threshold'] = 2; // Logs errors and debug messages (adjust to 4 for more detail) $config['log_path'] = './application/logs/'; // Ensure this path is correct
Critical note: The application/logs folder needs write permissions for Ubuntu’s web server user (www-data). Run these commands to fix that:
sudo chown www-data:www-data /path/to/your/app/application/logs sudo chmod 755 /path/to/your/app/application/logs
This should start capturing CI-specific errors that PHP’s logs might miss.
2. Hunt for Legacy PHP Function Conflicts
CI 1.7.2 is ancient (released in 2009), so it’s likely clashing with PHP 5.6+/7.2’s deprecated/removed functions:
- Check your custom libraries (like
jempe_dboremployees_library) for oldmysql_*calls — you switched CI’s core driver to mysqli, but custom code might still be using outdated MySQL functions. - Look for
ereg*functions (deprecated in PHP 5.3, gone in 7.0) — replace them withpreg_matchif you find any. - Temporarily disable session database storage: Set
$config['sess_use_database'] = FALSE;inconfig.phpto rule out session-related crashes.
3. Debug the Bootstrap Step-by-Step
Blank pages usually mean a fatal error before any output is sent. Add manual debug checks to your main index.php (the CI entry point):
error_reporting(E_ALL); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); // Test if the script even starts echo "Script initialized...<br>";
Then, add echo statements in application/config/autoload.php to pinpoint which library is breaking things:
$autoload['libraries'] = array(); echo "Loading jempe_form...<br>"; $autoload['libraries'][] = 'jempe_form'; echo "Loading jempe_db...<br>"; $autoload['libraries'][] = 'jempe_db'; // Repeat for each library in your original list
This will show you exactly where the script stops executing.
4. Check Apache’s Error Logs
Don’t ignore the web server logs! For Apache on Ubuntu, they’re located at /var/log/apache2/error.log. Run this command to watch logs in real-time while you load the page:
sudo tail -f /var/log/apache2/error.log
You might find permission errors, missing files, or server-level issues that PHP isn’t reporting.
5. Fix File Permissions Across the Board
Ubuntu’s www-data user needs read access to all CI files, and write access to specific folders (logs, cache). Run these commands to set proper permissions:
// Set ownership to the web server user sudo chown -R www-data:www-data /path/to/your/application // Set folders to 755, files to 644 (standard secure permissions) find /path/to/your/application -type d -exec chmod 755 {} \; find /path/to/your/application -type f -exec chmod 644 {} \;
Double-check custom library files (like jempe_form.php) to ensure they’re readable by www-data.
6. Test a Minimal CI Setup
To rule out custom code issues, create a bare-bones test:
- Rename your current
applicationfolder toapplication-old. - Copy the fresh
applicationfolder from a CI 1.7.2 archive into your project. - Update
database.phpwith your credentials (using mysqli) and setlog_thresholdto 2. - Load the default welcome page. If this works, start adding back your custom libraries/configs one by one to find the culprit.
Legacy CI versions can be finicky with newer PHP environments, but methodical debugging almost always reveals the hidden error. Good luck!
内容的提问来源于stack exchange,提问作者Muhammad Salahuddin

