• linux centos编译安装php7.3


    php7.2的编译安装参考:https://www.cnblogs.com/rxbook/p/9106513.html

    已有的之前编译的旧版本php:

    mv /usr/local/php /usr/local/php72

    下载,解压,编译:

    wget https://www.php.net/distributions/php-7.3.12.tar.gz
    tar -zxvf php-7.3.12.tar.gz
    cd php-7.3.12
    ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php --enable-mbstring --with-openssl --enable-ftp --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pear --enable-sockets --with-freetype-dir=/usr --with-zlib --with-libxml-dir=/usr --with-xmlrpc --enable-zip --enable-fpm --enable-xml --enable-sockets --with-gd --with-zlib --with-iconv --enable-zip --with-freetype-dir=/usr/lib/ --enable-soap --enable-pcntl --enable-cli --with-curl

    --报错:php-7.3.4 configure: error: Please reinstall the libzip distribution:

    # wget https://libzip.org/download/libzip-1.5.2.tar.gz
    tar -zxf libzip-1.5.2.tar.gz
    cd libzip-1.5.2
    mkdir build
    cd build 
    cmake ..
    make -j4
    make install

    ---- 此过程报错:CMake 3.0.2 or higher is required. You are running version,参考:https://www.cnblogs.com/rxbook/p/11911375.html

    然后再次编译,通过:

    说明:由于PHP7.2不再支持mysql,而是用mysqli取代。因此会出现上面图中所示的warning。不过没关系,如果需要安装php的mysql扩展,文章后面会有说明。

    编译完成之后,执行安装命令:

    $ make && make install

    说明:如果是在阿里云购买的内存较小的云服务器,安装到这里可能会出现如下错误:

    virtual memory exhausted: Cannot allocate memory
    make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1

    解决方案:https://www.cnblogs.com/rxbook/p/8005944.html

    然后,重新 make && make install

    接下来,安装过程大约需要20分钟时间,安装成功的界面如下:

    【配置PHP】

    在之前编译的源码包中,找到 php.ini-production,复制到/usr/local/php下,并改名为php.ini:

    $ cp php.ini-production /usr/local/php/php.ini

    [可选项] 设置让PHP错误信息打印在页面上 

    $ vim /usr/local/php/php.ini 

    1
    display_errors = On

    复制启动脚本:

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

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

    修改php-fpm配置文件:

    $ cd /usr/local/php/etc

    $ cp php-fpm.conf.default php-fpm.conf

    $ vim php-fpm.conf

    1
    ① 去掉 pid = run/php-fpm.pid 前面的分号

    $ cd php-fpm.d

    $ cp www.conf.default www.conf

    $ vim www.conf

    1
    ② 修改user和group的用户为当前用户(也可以不改,默认会添加nobody这个用户和用户组)

     

    【启动PHP】

    $ /etc/init.d/php-fpm start        #php-fpm启动命令

    $ /etc/init.d/php-fpm stop         #php-fpm停止命令

    $ /etc/init.d/php-fpm restart        #php-fpm重启命令

    $ ps -ef | grep php 或者 ps -A | grep -i php  #查看是否已经成功启动PHP

    【安装PHP测mongodb扩展和redis扩展】

    cd /usr/local/php/bin/
    ./pecl install mongodb
    ./pecl install redis
    ./pecl install memcached
    ./pecl install xxx...

    【PHP7.2的MySQL扩展】

    由于PHP7.2不再支持mysql,而是用mysqli取代,如果需要安装php的mysql扩展,请看这里。

    下载安装包:链接:https://pan.baidu.com/s/1bqDutYZ  密码:ae40

    解压,并进入目录:

    $ tar -zxvf mysql-24d32a0.tar.gz

    $ cd mysql-24d32a0

    $ /usr/local/php/bin/phpize  #使用phpize初始化

    #编译mysql扩展,使用mysql native driver 作为mysql链接库

    $ ./configure --with-php-config=/usr/local/php/bin/php-config --with-mysql=mysqlnd

    接下来,安装:

    $ make && make install

    最后,编辑php.ini文件,在最后面加入 extension=mysql.so 即可。

    $ vim /usr/local/php/php.ini

    重启PHP,查看phpinfo()

    $ /etc/init.d/php-fpm restart 

  • 相关阅读:
    Verilog 浮点数运算模块
    【MATLAB】设定坐标的轴的范围
    【MATLAB】画平行于坐标轴的曲线
    【Quartus警告】created implicit net for XXX.
    多普勒雷达探测原理
    高斯分布和均匀分布之间的映射关系
    反射设置当前窗体所有控件的Text
    IAR6.1的工程迁移到IAR6.5不能用的解决方法
    C语言实现通用链表初步(二)
    C语言实现通用链表初步(一)
  • 原文地址:https://www.cnblogs.com/rxbook/p/11911438.html
Copyright © 2020-2023  润新知