您现在的位置是:首页 > 博客日记 > Liunx Liunx

liunx 安装 php7.3.7高版本

2019-07-05 10:48:58 【Liunx】 人已围观

centos就会将我们刚刚下载的PHP7解压到当前目录。ls查看我们会看到一个php7的文件夹。

安装依赖包

  1. yum install -y libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel

打开php下载页
https://www.php.net/downloads.php

最后通过wget下载这个地址里解析出来的文件就可以了。
也可以去github上找 php下载

  1. cd /usr/local/src/
  2. wget https://www.php.net/distributions/php-7.3.7.tar.gz

我们在当前目录输入

  1. tar -zvxf php-7.3.7.tar.gz
  2. cd php-7.3.7

编译php

  1. ./configure --prefix=/usr/local/php7.3.7 \
  2. --with-config-file-path=/usr/local/php7.3.7/etc \
  3. --with-openssl \
  4. --with-curl \
  5. --with-mysql \
  6. --with-pdo-mysql \
  7. --with-mhash \
  8. --with-xmlrpc \
  9. --with-zlib \
  10. --with-gd \
  11. --with-jpeg-dir \
  12. --with-png-dir \
  13. --with-freetype-dir \
  14. --enable-fileinfo \
  15. --enable-bcmath \
  16. --enable-mbstring \
  17. --enable-sockets \
  18. --enable-xml \
  19. --enable-fpm \
  20. --enable-force-cgi-redirect \
  21. --enable-zip \
  22. --enable-soap \
  23. --enable-ftp \
  24. --without-pear

enable-bcmath php精度计算扩展

enable-fileinfo 文件操作

安装

  1. make && make install

最后显示安装成功

  1. Build complete.
  2. Don't forget to run 'make test'.
  3. Installing shared extensions: /usr/local/php7.3.7/lib/php/extensions/no-debug-non-zts-20180731/
  4. Installing PHP CLI binary: /usr/local/php7.3.7/bin/
  5. Installing PHP CLI man page: /usr/local/php7.3.7/php/man/man1/
  6. Installing PHP FPM binary: /usr/local/php7.3.7/sbin/
  7. Installing PHP FPM config: /usr/local/php7.3.7/etc/
  8. Installing PHP FPM man page: /usr/local/php7.3.7/php/man/man8/
  9. Installing PHP FPM status page: /usr/local/php7.3.7/php/php/fpm/
  10. Installing phpdbg binary: /usr/local/php7.3.7/bin/
  11. Installing phpdbg man page: /usr/local/php7.3.7/php/man/man1/
  12. Installing PHP CGI binary: /usr/local/php7.3.7/bin/
  13. Installing PHP CGI man page: /usr/local/php7.3.7/php/man/man1/
  14. Installing build environment: /usr/local/php7.3.7/lib/php/build/
  15. Installing header files: /usr/local/php7.3.7/include/php/
  16. Installing helper programs: /usr/local/php7.3.7/bin/
  17. program: phpize
  18. program: php-config
  19. Installing man pages: /usr/local/php7.3.7/php/man/man1/
  20. page: phpize.1
  21. page: php-config.1
  22. /usr/local/src/php-7.3.7/build/shtool install -c ext/phar/phar.phar /usr/local/php7.3.7/bin
  23. ln -s -f phar.phar /usr/local/php7.3.7/bin/phar
  24. Installing PDO headers: /usr/local/php7.3.7/include/php/ext/pdo/

修改配置

复制php-fpm.conf 和php.ini配置文件

  1. cp /usr/local/src/php-7.3.7/php.ini-production /usr/local/php/etc/php.ini
  2. cp /usr/local/php7.3.7/etc/php-fpm.conf.default /usr/local/php7.3.7/etc/php-fpm.conf

1.然后 php.ini 修改

  1. extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"

2.配置php-fpm.conf

  1. vim /usr/local/php/etc/php-fpm.conf

php-fpm.pid 目录必须指向:/usr/local/php/var/run/php-fpm.pid

如果服务器上安装多个php版本需要修改端口

  1. cp /usr/local/php7.3.7/etc/php-fpm.d/www.conf.default /usr/local/php7.3.7/etc/php-fpm.d/www.conf

修改 www.conf 文件中

  1. listen = 127.0.0.1:9000

改为9001

3.配置环境变量

  1. vi /etc/profile

在末尾追加

  1. PATH=$PATH:/usr/local/php7/bin
  2. export PATH

执行命令使得改动立即生效

  1. source /etc/profile

php添加到liunx服务

1..拷贝php-fpm脚本至/etc/init.d目录

  1. cp /usr/local/src/php-7.3.7/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm7.3.7

3.设置权限并启动php-fpm:

  1. chmod +x /etc/init.d/php-fpm7.3.7
  2. /etc/init.d/php-fpm7.3.7 start
  3. chkconfig --add php-fpm7.3.7

最后,给出php-fpm以服务的方式启动、停止和重启:

  1. service php-fpm7.3.7 start
  2. service php-fpm7.3.7 stop
  3. service php-fpm7.3.7 reload

PHP配置Configure报错:Please reinstall the libzip distribution
发生情景:
php执行配置命令configure时,报如下错误:

  1. checking for libzip... not found
  2. configure: error: Please reinstall the libzip distribution

错误含义:
没有找到libzip
请重新安装libzip的dev包。
尝试解决:
(1)移除旧的libzip:

  1. yum remove libzip

(2)安装新版本:

  1. curl -O https://libzip.org/download/libzip-1.5.1.tar.gz
  2. tar -zxvf libzip-1.5.1.tar.gz
  3. cd libzip-1.5.1
  4. mkdir build
  5. cd build
  6. cmake ..
  7. make && make install

注意:如果提示cmake版本过低,需新版本,则需要重新安装cmake。

liunx 安装cmake或升级cmake



关注TinyMeng博客,更多精彩分享,敬请期待!
 

很赞哦! ()