1. 安装依赖包
yum install -y libxml2 openssl libcurl libjpeg libpng freetype libmcrypt
yum -y install libjpeg-devel
yum -y install curl-devel
yum install libpng
yum install libpng-devel
yum install openssl openssl-devel
yum -y install curl-devel
yum install libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 -y
yum install libjpeg-devel
yum install bzip2-devel.x86_64 -y
yum install libXpm-devel
yum install gmp-devel
yum install -y icu libicu libicu-devel
yum install postgresql-devel
yum install libxslt-devel
yum -y install ncurses ncurses-devel
yum -y install libxml2 libxml2-devel
yum -y install gd
yum -y install gd-devel
yum -y install flex
yum -y install zlib-devel
yum -y install freetype-devel
yum -y install libssl-dev
yum -y install gmp-devel
yum -y install unixODBC-devel
yum -y install pspell-devel
yum -y install net-snmp net-snmp-devel
yum -y install openldap-devel openldap-servers openldap-clients
yum -y install zlib-devel
yum install libc-client-devel
yum install epel-release
2. php官网下载压缩包
win7本地环境下载, 通过ftp远程连接服务器
把压缩包放到centos7服务器的/home/work/ 目录下
3. 创建用户和用户组
groupadd www-data
useradd -g www-data www-data
4. 解压、配置、编译、安装
cd /home/work目录下 ls 查看文件
tar -zxvf php-7.2.16.tar.gz , ls 查看php-7.2.16 目录
cd php-7.2.16目录下
./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=www --with-fpm-group=www
注释 : --enable-fpm 启动php-fpm插件 (必须)(nginx和php无法配合,必须要php-fpm插件配合二者才可以正常解析, 区别:Apache与php就不需要这个插件)
make && make install
5、 设置用户变量 (类似:设置全局环境变量)
ln -s /usr/local/php/bin/php /usr/bin/php
6、 配置php-fpm
启动后提示没有配置文件,php fpm初始化失败,需要添加配置文件,把cp php-fpm.conf.default重命名php-fpm.conf和www.conf.default重命名www.conf
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
7. 开启 php-fpm
/usr/local/php/sbin/php-fpm
8. 配置nginx.conf
目录: /usr/local/nginx/conf/nginx.conf
/usr/local/nginx/sbin/nginx -t 测试配置文件正确性
/usr/local/nginx/sbin/nginx -s reload 重启 nginx
9. 安装好后需要在php源码
把目录把php.ini-production和php.ini-development复制到php的etc目录中,并把php.ini-production重命名为php.ini
cp /home/work/php-7.2.16/php.ini-development /usr/local/php/etc/php.ini