美文网首页
Ubuntu 编译安装PHP7.3.8

Ubuntu 编译安装PHP7.3.8

作者: realguan | 来源:发表于2019-11-24 11:43 被阅读0次

    一、下载PHP并解压

    PHP官网地址
    复制下载链接

    image 切换到想要下载的目录,执行下载命令并解压
    sudo wget https://www.php.net/distributions/php-7.3.8.tar.gz
    tar -xvf php-7.3.8.tar.gz
    

    二、安装依赖

    sudo apt update
    sudo apt install gcc
    sudo apt install make
    sudo apt install openssl
    sudo apt install libbz2-dev
    sudo apt install libxml2-dev
    sudo apt install libjpeg-dev
    sudo apt install libpng-dev
    sudo apt install libfreetype6-dev
    sudo apt install libzip-dev
    sudo apt install libssl-dev
    

    三、配置

    ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli --with-pdo-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-ftp --with-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-fileinfo --enable-maintainer-zts

    出现以下提示,表明配置OK

    Generating files
    configure: creating ./config.status
    creating main/internal_functions.c
    creating main/internal_functions_cli.c
    +--------------------------------------------------------------------+
    | 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.
     
    config.status: creating php7.spec
    

    四、编译安装

    sudo make
    

    出现以下提示,表明编译OK

    Generating phar.php
    Generating phar.phar
    PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
    pharcommand.inc
    directorytreeiterator.inc
    directorygraphiterator.inc
    invertedregexiterator.inc
    clicommand.inc
    phar.inc
    
    Build complete.
    Don't forget to run 'make test'.
    

    正式安装

    sudo make install
    

    如果没有报错,那就恭喜你安装成功。

    五、配置环境变量

    vi ~/.profile
    

    末尾追加:

    # php环境变量
    PATH=$PATH:/usr/local/php/bin
    export PATH
    

    保存后使之生效

    source ~/.profile
    

    六、配置 php-fpm

    复制php.ini

    sudo cp php.ini-development /usr/local/php/php.ini
    

    复制php-fpm的配置文件

    sudo cp /usr/local/php/etc/php-fpm.conf.default  /usr/local/php/etc/php-fpm.conf
    

    复制www.conf.default配置文件,注意名字和当前用户名一致,我的当前用户名是guan

    sudo cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/guan.conf
    

    打开guan.conf,并更改用户名和用户组,如图所示:


    image

    复制php-fpm服务开启程序,并增加执行权限

    sudo cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
    sudo chmod +x /etc/init.d/php-fpm
    

    七、启动 php-fpm

    sudo /etc/init.d/php-fpm start
    #其他参数还有 stop, restart,status, force-quit, reload, configtest..
    

    查看 php-fpm 状态

    guan@fjsdjdfjk:/usr/local/php/etc/php-fpm.d$ /etc/init.d/php-fpm status
    php-fpm (pid 25341) is running...    
    

    安装配置完成。

    参考链接:https://commandnotfound.cn/php/2/17/PHP-7.3.6-Linux-%E4%B8%8B%E7%9A%84%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85

    相关文章

      网友评论

          本文标题:Ubuntu 编译安装PHP7.3.8

          本文链接:https://www.haomeiwen.com/subject/wzkhwctx.html