正在加载中……
最新消息:欢迎大家访问,导航分类不完善,如果找不到自己想要的文章,可以通过【关键词】来进行搜索,^_^!

Linux(CentOS6.3)下编译安装php-5.3.18及出现问题的解决方法

Linux专题 REKFAN.COM 17623浏览 0评论

更多


第一步:安装系统环境需要的软件

# yum install -y apr* autoconf automake curl curl-devel gcc gcc-c++ zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel e2fsprogs e2fsprogs-devel libidn libidn-devel openssl openssl-devel pcre-devel gd kernel keyutils patch perl kernel-headers compat* mpfr cpp glibc glibc-devel libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5 krb5-libs krb5-devel krb5-server libXpm* freetype* libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 libxml2-devel patch openldap openldap-devel nss_ldap openldap-clients openldap-servers

第二步:下载安装PHP所需要的库

//---------------------------------------------------------------
1# wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
2# wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
3# wget http://downloads.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.bz2
4# wget http://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
5# wget http://cn2.php.net/get/php-5.3.18.tar.gz/from/this/mirror
6# wget http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz
7# wget http://pecl.php.net/get/memcache-3.0.6.tgz
8# wget http://downloads.sourceforge.net/project/eaccelerator/eaccelerator/eAccelerator%200.9.6.1/eaccelerator-0.9.6.1.zip
9# wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
10# wget ftp://ftp.kddlabs.co.jp/graphics/ImageMagick/ImageMagick-6.8.0-3.tar.gz
11# wget http://pecl.php.net/get/imagick-3.0.1.tgz
---------------------------------------------------------------//

第三步:编译安装PHP所需要的库

1.
# mkdir -p /data/src
# cd /data/src
# wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
# tar zxvf libiconv-1.14.tar.gz
# cd libiconv-1.14
# ./configure --prefix=/usr/local
# make && make install
2.
# cd ..
# wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
# tar zxvf libmcrypt-2.5.8.tar.gz
# cd libmcrypt-2.5.8/
# ./configure
# make && make install
# /sbin/ldconfig
# cd libltdl/
# ./configure --enable-ltdl-install
# make && make install
3.
# cd ../../
# wget http://downloads.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.bz2
# tar jxvf mhash-0.9.9.9.tar.bz2
# cd mhash-0.9.9.9
# ./configure
# make && make install
# echo "/usr/local/lib" >>/etc/ld.so.conf
# /sbin/ldconfig

 # ln -s /usr/local/lib/libmcrypt.la          /usr/lib/libmcrypt.la
 # ln -s /usr/local/lib/libmcrypt.so          /usr/lib/libmcrypt.so
 # ln -s /usr/local/lib/libmcrypt.so.4        /usr/lib/libmcrypt.so.4
 # ln -s /usr/local/lib/libmcrypt.so.4.4.8    /usr/lib/libmcrypt.so.4.4.8
 # ln -s /usr/local/lib/libmhash.a            /usr/lib/libmhash.a
 # ln -s /usr/local/lib/libmhash.la           /usr/lib/libmhash.la
 # ln -s /usr/local/lib/libmhash.so           /usr/lib/libmhash.so
 # ln -s /usr/local/lib/libmhash.so.2         /usr/lib/libmhash.so.2
 # ln -s /usr/local/lib/libmhash.so2.0.1      /usr/lib/libmhash.so2.0.1
 
4.
# cd ..
# wget wget http://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
# tar zxvf mcrypt-2.6.8.tar.gz
# cd mcrypt-2.6.8
# /sbin/ldconfig
# ./configure
# make && make install

第四步:编译安装PHP

5.
# cd /data/src
# wget http://cn2.php.net/get/php-5.3.18.tar.gz/from/this/mirror
6.
# wget http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz
tar zxvf php-5.3.18.tar.gz
# gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.3.18 -p1
# cd php-5.3.18
# sed -i "s/\!png_check_sig (sig, 8)/png_sig_cmp (sig, 0, 8)/" ext/gd/libgd/gd_png.c
#
# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --enable-ftp  --without-pear --with-gettext --enable-session
# make ZEND_EXTRA_LIBS='-liconv'
# make install
# cd ..

第五步:编译安装PHP扩展模块

7.
# wget http://pecl.php.net/get/memcache-3.0.6.tgz
# tar zxvf memcache-3.0.6.tgz
# cd memcache-3.0.6/
# /usr/local/php/bin/phpize
# ./configure --with-php-config=/usr/local/php/bin/php-config
# make && make install
8.
# cd ..
# wget http://downloads.sourceforge.net/project/eaccelerator/eaccelerator/eAccelerator%200.9.6.1/eaccelerator-0.9.6.1.zip
# unzip -x eaccelerator-0.9.6.1.zip
# cd eaccelerator-0.9.6.1/
# /usr/local/php/bin/phpize
# ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config --without-eaccelerator-use-inode
# make && make install
9.
# cd ..
# wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
# tar zxvf PDO_MYSQL-1.0.2.tgz
# cd PDO_MYSQL-1.0.2
# /usr/local/php/bin/phpize
# ./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
# make && make install
10.
# cd ..
# wget ftp://ftp.kddlabs.co.jp/graphics/ImageMagick/ImageMagick-6.8.0-3.tar.gz
# tar zxvf ImageMagick-6.8.0.3.tar.gz
# cd ImageMagick-6.8.0.3
# ./configure
# make && make install
11.
# cd ..
# wget http://pecl.php.net/get/imagick-3.0.1.tgz
# tar zxvf imagick-3.0.1.tgz
# cd imagick-3.0.1
# /usr/local/php/bin/phpize
# export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
其中export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig 如果这里不添加这一句会出现make的时候报错提示
[imagick_class.lo] Error 1
这里的pkgconfig路径是安装ImageMagick时指定的安装路径。
如果在安装ImageMagick的时候没有指定安装路径,那么默认就是用以下这句
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
如果指定了安装路径可以改成自己的路径就好,要是记不住了可以使用find命令搜索
# find /usr -name pkgconfig
/usr/lib/pkgconfig
/usr/local/lib/pkgconfig
/usr/share/pkgconfig

# ./configure --with-php-config=/usr/local/php/bin/php-config
# make && make install
# cd ..

第六步:修改php.ini文件

# cp php.ini-production /usr/local/php/etc/php.ini
# rm -rf /etc/php.ini #删除系统自带配置文件
# ln -s /usr/local/php/etc/php.ini /etc/php.ini #添加软链接
vi /usr/local/php/etc/php.ini #编辑配置文件
找到:disable_functions =
修改为:disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。

找到:;date.timezone =
修改为:date.timezone = PRC #设置时区
找到:expose_php = On
修改为:expose_php = OFF #禁止显示php版本的信息
找到:short_open_tag = Off
修改为:short_open_tag = ON #支持php短标签

第七步:创建php-fpm.conf文件

# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf #拷贝模板文件为php-fpm配置文件

第八步:创建www用户及启动php-fpm并加入启动脚本

cp data/src/php-5.3.18/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm #拷贝php-fpm到启动目录
chmod +x /etc/rc.d/init.d/php-fpm #添加执行权限
chkconfig php-fpm on #设置开机启动

php-fpm服务器相关操作命令:

 /usr/local/php5/sbin/php-fpm #启动php-fpm
/etc/rc.d/init.d/php-fpm restart #重启php-fpm
/etc/rc.d/init.d/php-fpm stop #停止php-fpm
/etc/rc.d/init.d/php-fpm start #启动php-fpm

安装过程中出现的问题及解决方法:

Q:configure:error: *** libmcrypt was not found
A:export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

Q:configure: error: "You need at least libmhash 0.8.15 to compile this program. http://mhash.sf.net/"
A:安装上述第三步 在重新编译

Q:configure: error: Cannot find ldap libraries in /usr/lib.
A:如果是X64位系统  cp -frp /usr/lib64/libldap* /usr/lib/

Q: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
make: *** [ext/phar/phar.phar] 错误 127

A:ln -s /usr/local/mysql/lib/libmysqlclient.so.18  /usr/lib64/

Q:cp: cannot stat `ext/phar/phar.phar': No such file or directory
A:cd  ext/phar/
cp ./phar.php  ./phar.phar

转载请注明:|REKFAN|系统运维| » Linux(CentOS6.3)下编译安装php-5.3.18及出现问题的解决方法

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址