千家信息网

Centos7.2 编译安装PHP7.0.2的步骤

发表于:2026-11-02 作者:千家信息网编辑
千家信息网最后更新 2026年11月02日,环境系统:Centos7.2服务:Nginx1:下载PHP7.0.2的安装包解压,编译,安装: $ cd /usr/src/ $ wget http://cn2.php.net/distribut
千家信息网最后更新 2026年11月02日Centos7.2 编译安装PHP7.0.2的步骤

环境

  1. 系统:Centos7.2
  2. 服务:Nginx

1:下载PHP7.0.2的安装包解压,编译,安装:

  $ cd /usr/src/  $ wget http://cn2.php.net/distributions/php-7.0.2.tar.gz  $ tar -xzxvf php-7.0.2.tar.gz  $ cd php-7.0.2

1.1编译前检查

请检查是否安装了gcc ,没有的话执行yum install gcc

检查是否安装了libxml2 ,没有的话执行yum install libxml2

检查是否安装了libxml2-devel,没有的话执行yum install libxml2-devel

注:因为改为用nginx了,所以编译参数中的--with-apxs2=/usr/bin/apxs去掉了,如果要配置apache用,安装PHP前,请先安装apache。*

2:编译参数配置

复制代码 代码如下:
'./configure' '--prefix=/usr/local/php' '--with-pdo-pgsql' '--with-zlib-dir' '--with-freetype-dir' '--enable-mbstring' '--with-libxml-dir=/usr' '--enable-soap' '--enable-calendar' '--with-curl' '--with-mcrypt' '--with-gd' '--with-pgsql' '--disable-rpath' '--enable-inline-optimization' '--with-bz2' '--with-zlib' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-pcntl' '--enable-mbregex' '--enable-exif' '--enable-bcmath' '--with-mhash' '--enable-zip' '--with-pcre-regex' '--with-pdo-mysql' '--with-mysqli' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--with-openssl' '--with-fpm-user=www-data' '--with-fpm-group=www-data' '--with-libdir=/lib/x86_64-linux-gnu/' '--enable-ftp' '--with-gettext' '--with-xmlrpc' '--with-xsl' '--enable-opcache' '--enable-fpm' '--with-iconv' '--with-xpm-dir=/usr'

3:错误集合

报错 Cannot find OpenSSL's  执行 yum install openssl openssl-devel报错 Please reinstall the libcurl distribution 执行 yum -y install curl-devel错误 jpeglib.h not found 执行 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错误:checking for BZip2 in default path... not found configure: error: Please reinstall the BZip2 distribution 这是bzip2软件包没有安装 执行 yum install bzip2-devel.x86_64 -y错误:configure: error: xpm.h not found. 执行 yum install libXpm-devel错误: Unable to locate gmp.h 执行 yum install gmp-devel错误:Unable to detect ICU prefix or /usr//bin/icu-config failed. Please verify ICU install prefix and make sure icu-config works 执行 yum install -y icu libicu libicu-devel错误:mcrypt.h not found. Please reinstall libmcrypt. 执行 yum install php-mcrypt libmcrypt libmcrypt-devel错误: configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path 执行 yum install postgresql-devel错误: configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution 执行 yum install libxslt-devel

4:编译

make clean && make && make install

5:PHP配置

5.1安装完成后,我们要把源码包中的配置文件复制到PHP安装目录下,源码包中有两个配置 php.ini-development php.ini-production ,看名字就知道,一个是开发环境,一个是生产环境,我们这里就复制开发环境的

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

5.2另外还需要设置环境变量 :修改/etc/profile文件使其永久性生效,并对所有系统用户生效,在文件末尾加上如下两行代码

PATH=$PATH:/usr/local/php/binexport PATH

5.3 然后执行生效命令

source /etc/profile

5.4查看PHP版本信息

php -v

6:配置PHP-fpm

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.confcp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.confcp /usr/src/php-7.0.2/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpmchmod +x /etc/init.d/php-fpm

6.1 启动php-fpm:

/etc/init.d/php-fpm start

6.2 如果出现错误:ERROR: [pool www] cannot get uid for user 'www-data'

则新建www-data 用户组:

groupadd www-datauseradd -g www-data www-data

6.3 重启php-fpm

/etc/init.d/php-fpm restart

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

错误 配置 编译 环境 检查 代码 文件 参数 源码 用户 系统 开发 两个 信息 内容 变量 名字 命令 就是 末尾 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 深圳恒合互联网络科技有限公司 互联网科技有限公司图片 互联网科技卖菜 深圳科技互联网 易通互联网络科技有限公司 多迪互联网科技有限公司 中国最先进互联网科技公司 温州喔噻互联网科技有限公司 互联网教育科技公司vipkid 互联网科技实习生岗位职责 崇明区互联网教育科技售后服务 乌苏新华互联网科技做什么的 燊美集互联网科技有限公司 玉溪新华互联网科技好不好 深圳互联网科技的发展 广州千川互联网科技有限公司 皮皮虾互联网科技有限公司 工业互联网科技创业 万物互联网智能科技 平安好医生打造互联网科技医疗 广州大一互联网络科技有限公司 互联网科技卖菜 艾特科技互联网 互联网前沿科技 互联网科技汛 洛阳共同富裕互联网科技有限公司 沐思想互联网科技有限公司 互联网科技融合创新 中国互联网公司的科技投入 科技互联网专业工作会议发言稿
0