php编译安装

一、准备安装

yum -y install gcc gcc-c++ gcc-g77 libmcrypt libmcrypt-devel php-mcrypt flex bison autoconf automake  bzip2-devel zlib-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel openssl-devel libxml2-devel gettext-devel  pcre-devel mysql-devel net-snmp-devel curl-devel perl-DBI mysql mysql-server httpd php php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc  php-bcmath php-mbstring

二、现在php

wget http://cn2.php.net/distributions/php-5.5.31.tar.gz

tar zxvf php-5.5.31.tar.gz

cd php-5.5.31.tar.gz

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache --enable-fpm --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --enable-mbstring --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl  --with-zlib --enable-zip --with-bz2

详解

./configure \

--prefix=/usr/local/php \                                    #php安装目录

--with-config-file-path=/usr/local/php/etc \     #指定php.ini位置

--enable-inline-optimization \                            #开启内联优化(优化选项

--disable-debug \                                                #禁用debug优化选项

--disable-rpath \                                                  #禁止传递附加的运行时库搜索路径优化选项

--enable-shared \                                                #允许编译共享库优化选项

--enable-opcache \                                             #开启opcache,加快php的响应速度

--enable-fpm \                                                    #PHP FastCGI管理器( nginx把http请求变量,如get,user_agent转发给php进程,即php独立进程,与nginx进行通讯,称为fastcgi运行方式)

--with-mysql=mysqlnd \                                    #Mysql Native Driver,php内置mysql原生驱动,与libmysql扩展相比,好处是,主要防止license纠纷(mysql属于 oracle公司,防止版权纠纷)和性能优化

--with-mysqli=mysqlnd \

--with-pdo-mysql=mysqlnd \

--with-gettext \                                                    #打开GNU的gettext支持,编码库用到

--enable-mbstring \                                             #多字节,字符串的支持

--with-iconv \                                                       #打开iconv函数,字符集间的转换

--with-mcrypt=/usr/local/mcrypt \                     #yum安装libmcrypt的话不需要设置路径,源码下载,解压安装的话,需要指定安装目录

--with-mhash \

--with-openssl \

--enable-bcmath \

--enable-soap \

--with-libxml-dir \

--enable-pcntl \

--enable-shmop \

--enable-sysvmsg \

--enable-sysvsem \

--enable-sysvshm \

--enable-sockets \

--with-curl \

--with-zlib \

--enable-zip \

--with-bz2

报错libcurl库未安装

wget http://curl.haxx.se/download/curl-7.46.0.tar.gz

tar zxvf curl-7.46.0.tar.gz

cd curl-7.46.0

./configure --prefix=/usr/local/curl

make  && make install

报错libmcrypt未安装

wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz

tar zxvf libmcrypt-2.5.7.tar.gz

cd libmcrypt-2.5.7.tar.gz

./configure --prefix=/usr/local/mcrypt

make  && make install


php编译安装_第1张图片

make && make install

cp /usr/local/src/php-5.5.31/php.ini-development /usr/local/php/lib/php.ini

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

/usr/local/php/sbin/php-fpm

把php-fpm加入path连接

ln -s /usr/local/php/sbin/php-fpm /bin/php-fpm

你可能感兴趣的:(php编译安装)