Ubuntu安装apache及问题解决
1.安装apache需要下载4个软件包:
httpd-2.4.3.tar.bz2 ---http server
apr-1.4.6.tar.bz2 ---apr
apr-util-1.5.1.tar.bz2 ---apr-util
pcre-8.31.tar.bz2 ---pcre
安装完后面3个依赖包后,按照httpd,./configure 时加上参数 --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
然后make,make install
添加apache服务到开机自动启动
$cp /usr/local/apache2/bin/apachectl /etc/init.d/
$update-rc.d apachectl defaults
启动apache, /etc/init.d/apachectl start,报如下错误:
/usr/local/apache2/bin/httpd: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
# ldd httpd linux-vdso.so.1 => (0x00007fff691ff000) libpcre.so.1 => not found libaprutil-1.so.0 => /usr/local/apache2/lib/libaprutil-1.so.0 (0x00007ff847f31000) libapr-1.so.0 => /usr/local/apache2/lib/libapr-1.so.0 (0x00007ff847d00000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff847ae3000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff847726000) libexpat.so.0 => /usr/local/apache2/lib/libexpat.so.0 (0x00007ff8474fb000) libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007ff8472c2000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff8470be000) /lib64/ld-linux-x86-64.so.2 (0x00007ff848165000)
显示 libpcre.so.1 => not found
解决方法:
1. 搜索libpcre.so.1文件,发现该文件在/usr/local/lib目录下。
2. 在/etc/ld.so.conf.d目录下新建文件libc.conf,将/usr/local/lib目录加到该文件:
/usr/local/lib
#sudo ldconfig
# ldd httpd linux-vdso.so.1 => (0x00007fffcc3ff000) libpcre.so.1 => /usr/local/lib/libpcre.so.1 (0x00007f2f68f98000) libaprutil-1.so.0 => /usr/local/apache2/lib/libaprutil-1.so.0 (0x00007f2f68d76000) libapr-1.so.0 => /usr/local/apache2/lib/libapr-1.so.0 (0x00007f2f68b45000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f2f68928000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2f6856b000) libexpat.so.0 => /usr/local/apache2/lib/libexpat.so.0 (0x00007f2f68340000) libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f2f68107000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f2f67f03000) /lib64/ld-linux-x86-64.so.2 (0x00007f2f691c7000)