博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php编译安装
阅读量:6953 次
发布时间:2019-06-27

本文共 4446 字,大约阅读时间需要 14 分钟。

hot3.png

4.27 php编译安装

官网:www.php.net

下载php

# cd /usr/local/src# wget http://cn2.php.net/distributions/php-7.3.0.tar.bz2

解压文件,如果没有安装bzip2,则不能解压tar.bz2包,需要先安装bzip2包

# yum install -y bzip2  #安装bzip2包# tar jxvf php-7.3.0.tar.bz2   #解压

编辑安装一个软件包的步骤大致分为三步

1)第一步:./configure 编译参数 2)第二部:make 编译 3)第三部:install 安装

编译参数:

# ./configure --prefix=/usr/local/php-fpm  --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-openssl --with-curl --enable-sockets

编译报错1如下:

checking for cc... nochecking for gcc... noconfigure: error: in `

原因是没有安装gcc编译工具,先安装gcc包

# yum install -y gcc

安装完成后重新编译参数,报错2如下

configure: error: libxml2 not found. Please check your libxml2 installation.

原因是缺少开发包libxml2,需要装libxml2开发包

# yum list | grep libxml2  #查找到包名为libxml2-devel.x86_64# yum install -y libxml2-devel

安装完成后继续重新再次执行编译参数,出现第3个报错,内容如下:

configure: error: Cannot find OpenSSL's 
# yum list | grep -i OpenSSL #同样的方式查找安装包,i选项忽略大小写# yum install -y openssl-devel

继续编译参数报错4如下:

checking for cURL 7.15.5 or greater... configure: error: cURL version 7.15.5 or later is required to compile php with cURL support

安装包: # yum list | grep -i cURL # yum install -y libcurl-devel 继续编译,报错5

configure: error: jpeglib.h not found.

安装libjpeg包:

# yum list | grep -i jpeg# yum install -y libjpeg-turbo-devel

继续编译,报错6

configure: error: png.h not found.

安装软件包

# yum list | grep -i png# yum install -y libpng-devel

继续编译,报错7:

configure: error: freetype-config not found.

安装包:

# yum list | grep freetype# yum install -y freetype-devel

继续编译,报错8

configure: error: wrong mysql library version or lib not found. Check config.log for more information.

先下载mysql 5.6,64位的二进制包到/usr/local/src下

# wget http://mirrors.163.com/mysql/Downloads/MySQL-5.6/mysql-5.6.42-linux-glibc2.12-x86_64.tar.gz# tar zxvf http://mirrors.163.com/mysql/Downloads/MySQL-5.6/mysql-5.6.42-linux-glibc2.12-x86_64.tar.gz# mv mysql-5.6.42-linux-glibc2.12-x86_64 /usr/local/mysql5.6 #移动解压文件

修改编译参数,将mysql路径改为mysql5.6后,继续重新编译:

# ./configure --prefix=/usr/local/php-fpm  --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql5.6 --with-mysqli=/usr/local/mysql5.6/bin/mysql_config --with-pdo-mysql=/usr/local/mysql5.6 --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-openssl --with-curl --enable-sockets

将源码包变成二进制包

# make# echo $? #查看是否执行成功# make install# echo $? #查看是否执行成功

拷贝配置文件

# cd /usr/local/php-fpm/etc/# cp php-fpm.conf.default php-fpm.conf  #复制拷贝配置文件改名一下# cd /usr/local/src/php-7.3.0# diff php.ini-development php.ini-production   #查看并对比两个文件的差异,;号表示注释

php.ini-development是开发测试用的,php.ini-production是生产用的,我们测试拷贝php.ini-development即可

# cp php.ini-development /usr/local/php-fpm/etc/php.ini

拷贝完配置文件后,配置启动脚本,将启动脚本拷贝到init.d目录下

# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

将php-fpm添加到服务列表中

# chkconfig --add php-fpm   #添加到服务列表# chmod 755 /etc/init.d/php-fpm  #设置执行权限# chkconfig --list  #查看服务列表# chkconfig php-fpm on #设置开启启动# service php-fpm start #开启服务

启动服务时报错如下

Starting php-fpm [25-Jan-2019 20:40:27] WARNING: Nothing matches the include pattern '/usr/local/php-fpm/etc/php-fpm.d/*.conf' from /usr/local/php-fpm/etc/php-fpm.conf at line 143.[25-Jan-2019 20:40:27] ERROR: No pool defined. at least one pool section must be specified in config file[25-Jan-2019 20:40:27] ERROR: failed to post process the configuration[25-Jan-2019 20:40:27] ERROR: FPM initialization failedfailed

查看报错所在目录

# ll /usr/local/php-fpm/etc/php-fpm.d/  #查看所在目录发现没有.conf配置文件# cp www.conf.default www.conf  #拷贝配置文件service php-fpm start  #再次启动服务

再次启动报错如下,原因是因为没有增加相应的用户:

Starting php-fpm [25-Jan-2019 20:48:11] ERROR: [pool www] cannot get uid for user 'php-fpm'[25-Jan-2019 20:48:11] ERROR: FPM initialization failed

增加用户并启动

# useradd php-fpm #添加用户# service php-fpm start #启动服务Starting php-fpm  done

至此php编译安装完成。

转载于:https://my.oschina.net/u/3954059/blog/3006107

你可能感兴趣的文章
定制自己的数据类型
查看>>
CSS样式表初始化杂谈
查看>>
[转]winform控件webbrowser和js脚本互调
查看>>
Selenium WebDriver控制操作(Python)
查看>>
最短路 - spfa
查看>>
java 一些容易忽视的小点-类和对象
查看>>
weblogic安装升级配置
查看>>
在Spring MVC中使用FileUpload功能
查看>>
[转] Windows Server 2012 Beta (Hyper-V 3.0) VM Replica與Live Migration Winout Shared Storage
查看>>
枚举 enum
查看>>
JavaScript 学习笔记
查看>>
C# 文件读写系列三
查看>>
让Android的输入框与文本框带滚动条ScrollView
查看>>
基于jQuery或Zepto实现实时监控用户浏览信息
查看>>
【高德地图API】如何打造十月妈咪品牌地图?
查看>>
laravel Ajax请求 X-CSRF验证问题
查看>>
deb包的安装及dpkg命令小结
查看>>
网站程序 Bin目录下 dll无法删除,删除并编译后自动重新引用的解决方法
查看>>
git配置
查看>>
centos7下mongoDB安装和配置
查看>>