安装 libiconv
- 下载 libiconv 安装包
mkdir -p /usr/local/src/download/libiconv
cd /usr/local/src/download/libiconv
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
- 解压 libiconv
tar zxvf libiconv-1.14.tar.gz
- 修改 srclib/stdio.h
cd libiconv-1.14
vi srclib/stdio.in.h +698
# 注释该行内容
// _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
- 安装依赖
yum -y install gcc gcc-c++
- 编译 libiconv
./configure --prefix=/usr/local/libiconv
- 安装 libiconv
make
make install
安装 PHP
- 下载 PHP 安装包
mkdir -p /usr/local/src/download/php7
cd /usr/local/src/download/php7
wget http://cn2.php.net/distributions/php-7.1.7.tar.gz
- 解压 PHP
tar zxvf php-7.1.7.tar.gz
- 安装依赖
yum -y install libxml2 libxml2-devel \
gd gd-devel \
freetype freetype-devel \
libjpeg libjpeg-devel \
libpng libpng-devel \
openssl openssl-devel \
curl curl-devel \
zlib zlib-devel \
libiconv libiconv-devel \
libxslt libxslt-devel \
autoconf
- 创建 PHP-FPM 运行用户及组
groupadd nginx
useradd nginx -s /sbin/nologin -g nginx -M
- 编译 PHP
cd php-7.1.7
./configure --prefix=/usr/local/php7 \
--with-xmlrpc \
--with-openssl \
--with-zlib \
--with-curl \
--with-xsl \
--with-gd \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-libxml-dir \
--with-iconv=/usr/local/libiconv \
--enable-mysqlnd \
--enable-short-tags \
--enable-ftp \
--enable-sockets \
--enable-soap \
--enable-mbstring \
--enable-static \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx
- 安装 PHP
make
make install
- PHP 配置文件
cp php.ini-development /usr/local/php7/lib/php.ini
- PHP-FPM 配置文件
cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
- PHP 扩展库
mv ext /usr/local/php7/
- PHP-FPM 开机自启动
vi /etc/rc.local
# php auto start
/usr/local/php7/sbin/php-fpm
- PHP 环境变量
echo "export PATH=/usr/local/php7/bin:$PATH" >> /etc/profile
source /etc/profile
- 启动 PHP-FPM
/usr/local/php7/sbin/php-fpm