LAMP升级

这篇博客详细记录了一次LAMP(Linux、Apache、MySQL、PHP)环境升级过程中遇到的问题,包括apache升级时依赖库的安装,重装mysql和php时的报错,特别是配置和编译php时libmysqlclient_r、libltdl和libgd库的问题。通过查找错误、下载和安装最新库,最终成功解决了所有问题并完成了LAMP环境的升级。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.apache 升级
新下载apache
提示少apr apr-util pcre 
果断下载最新版,安装,然后--with- 指定地址
2.启动apache报错 
根据提示,重装mysql
重装陈功
目前重装php中
各种报错,
configure: error: mysql configure failed. Please check config.log for more information.
准备更换新版本mysql


没有更换


根据config.log
configure:59628: gcc -o conftest -I/usr/include -g -O2 -pthread  -D_REENTRANT -Wl,-rpath,/usr/local/mysql//lib/mysql -L/usr/local/mysql//lib/mysql -L/usr/lib  -Wl,-rpath,/usr/local/libxml2/lib -L/usr/local/libxml2/lib -Wl,-rpath,/usr/local/jpeg8//lib -L/usr/local/jpeg8//lib -Wl,-rpath,/usr/local/freetype//lib -L/usr/local/freetype//lib -Wl,-rpath,/usr/local/gd//lib -L/usr/local/gd//lib -Wl,-rpath,/usr/local/libmcrypt//lib -L/usr/local/libmcrypt//lib conftest.c -lmysqlclient_r  -lmcrypt -lltdl -lgd -lfreetype -ljpeg -lresolv -lm -ldl -lnsl  -lxml2 -lm -lxml2 -lm 1>&5
/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status
configure: failed program was:
#line 59617 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error.  */
/* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
char mysql_close();


int main() {
mysql_close()
; return 0; }
configure:59851: checking for mysql_error in -lmysqlclient_r
configure:59870: gcc -o conftest -I/usr/include -g -O2 -pthread  -D_REENTRANT -Wl,-rpath,/usr/local/mysql//lib/mysql -L/usr/local/mysql//lib/mysql -L/usr/lib  -Wl,-rpath,/usr/local/libxml2/lib -L/usr/local/libxml2/lib -Wl,-rpath,/usr/local/jpeg8//lib -L/usr/local/jpeg8//lib -Wl,-rpath,/usr/local/freetype//lib -L/usr/local/freetype//lib -Wl,-rpath,/usr/local/gd//lib -L/usr/local/gd//lib -Wl,-rpath,/usr/local/libmcrypt//lib -L/usr/local/libmcrypt//lib -Wl,-rpath,/usr -L/usr conftest.c -lmysqlclient_r  -lz -lmcrypt -lltdl -lgd -lfreetype -ljpeg -lresolv -lm -ldl -lnsl  -lxml2 -lm -lxml2 -lm 1>&5
/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status
configure: failed program was:
#line 59859 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error.  */
/* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
char mysql_error();


int main() {
mysql_error()
; return 0; }


找不到-lltdl  
找到libltdl文件夹


find / -name libltdl


./configure  -enable-ltdl-install


make


make install


然后
进入php文件夹


执行
 ./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/php/etc/ --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql/ --with-libxml-dir=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg8/ --with-freetype-dir=/usr/local/freetype/ --with-gd=/usr/local/gd/ --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets
 没问题
 make报错


 ext/standard/.libs/info.o: In function `php_info_print_table_header':
/download/LAMP/php-5.2.6/ext/standard/info.c:879: undefined reference to `ts_resource_ex'
ext/standard/.libs/info.o: In function `php_info_print_table_row_internal':
/download/LAMP/php-5.2.6/ext/standard/info.c:923: undefined reference to `ts_resource_ex'
ext/standard/.libs/info.o: In function `php_print_gpcse_array':
/download/LAMP/php-5.2.6/ext/standard/info.c:133: undefined reference to `executor_globals_id'
ext/standard/.libs/info.o: In function `php_info_write_wrapper':
/download/LAMP/php-5.2.6/ext/standard/info.c:67: undefined reference to `ts_resource_ex'
ext/standard/.libs/info.o: In function `php_print_info':
/download/LAMP/php-5.2.6/ext/standard/info.c:747: undefined reference to `executor_globals_id'
/download/LAMP/php-5.2.6/ext/standard/info.c:750: undefined reference to `executor_globals_id'
/download/LAMP/php-5.2.6/ext/standard/info.c:753: undefined reference to `executor_globals_id'
/download/LAMP/php-5.2.6/ext/standard/info.c:756: undefined reference to `executor_globals_id'
/download/LAMP/php-5.2.6/ext/standard/info.c:680: undefined reference to `sapi_globals_id'
/download/LAMP/php-5.2.6/ext/standard/info.c:468: undefined reference to `sapi_globals_id'
/download/LAMP/php-5.2.6/ext/standard/info.c:659: undefined reference to `sapi_globals_id'
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] 错误 1


正在找解决办法


make clean


make


Build complete.
Don't forget to run 'make test'.


make install 


应该是成功了


[root@localhost php-5.2.6]# /usr/local/apache2/bin/apachectl start
httpd: Syntax error on line 57 of /etc/httpd/httpd.conf: Cannot load modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: undefined symbol: unixd_config




apache启动发生错误


1.http2.2.* 不能直接升级到2.4.1,需要先停止apache,将http.conf 改名成http.conf-2.2.*


2.http2.4.1 目前不再支持php5.2.* 可用的php为5.3.10


php5.2* 会报 httpd: Syntax error on line 163 of httpd.conf: Cannot load modules/libphp5.so into server: modules/libphp5.so: undefined symbol: unixd_config




apache版本2.4.6
php版本5.2.6


下载最新版php PHP-5.5.3.tar.gz 
 ./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/php/etc/ --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql/ --with-libxml-dir=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg8/ --with-freetype-dir=/usr/local/freetype/ --with-gd=/usr/local/gd/ --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets


报错
checking for T1lib support... no
checking whether to enable truetype string function in GD... no
checking whether to enable JIS-mapped Japanese font support in GD... no
If configure fails try --with-vpx-dir=<DIR>
checking for jpeg_read_header in -ljpeg... yes
configure: error: png.h not found.


重新编译安装 libpng  尝试指定目录 --with-png-dir=/usr/local/libpng/


继续报错 configure: error: Unable to find libgd.(a|so) >= 2.1.0 anywhere under /usr/local/gd/


重装GD库 


./configure --prefix=/usr/local/gd --with-png=/usr/local/libpng/ --with-jpeg=/usr/local/jpeg8/ --with-freetype=/usr/local/freetype/


GD库重装成功


尝试重装PHP 
依然报错


查找到libgd.*位置
复制到/usr/local/gd/


依然找不到。


找到原因,GD库版本过低,低于2.1.0 下载最新版本


./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg8/ --with-freetype=/usr/local/freetype/ --with-png=/usr/local/libpng/


make && make install




成功


[root@localhost php-5.5.3]#  ./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/php/etc/ --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql/ --with-libxml-dir=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg8/ --with-freetype-dir=/usr/local/freetype/ --with-gd=/usr/local/gd/ --with-png-dir=/usr/local/libpng/ --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets


无报错


make


/download/LAMP/php-5.5.3/ext/gd/gd.c:57:22: 错误:X11/xpm.h:没有那个文件或目录


下载libxpm  解压 移动位置到/usr/local/libxpm


添加 --with-libXpm-dir=/usr/local/libxpm


失败


使用yum install libXmp-devel


重装GD库,支持Xmp




PHP去掉 --with-libXpm-dir=/usr/local/libxpm


无报错


make && make install


成功


重启后,/usr/local/apache2/bin/apachectl start


httpd: Syntax error on line 58 of /etc/httpd/httpd.conf: Could not open config directory /usr/local/apache2/conf.d: No such file or directory


新建conf.d后,


httpd: Syntax error on line 58 of /etc/httpd/httpd.conf: Could not open config directory /usr/local/apache2/conf.d: No such file or directory


失败


删除apache 所有文件夹 /etc/httpd /var/www /usr/local/apache2


重新安装,成功


PHP重新编译安装


成功架构LAMP
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值