红联Linux门户
Linux帮助

ubuntu15.04编译安装php5.3和5.2

发布时间:2015-05-10 09:28:55来源:blog.sina.com.cn/xiazhujie作者:漫步海边小路

我安装的ubuntu  mate 桌面64位
源里的php版本太高,像ecshop这种的程序跑起来老报错,调起来费劲,所以装个5.3.
先卸载php5.6:
sudo apt-get --purge remove php5
sudo apt-get autoremove php5
用 dpkg -l | grep php 和dpkg -l | grep php5 检查,如无返回即干净卸载


下面说一下编译安装php5.3,下载地址:http://php.net/releases/
自己找一个版本,我安装的是5.3.29,以下是具体过程:

下载并解压,执行:
./configure --prefix=/usr/local/php --with-mcrypt --with-gettext --with-mysql --with-gd --with-jpeg-dir --with-png-dir --with-curl --with-freetype-dir --enable-gd-native-ttf --enable-mbstring --enable-sockets --with-pdo-mysql --enable-fpm --with-zlib --enable-zip --with-bz2 --enable-bcmath --with-tidy --with-fpm-user=daemon --with-fpm-group=daemon

报错:error: xml2-config not found. Please check your libxml2 installation.
安装: libxml2-dev

报错:configure: error: Please reinstall the BZip2 distribution
安装: libbzip2-dev

报错:configure: error: Please reinstall the libcurl distribution - easy.h should be in /include/curl/
安装:libcurl4-gnutls-dev

报错:configure: error: jpeglib.h not found.
安装:libjpeg-dev

报错:configure: error: freetype.h not found.
解决办法:
安装:libfreetype6-dev

报错:configure: error: freetype.h not found.
但是libfreetype6-dev和libfreetype6已经安装了,需要做个软链接
ln -sf /usr/include/freetype2 /usr/include/freetype2/freetype

报错:configure: error: mcrypt.h not found. Please reinstall libmcrypt.
安装:libmcrypt-dev

报错:configure: error: Cannot find MySQL header files under yes.
Note that the MySQL client library is not bundled anymore!
安装:libmysql++-dev

报错:configure: error: Cannot find libtidy
安装:libtidy-dev


没问题的话画出现:
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.


然后:make
可以先make test测试一下,如果有问题会出现:
You may have found a problem in PHP.
This report can be automatically sent to the PHP QA team at
http://qa.php.net/reports and http://news.php.net/php.qa.reports
This gives us a better understanding of PHP's behavior.
If you don't want to send the report immediately you can choose
option "s" to save it.  You can then email it to qa-reports@lists.php.net later.
Do you want to send this report now? [Yns]:
我的出现了这个问题,不过没什么影响


最后sudo make install
安装后会出现:
Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
/home/xxx/下载/php-5.3.29/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f /usr/local/php/bin/phar.phar /usr/local/php/bin/phar
Installing PDO headers:          /usr/local/php/include/php/ext/pdo/


安装位置是/usr/local/php,所以要改一下/etc/php5/apache2/php.ini,添加include_path = "/usr/local/php/lib/php"
把原来的/usr/bin/php删掉,或者改名:sudo mv /usr/bin/php /usr/bin/php.bak
把编译出来的php5.3做个软链接:sudo ln -s /usr/local/php/bin/php /usr/bin/php

ecshop说好的支持php5.3和5.2,但是安装了5.2还是报错,再下php5.2.10,重新编译,方法类似,多的报错:
configure: error: libjpeg.(a|so) not found.
sudo ln -s /usr/lib/i386-linux-gnu/libjpeg.so.8 /usr/lib/libjpeg.so

configure: error: libpng.(a|so) not found.
sudo ln -s /usr/lib/i386-linux-gnu/libpng12.so.0 /usr/lib/libpng.so

configure: error: Cannot find libmysqlclient under /usr.
sudo ln -s /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18 /usr/lib/libmysqlclient.so


在Ubuntu Kylin中安装PHP开发环境:http://www.linuxdiyf.com/linux/9908.html

CentOS 6.4中yum命令安装php5.2.17:http://www.linuxdiyf.com/linux/10828.html

在RedHat Linux编译安装php常见问题解决:http://www.linuxdiyf.com/linux/8520.html

CentOS 6.2编译安装PHP5.4.0:http://www.linuxdiyf.com/linux/3130.html

Linux下安装php的gettext扩展:http://www.linuxdiyf.com/linux/5048.html