PHP安装

下载 PHP 源码包

1
2
wget http://cn2.php.net/get/php-5.6.25.tar.gz/from/this/mirror -O php-5.6.25.tar.gz
tar zxf php-5.6.25.tar.gz

添加 epel 源

1
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

安装依赖

1
yum install gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel sqlite-devel -y

创建 www 用户

1
2
groupadd www
useradd -g www -s /sbin/nologin -M www

编译

1
2
cd php-5.6.25/
./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-fpm-user=www --with-fpm-group=www --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 --with-readline

安装

1
make -j4 && make install

拷贝配置文件

1
2
3
4
cp php.ini-development /usr/local/php/etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm

启动 php-fpm

1
service php-fpm start

添加环境变量

1
2
echo "PATH=$PATH:/usr/local/php/bin" >> /etc/profile
source /etc/profile

检查

1
2
3
4
php -v
PHP 5.6.25 (cli) (built: Aug 24 2016 10:44:16)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
坚持原创技术分享,您的支持将鼓励我继续创作!