linux下php 5.4.* 编译安装步骤详解
2019/10/10/17:45:22 阅读:1985 来源:谷歌SEO算法 标签:
谷歌CEO
php 5.4.* 编译安装小编觉得是有点多余了,因为使用常规安装其实非常 的快了,但编译安装会比较好一些了,下面一起来看看linux中php 5.4.* 编译安装步骤.
据说php5.4要比此前各版本的php快不少,所以有必要安装来测试一下,国内比较流行的一些php程序比如discuz等等对php5.4的支持貌似还不太友好,所以站长朋友们还是要慎重升级,下面是在64位centos6.1上面编译安装的笔记,仅供参考.
1、下载
- wgethttp://cn.php.net/get/php-5.4.8.tar.gz/from/this/mirror
- wgethttp://pecl.php.net/get/memcache-2.2.7.tgz
- wgethttp://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
- wgethttps://github.com/downloads/libevent/libevent/libevent-2.0.20-stable.tar.gz
- wgethttps://memcached.googlecode.com/files/memcached-1.4.15.tar.gz
- wget"http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0"
- wget"http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?modtime=1194463373&big_mirror=0"//phpfensi.com
- wgetftp://ftp.kddlabs.co.jp/graphics/ImageMagick/ImageMagick.tar.gz
- wget"http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?modtime=1175740843&big_mirror=0"
- wgethttp://pecl.php.net/get/imagick-3.1.0RC2.tgz
2、另外一些准备工作
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/ 假定mysql已经安装,不加这个的话后面编译的时候可能会出错.
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/ 假定mysql已经安装,不加这个的话后面编译的时候可能会出错.
- yuminstallncurses-devellibxml2-develbzip2-devellibcurl-develcurl-devellibjpeg-devellibpng-develfreetype-develnet-snmp-devel-y
- ln-s/usr/local/mysql/lib/libmysqlclient.so.18/usr/lib64///phpfensi.com
假定mysql已经安装,不加这个的话后面编译的时候可能会出错.
3、还有这些准备工作,编译一些php需要用到的支持库.
- tarxzvflibic*
- cdlibic*
- ./configure--prefix=/usr/local
- make
- makeinstall
- cd..
- tarxzvflibmcry*
- cdlibmcry*
- ./configure
- make
- makeinstall
- /sbin/ldconfig
- cdlibltdl/
- ./configure
- --enable-ltdl-install
- make
- makeinstall
- cd../../
- tarzxvfmhash-0.9.9.9.tar.gz
- cdmhash-0.9.9.9/
- ./configure
- make
- makeinstall
- cd../
- 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.so.2.0.1/usr/lib/libmhash.so.2.0.1
- ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config
- tarzxvfmcrypt-2.6.8.tar.gz
- cdmcrypt-2.6.8/
- /sbin/ldconfig
- ./configure
- make
- makeinstall
- cd../
4、开始编译安装php
- tarxvzfphp-5.4.*.tar.gzcdphp-5.4.*
- ./configure--prefix=/usr/local/php--with-config-file-path=/etc\
- --with-mysql=/usr/local/mysql/--with-mysqli=/usr/local/mysql/bin/mysql_config\
- --with-pdo-mysql=/usr/local/mysql/--with-iconv-dir=/usr/local--enable-fpm\
- --disable-phar--with-fpm-user=www--with-fpm-group=www--with-pcre-regex\
- --with-zlib--with-bz2--enable-calendar--with-curl--enable-dba--with-libxml-dir\
- --enable-ftp--with-gd--with-jpeg-dir--with-png-dir--with-zlib-dir--with-freetype-dir\
- --enable-gd-native-ttf--enable-gd-jis-conv--with-mhash--enable-mbstring--with-mcrypt\
- --enable-pcntl--enable-xml--disable-rpath--enable-shmop--enable-sockets--enable-zip\
- --enable-bcmath--with-snmp--disable-ipv6
- makeZEND_EXTRA_LIBS='-liconv'
- maketest
- makeinstall
- cpphp.ini-production/etc/php.ini
5、编译安装php的一些扩展模块
- tarzxvfmemcache-*.tgz
- cdmemcache-*/
- /usr/local/php/bin/phpize
- ./configure--with-php-config=/usr/local/php/bin/php-config
- make
- makeinstall
- cd../
- tarxzvflibevent*
- cdlibevent*
- ./configure--prefix=/usr/local
- make
- makeinstall
- cd..
- tarxvzfmemcached-*.gz
- cdmemcached-*
- ./configure--with-libevent=/usr/local--prefix=/usr/local/memcached
- make
- makeinstall
- cd../
- tarzxvfImageMagick.tar.gz
- cdImageMagick-*/
- ./configure
- make
- makeinstall
- cd../
- tarzxvfimagick-*.tgz
- cdimagick-*/
- exportPKG_CONFIG_PATH=/usr/local/lib/pkgconfig//usr/local/php/bin/phpize
- ./configure--with-php-config=/usr/local/php/bin/php-config
- make
- makeinstall
- cd../
6、修改php的一些参数配置
vi /etc/php.ini
增加这些:
- extension_dir=/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
- extension="memcache.so"
- extension="imagick.so"
修改这些:cgi.fix_pathinfo=0
服务器安装好php之后,出于安全考虑,需要禁用掉一些有潜在危险的php函数,下面这些函数如果没有特殊需要,可以禁用掉:
- exec,system,phpinfo,eval,passthru,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,fsocket,fsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server
禁用方法:修改php.ini,找到disable_functions,修改为:
- disable_functions=exec,system,phpinfo,eval,passthru,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,fsocket,fsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server
热门评论