启动Apache服务器时遇/usr/sbin/httpd符号查找错误求助
Hey there, let's work through this Apache startup error together. The undefined symbol: apr_bucket_alloc_aligned_floor error almost always boils down to a mismatch between the Apache (httpd) binary and the APR (Apache Portable Runtime) libraries on your system. Here's how to diagnose and fix it:
Step 1: Diagnose the Dependency Mismatch
First, let's confirm which APR libraries httpd is trying to use, and compare them to the system's installed APR version:
- Run this command to see the APR libraries linked to httpd:
This will show you the full paths of the APR libraries httpd is referencing.ldd /usr/sbin/httpd | grep apr - Next, check the system's active APR version:
If the version fromapr-1-config --versionapr-1-configdoesn't match the libraries linked in the first command, or if the library paths point to outdated/mismatched files, that's your root cause.
Step 2: Fix Library Path Issues
Sometimes httpd is picking up the wrong APR libraries because of incorrect library path configurations:
- Try temporarily setting the library path to point to the correct APR libraries (replace
/path/to/correct/apr/libwith the valid path from yourlddoutput or your system's official APR libs):export LD_LIBRARY_PATH=/path/to/correct/apr/lib:$LD_LIBRARY_PATH - Then attempt to start httpd again:
service httpd start - If this works, make the path change permanent by adding the APR library path to a new config file:
echo "/path/to/correct/apr/lib" > /etc/ld.so.conf.d/apr.conf ldconfig
Step 3: Reinstall or Recompile Matching Components
If the path fix doesn't work, you'll need to ensure httpd and APR are fully compatible:
For Package-Managed Systems (Yum/DNF/Apt)
- Uninstall the existing mismatched packages:
# For RHEL/CentOS yum remove httpd apr apr-util # For Debian/Ubuntu apt purge apache2 libapr1 libaprutil1 - Reinstall the official, compatible packages:
# For RHEL/CentOS yum install httpd apr apr-util # For Debian/Ubuntu apt install apache2 libapr1 libaprutil1
For Manually Compiled Apache
If you built httpd from source, recompile it with the correct APR libraries:
- First, clean old build files:
make clean - Configure the build with explicit paths to your APR and APR-util installations:
./configure --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util - Recompile and install:
make && make install
Step 4: Verify the Fix
After making changes, confirm Apache starts successfully:
# For systemd systems systemctl start httpd systemctl status httpd # For non-systemd systems service httpd start service httpd status
You can also double-check the linked libraries again with ldd /usr/sbin/httpd | grep apr to ensure everything matches.
内容的提问来源于stack exchange,提问作者ganesh sekaran

