1.安装依赖
yum -y install make gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap lsof
安装epel-release源
yum install epel-release -y
安装 libiconv-1.14.tar.gz
(这个还有个devl包)
wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gztar zavf libiconv-1.15.tar.gz tar zxvf libiconv-1.15.tar.gz cd libiconv-1.15 ./configure makemake instal
安装 libmcrypt-2.5.8.tar.gz
建议 yum install libmcrypt
libmcrypt
-de*
wget https://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
mhash-0.9.9.9.tar.bz2
yum install mhash -y
mcrypt-2.6.8.tar.g
z
yum install mcrypt -y
通过yum 安装
wget http://mirrors.sohu.com/php/php-5.5.12.tar.gztar zxvf php-5.5.12.tar.gzcd php-5.5.12 ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts
php.7.1.8 ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts 报这个错的原因是 --enable-fastcgi参数已经去除了,不再需要添加该参数,默认开启。下次安装删除此参数。 configure: WARNING: unrecognized options: --enable-magic-quotes, --enable-safe-mode, --with-curlwrappers configure: error: Don't know how to define struct flock on this system, set --enable-opcache=no 参阅: http://lovelace.blog.51cto.com/1028430/1314571 make && make install
修改fpm配置php-fpm.conf.default文件名称
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
复制php.ini配置文件
cp php.ini-production /usr/local/php/etc/php.ini
复制php-fpm启动脚本到init.d
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
赋予执行权限
chmod +x /etc/init.d/php-fpm
添加为启动项
chkconfig --add php-fpm
设置开机启动
chkconfig php-fpm on
按照标准,给php-fpm创建一个指定的用户和组
创建群组groupadd www创建一个用户,不允许登陆和不创主目录 useradd -s /sbin/nologin -g www -M www
立即启动php-fpm
service php-fpm start#或者/etc/init.d/php-fpm start Starting php-fpm [15-Aug-2017 20:28:35] WARNING: Nothing matches the include pattern '/usr/local/php/etc/php-fpm.d/*.conf' from /usr/local/php/etc/php-fpm.conf at line 125. 153 cd /usr/local/php/etc/php-fpm.d/ 154 ls 155 cp www.conf.default www.conf 156 vi www.conf 157 /etc/init.d/php-fpm start
ext/iconv/.libs/iconv.o: In function `php_iconv_stream_filter_ctor':
/home/king/-5.2.13/ext/iconv/iconv.c:2491: undefined reference to `libiconv_open' collect2: ld returned 1 exit statusmake: *** [sapi/cli/] Error 1[root@test php-5.2.13]# vi Makefile
在安裝 PHP 到系统中时要是发生「undefined reference to libiconv_open'」之类的错误信息,那表示在「./configure 」沒抓好一些环境变数值。错误发生点在建立「-o sapi/cli/php」是出错,没給到要 link 的 iconv 函式库参数。 解决方法:编辑Makefile 大约77 行左右的地方: EXTRA_LIBS = ..... -lcrypt 在最后加上 -liconv,例如: EXTRA_LIBS = ..... -lcrypt -liconv 然后重新再次 make 即可。
或者用另一种办法
make ZEND_EXTRA_LIBS='-liconv'
ln -s /usr/local/lib/libiconv.so.2 /usr/lib64/