您所在的位置:首页 - PHP - 正文PHP

Linux源码编译安装php7.3.3

萧何-Vincent 萧何-Vincent 2021-11-11 【PHP】 1165人已围观

先删除之前所有的php 文件  yum remove php


在linux下,你把文件夹删干净就等同于卸载了,毕竟linux系统是一个连内存都当做文件和文件夹管理的系统

rm -rf /usr/local/php /bin/php /usr/local/sbin/php-fpm /usr/local/bin/php /usr/local/bin/pear /usr/local/bin/peardev /usr/local/bin/pecl /usr/local/bin/phar /usr/local/bin/phar.phar /usr/local/bin/php-cgi /usr/local/bin/php-config /usr/local/bin/phpdbg /usr/local/bin/phpize



一、安装所需环境

yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel libzip-devel pcre-devel


二、下载及安装nginx

1.下载php     

wget http://cn2.php.net/distributions/php-7.3.3.tar.gz


 2.解压php

tar -xzf php-7.3.3.tar.gz


3.进入php目录

cd php-7.3.3



3.编译php(官方已经不支持zib,一般不建议再加zib)

./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --with-config-file-scan-dir=/usr/local/php7/etc/php.d --with-mcrypt=/usr/include --enable-mysqlnd --with-mysqli --with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-gd --with-iconv --with-zlib --enable-xml --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache


去掉zib 扩展版编译

./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --with-config-file-scan-dir=/usr/local/php7/etc/php.d --with-mcrypt=/usr/include --enable-mysqlnd --with-mysqli --with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-gd --with-iconv --enable-xml --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache


4.编译参数解析

可以使用./configure --help查看

--prefix:配置安装的路径,可以把所有的资源文件放在这个路径中,不会杂乱

--with-config-file-path:指定PHP扩展的ini配置文件目录,不是文件

--with-fpm-user:fpm运行的用户,默认为nobody

--with-fpm-group:fpm运行的组,默认为nobody

--with-curl :打开curl浏览工具的支持

--with-freetype-dir :打开对freetype字体库的支持

--with-gd :打开gd库的支持

--with-gettext :打开gnu 的gettext 支持,编码库用到

--with-iconv-dir:用于 PHP 编译时指定 iconv 在系统里的路径,否则会扫描默认路径

--with-kerberos:Include kerberos支持

--with-libdir:目标代码库

--with-libxml-dir:打开libxml2库的支持

--with-mysqli:mysqli扩展技术不仅可以调用MySQL的存储过程、处理MySQL事务,而且还可以使访问数据库工作变得更加稳定

--with-openssl:openssl的支持,加密传输https时用到的

--with-pcre-regex:引用pear兼容的正则表达式库

--with-pdo-mysql:加入pdo支持,默认为自带驱动mysqlnd

--with-mysql:对mysql的支持

--with-pdo-sqlite:PDO:sqlite 3支持

--with-pear:打开gnu 的gettext 支持,编码库用到

--with-png-dir:打开对png图片的支持

--with-jpeg-dir:打开对jpeg图片的支持

--with-xmlrpc:打开xml-rpc的c语言

--with-xsl:打开XSLT 文件支持,扩展了libXML2库 ,需要libxslt软件

--with-zlib:打开zlib库的支持

--with-bz2:打开对bz2文件的支持 

--with-mhash:mhash算法扩展

--enable-fpm:开启fpm模式(nginx等服务用的)

--enable-bcmath:启用BCMath扩展

--enable-libxml:启用libxml PHP 扩展

--enable-inline-optimization:优化线程

--enable-mbregex:禁用 [具有多字节字符支持的正则表达式函数]

--enable-mbstring:启用多字节字符串的支持

--enable-opcache:启用发送操作缓存支持

--enable-pcntl:启用pcntl支持(仅限CLI/CGI)

--enable-shmop:启用shmop支持

--enable-soap:启用SOAP支持

--enable-sockets:启用套接字支持

--enable-sysvsem:启用系统V信号量支持

--enable-sysvshm:启用System V共享内存支持

--enable-xml:启用xml支持

---------------------start---------------------------



 假如编译完成之后报错:


  “checking for libzip... configure: error: system libzip must be upgraded to v”


  执行一下,没有报错则忽略。


wget https://nih.at/libzip/libzip-1.2.0.tar.gz


tar -xzf libzip-1.2.0.tar.gz


./configure


make && make install


----------------------------end-------------------------


出现以下则表示编译成功


+--------------------------------------------------------------------+

| License: |

| This software is subject to the PHP License, available in this |

| distribution in the file LICENSE. By continuing this installation |

| process, you are bound by the terms of this license agreement. |

| If you do not agree with the terms of this license, you must abort |

| the installation process at this point. |

+--------------------------------------------------------------------+


Thank you for using PHP.


然后执行:


make test(如果出现什么问题请谷歌或百度,或者往下看看能解决不)


--------------start----------------


如果这里报错:


/usr/local/include/zip.h:59:21: fatal error: zipconf.h: No such file or directory


则执行一下命令,没有则忽略。


find / -name zipconf.h


cp /你zipconf.h所在的目录  //usr/local/include/zipconf.h


然后重新 configure 成功之后在make test,没问题则继续执行后面的命令。


---------------end--------------------


make && make install -j2


三、配置php

#将PHP目录中的php-fpm配置文件进行修改 

cd /mnt/php-7.3.3 进入安装文件目录
cp php.ini-production /usr/local/php7/etc/php.ini

cd /usr/local/php7/etc 切换目录
cp php-fpm.conf.default php-fpm.conf 
 
cp php-fpm.d/www.conf.default php-fpm.d/www.conf


1.测试下是否成功

/usr/local/php7/sbin/php-fpm -t



2.配置fpm ,开启自启动


cd /mnt/php-7.3.3/sapi/fpm

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

chmod +x /etc/init.d/php-fpm

chkconfig --add php-fpm

chkconfig php-fpm on


3.#启动 php-fpm 

/etc/init.d/php-fpm  start
systemctl start php-fpm


启动 php-fpm 时报错:

Starting php-fpm [23-May-2018 12:20:45] ERROR: [pool www] cannot get uid for user 'nginx'


意思是没有nginx用户,添加就好了


# useradd nginx



Tags: PHP

文章评论 (暂无评论,1165人围观)

我的名片

网名:Vincent

职业:IT

现居:SZ

Email:53126692@qq.com

站长寄语:技术分享,支持原创!

站点信息

  • 文章总数:65
  • 页面总数:1
  • 分类总数:5
  • 标签总数:12
  • 评论总数:24
  • 浏览总数:82970
取消
微信二维码
支付宝二维码

目录[+]