When manually upgrading from PHP 5.2 to PHP 5.3.1 on Ubuntu 8.04, Apache fails to start with a critical symbol loading error:
apache2: Syntax error on line 185 of /etc/apache2/apache2.conf:
Syntax error on line 1 of /etc/apache2/mods-enabled/php5.load:
Cannot load /usr/lib/apache2/modules/libphp5.so into server:
/usr/lib/apache2/modules/libphp5.so: undefined symbol: OnUpdateLong
The error occurs because of conflicting PHP installations. The key observations:
- Previous PHP 5.2 was installed via package manager
- Manual installation of PHP 5.3.1 in /opt/php/
- Apache still tries to load old module path (/usr/lib/apache2/modules/)
- Symbol mismatch between compiled and loaded versions
Here's the step-by-step resolution process:
# First, completely remove old PHP traces
sudo apt-get remove --purge php5 libapache2-mod-php5
# Clean up remaining files
sudo rm -f /usr/lib/apache2/modules/libphp5.so
sudo rm -f /etc/apache2/mods-enabled/php5.load
sudo rm -f /etc/apache2/mods-enabled/php5.conf
# Rebuild PHP with proper paths
cd /path/to/php-5.3.1/
make clean
./configure --prefix=/opt/php \
--with-mysql \
--with-curl=/usr/bin \
--with-apxs2=/usr/bin/apxs2 \
--libdir=/usr/lib
make
sudo make install
# Update Apache configuration
sudo ln -s /opt/php/libphp5.so /usr/lib/apache2/modules/
sudo echo "LoadModule php5_module /usr/lib/apache2/modules/libphp5.so" > /etc/apache2/mods-enabled/php5.load
After implementing the solution, verify:
# Check PHP CLI version
/opt/php/bin/php -v
# Verify Apache module loading
apache2ctl -M | grep php
# Test PHP info page
echo "<?php phpinfo(); ?>" > /var/www/test.php
If the above doesn't work, consider rebuilding with static linking:
./configure --prefix=/opt/php \
--with-mysql \
--with-curl=/usr/bin \
--with-apache2=/usr/bin/apxs2 \
--enable-static \
--disable-shared
- Always backup configuration files before making changes
- Consider using php-fpm as alternative to mod_php
- For production systems, consider using PPAs instead of manual builds
- Ubuntu 8.04 reached EOL in 2013 - strongly consider upgrading
After manually installing PHP 5.3.1 on Ubuntu 8.04 (previously running PHP 5.2 via package manager), Apache fails to start with the following error:
apache2: Syntax error on line 185 of /etc/apache2/apache2.conf:
Syntax error on line 1 of /etc/apache2/mods-enabled/php5.load:
Cannot load /usr/lib/apache2/modules/libphp5.so into server:
/usr/lib/apache2/modules/libphp5.so: undefined symbol: OnUpdateLong
The error occurs due to version mismatch between the PHP core and Apache module. The key points:
- The manually compiled PHP 5.3.1 was installed to
/opt/php/
- Apache is still trying to load the old module from
/usr/lib/apache2/modules/libphp5.so
- The
OnUpdateLong
symbol belongs to PHP's Zend Engine API which changed between versions
Here's how to properly clean up and reconfigure the setup:
# Remove old PHP module references
sudo rm /etc/apache2/mods-enabled/php5.*
sudo rm /usr/lib/apache2/modules/libphp5.so
# Rebuild PHP with proper Apache integration
cd /path/to/php-5.3.1-source/
make clean
./configure --prefix=/opt/php \
--with-mysql \
--with-curl=/usr/bin \
--with-apxs2=/usr/bin/apxs2 \
--with-config-file-path=/etc/php5/apache2
make
sudo make install
# Create new Apache configuration
echo "LoadModule php5_module /opt/php/libphp5.so" | sudo tee /etc/apache2/mods-available/php5.load
sudo a2enmod php5
sudo service apache2 restart
After implementing the solution, verify with:
# Check PHP CLI version
/opt/php/bin/php -v
# Check Apache module loading
apache2ctl -M | grep php
# Create test file
echo "<?php phpinfo(); ?>" > /var/www/test.php
If rebuilding doesn't work, consider these additional steps:
# Completely remove old PHP packages
sudo apt-get purge libapache2-mod-php5 php5-common
# Reinstall dependencies
sudo apt-get install apache2 apache2-prefork-dev
# Then rebuild PHP as shown above
- Always run
make clean
between configuration changes - Ensure consistent PHP versions between CLI and Apache modules
- Check
ldd /opt/php/libphp5.so
for missing dependencies - Consider using
--with-libdir=lib
if you encounter 32/64-bit issues