Centos7.2 编译安装PHP7.0.2的步骤
作者:hyperbolaa 时间:2023-10-08 12:51:29
环境
系统:Centos7.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 <evp.h>
执行 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/bin
export 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.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
cp /usr/src/php-7.0.2/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +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-data
useradd -g www-data www-data
6.3 重启php-fpm
/etc/init.d/php-fpm restart
来源:http://www.jianshu.com/p/812b28819715
标签:Centos,编译,安装,PHP
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
oracle 重置序列从指定数字开始的方法详解
2023-07-05 02:40:04
Python使用psutil对系统数据进行采集监控
2023-03-13 07:21:19
![](https://img.aspxhome.com/file/2023/2/109842_0s.png)
HTML在线编辑器任意设置字号大小
2007-08-29 19:55:00
Python实现提取Excel指定关键词的行数据
2022-09-01 10:15:59
![](https://img.aspxhome.com/file/2023/4/67834_0s.jpg)
微信小程序实现分页查询详解
2024-04-16 10:38:58
![](https://img.aspxhome.com/file/2023/0/136570_0s.png)
利用Python编写一个记忆翻牌游戏
2022-09-24 02:20:54
vue使用localStorage保存登录信息 适用于移动端、PC端
2024-04-30 08:46:25
matplotlib quiver箭图绘制案例
2023-07-13 10:04:11
![](https://img.aspxhome.com/file/2023/3/76893_0s.jpg)
Springboot获取前端反馈信息并存入数据库的实现代码
2024-01-15 09:06:15
PHP简单实现冒泡排序的方法
2024-06-07 15:45:49
python 中文编码乱码问题的解决
2021-03-06 16:43:58
![](https://img.aspxhome.com/file/2023/5/78645_0s.png)
python实现WebSocket服务端过程解析
2022-09-14 10:45:19
![](https://img.aspxhome.com/file/2023/5/75855_0s.png)
Django学习笔记之Class-Based-View
2023-09-07 15:37:25
python字符串替换的2种方法
2022-12-27 20:59:24
Python使用pyautogui模块实现自动化鼠标和键盘操作示例
2022-10-27 16:02:25
详解Python开发语言中的基本数据类型
2022-12-11 20:13:35
![](https://img.aspxhome.com/file/2023/6/117326_0s.png)
Python实现批量绘制遥感影像数据的直方图
2023-09-04 10:35:53
nlp自然语言处理学习CBOW模型类实现示例解析
2023-08-08 00:26:03
![](https://img.aspxhome.com/file/2023/8/76178_0s.jpg)
python爬取豆瓣评论制作词云代码
2023-03-14 04:31:40
![](https://img.aspxhome.com/file/2023/6/68286_0s.jpg)
Python实现提取给定网页内的所有链接
2022-03-29 19:01:11
![](https://img.aspxhome.com/file/2023/4/80814_0s.webp)