• 在CentOS 7-8上安装PHP 8.0


    原文:https://www.iplayio.cn/post/739811

    在CentOS 8上安装PHP 8.0

    我们将使用REMI存储库在CentOS 8 / CentOS 7 Linux系统上安装PHP 8。安装有两种选择

    • 安装PHP 8.0作为主要的PHP版本
    • 与其他PHP版本一起安装PHP 8.0

    如果您希望安装并将PHP 8.0作为默认版本,请使用以下命令。这意味着用PHP 8.0提供的软件包替换发行版中的基本软件包。

    CentOS 8:

    sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
    sudo dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
    sudo dnf -y install yum-utils
    sudo dnf module reset php
    sudo dnf module install php:remi-8.0 -y
    sudo dnf install php -y
    yum install php-fpm
    systemctl enable php-fpm
    yum install php-mysqlnd
    yum install php-mbstring


    安装compose:
    php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
    php composer-setup.php

    php -r "unlink('composer-setup.php');"

    上述 3 条命令的作用依次是:

    1. 下载安装脚本 - composer-setup.php - 到当前目录。
    2. 执行安装过程。
    3. 删除安装脚本
    全局安装:sudo mv composer.phar /usr/local/bin/composer


    https://www.phpcomposer.com/



     

    CentOS 7:

    sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    sudo yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
    sudo yum -y install yum-utils
    sudo yum-config-manager --disable 'remi-php*'
    sudo yum-config-manager --enable remi-php80
    sudo yum -y install php php-{cli,fpm,mysqlnd,zip,devel,gd,mbstring,curl,xml,pear,bcmath,json}

    要安装任何其他PHP软件包,请使用命令语法:

    sudo yum install php-xxx

    检查PHP版本:

    $ php --version
    PHP 8.0.0RC4 (cli) (built: Nov 10 2020 10:57:27) ( NTS gcc x86_64 )
    Copyright (c) The PHP Group
    Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies

    在CentOS 8上安装PHP 8.0:

    sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
    sudo dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
    sudo dnf -y install yum-utils
    sudo dnf module reset php
    sudo dnf install php80

    通过按键盘上的y键接受安装:

    Dependencies resolved.
    ==================================================================================================================================================================
     Package                                           Architecture                Version                                       Repository                      Size
    ==================================================================================================================================================================
    Installing:
     php80                                             x86_64                      1.0-3.el8.remi                                remi-safe                      7.0 k
    Installing dependencies:
     environment-modules                               x86_64                      4.1.4-4.el8                                   BaseOS                         254 k
     php80-php-cli                                     x86_64                      8.0.0~rc4-37.el8.remi                         remi-safe                      3.2 M
     php80-php-common                                  x86_64                      8.0.0~rc4-37.el8.remi                         remi-safe                      716 k
     php80-runtime                                     x86_64                      1.0-3.el8.remi                                remi-safe                      1.1 M
     policycoreutils-python-utils                      noarch                      2.9-9.el8                                     BaseOS                         251 k
     scl-utils                                         x86_64                      1:2.0.2-12.el8                                AppStream                       47 k
     tcl                                               x86_64                      1:8.6.8-2.el8                                 BaseOS                         1.1 M
    
    Transaction Summary
    ==================================================================================================================================================================
    Install  8 Packages
    
    Total download size: 6.7 M
    Installed size: 25 M
    Is this ok [y/N]: y

    在CentOS 7上安装PHP 8.0:

    sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    sudo yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
    sudo yum -y install yum-utils
    sudo yum-config-manager --disable 'remi-php*'
    sudo yum-config-manager --enable remi-safe
    sudo yum -y install php80 

    使用以下命令安装其他PHP扩展:

    sudo yum install php80-php-xxx

    或者

    sudo yum install php80-php-{cli,fpm,mysqlnd,zip,devel,gd,mbstring,curl,xml,pear,bcmath,json}

    同意安装提示:

    ..
    Dependencies Resolved
    
    ==================================================================================================================================================================
     Package                                    Arch                           Version                                        Repository                         Size
    ==================================================================================================================================================================
    Installing:
     php80-php-bcmath                           x86_64                         8.0.0~rc4-37.el7.remi                          remi-safe                          82 k
     php80-php-devel                            x86_64                         8.0.0~rc4-37.el7.remi                          remi-safe                         794 k
     php80-php-fpm                              x86_64                         8.0.0~rc4-37.el7.remi                          remi-safe                         1.8 M
     php80-php-gd                               x86_64                         8.0.0~rc4-37.el7.remi                          remi-safe                          87 k
     php80-php-mbstring                         x86_64                         8.0.0~rc4-37.el7.remi                          remi-safe                         483 k
     php80-php-mysqlnd                          x86_64                         8.0.0~rc4-37.el7.remi                          remi-safe                         193 k
     php80-php-pear                             noarch                         1:1.10.12-2.el7.remi                           remi-safe                         363 k
     php80-php-pecl-zip                         x86_64                         1.19.1-1.el7.remi                              remi-safe                          53 k
     php80-php-xml                              x86_64                         8.0.0~rc4-37.el7.remi                          remi-safe                         174 k
    Installing for dependencies:
     php80-php-pdo                              x86_64                         8.0.0~rc4-37.el7.remi                          remi-safe                         127 k
     php80-php-process                          x86_64                         8.0.0~rc4-37.el7.remi                          remi-safe                          86 k
    
    Transaction Summary
    ==================================================================================================================================================================
    Install  9 Packages (+2 Dependent packages)
    
    Total download size: 4.2 M
    Installed size: 16 M
    Is this ok [y/d/N]: y

    使用以下命令检查PHP 8版本和可用扩展

    $ php80 --version
    PHP 8.0.0RC4 (cli) (built: Nov 10 2020 10:57:27) ( NTS gcc x86_64 )
    Copyright (c) The PHP Group
    Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
    
    $ php80 --modules

    [root@vmcentos7 ~]# systemctl start php-fpm
    [root@vmcentos7 ~]# systemctl status php-fpm
    ● php-fpm.service - The PHP FastCGI Process Manager
    Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
    Active: active (running) since Tue 2021-01-19 17:45:01 CST; 5s ago
    Main PID: 1201 (php-fpm)
    Status: "Ready to handle connections"
    CGroup: /system.slice/php-fpm.service
    ├─1201 php-fpm: master process (/etc/php-fpm.conf)
    ├─1202 php-fpm: pool www
    ├─1203 php-fpm: pool www
    ├─1204 php-fpm: pool www
    ├─1205 php-fpm: pool www
    └─1206 php-fpm: pool www

    Jan 19 17:45:01 vmcentos7.aliyun systemd[1]: Starting The PHP FastCGI Process Manager...
    Jan 19 17:45:01 vmcentos7.aliyun systemd[1]: Started The PHP FastCGI Process Manager.
    [root@vmcentos7 ~]# systemctl enable php-fpm
    Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.

    [root@vmcentos7 ~]# ss -lntp | grep php
    LISTEN 0 128 127.0.0.1:9000 *:* users:(("php-fpm",pid=1206,fd=8),("php-fpm",pid=1205,fd=8),("php-fpm",pid=1204,fd=8),("php-fpm",pid=1203,fd=8),("php-fpm",pid=1202,fd=8),("php-fpm",pid=1201,fd=6))

    [root@vmcentos7 html]# ps auxfww | grep php | grep -v grep
    root 1201 0.0 0.7 261468 14176 ? Ss 17:45 0:00 php-fpm: master process (/etc/php-fpm.conf)
    apache 1202 0.0 0.4 261624 9276 ? S 17:45 0:00 \_ php-fpm: pool www
    apache 1203 0.0 0.4 261624 9272 ? S 17:45 0:00 \_ php-fpm: pool www
    apache 1204 0.0 0.5 261624 9432 ? S 17:45 0:00 \_ php-fpm: pool www
    apache 1205 0.0 0.4 261468 8396 ? S 17:45 0:00 \_ php-fpm: pool www
    apache 1206 0.0 0.4 261468 8152 ? S 17:45 0:00 \_ php-fpm: pool www

    配置nginx访问php-fpm

    1,准备测试用的目录和代码:
    复制代码
    [root@kubemaster web]# mkdir /data/web/phpweb
    [root@kubemaster web]# mkdir /data/web/phpweb/html
    [root@kubemaster web]# cd /data/web/phpweb/html
    [root@kubemaster html]# vi info.php
    [root@kubemaster html]# more info.php
    <?php
    phpinfo();
    ?>
    复制代码
     
    2,配置nginx
       在nginx的配置文件中增加一个虚拟主机,使可以访问php
       demo如下:
    复制代码
          server {
            listen       8003;
            root   /data/web/phpweb/html;
     
            location ~ .php {
                    fastcgi_pass   127.0.0.1:9000;
                    fastcgi_index  index.php;
                    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                    include        fastcgi_params;
            }
        }
    复制代码
        然后重启nginx
     
      3,从浏览器访问php
    访问:
    http://127.0.0.1:8003/info.php


    [root@vmcentos7 nginx]# yum install php80-unit-php
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    * remi-php80: mirrors.tuna.tsinghua.edu.cn
    * remi-safe: mirrors.tuna.tsinghua.edu.cn
    Resolving Dependencies
    --> Running transaction check
    ---> Package php80-unit-php.x86_64 0:1.21.0-1.el7.remi will be installed
    --> Processing Dependency: unit = 1.21.0 for package: php80-unit-php-1.21.0-1.el7.remi.x86_64
    --> Processing Dependency: php80-php-cli for package: php80-unit-php-1.21.0-1.el7.remi.x86_64
    --> Processing Dependency: php80-php-embedded for package: php80-unit-php-1.21.0-1.el7.remi.x86_64
    --> Running transaction check
    ---> Package php80-php-cli.x86_64 0:8.0.1-1.el7.remi will be installed
    --> Processing Dependency: php80-php-common(x86-64) = 8.0.1-1.el7.remi for package: php80-php-cli-8.0.1-1.el7.remi.x86_64
    ---> Package php80-php-embedded.x86_64 0:8.0.1-1.el7.remi will be installed
    ---> Package unit.x86_64 0:1.21.0-1.el7.remi will be installed
    --> Processing Dependency: libpcre2-8.so.0()(64bit) for package: unit-1.21.0-1.el7.remi.x86_64
    --> Running transaction check
    ---> Package pcre2.x86_64 0:10.23-2.el7 will be installed
    ---> Package php80-php-common.x86_64 0:8.0.1-1.el7.remi will be installed
    --> Processing Dependency: php80-runtime for package: php80-php-common-8.0.1-1.el7.remi.x86_64
    --> Running transaction check
    ---> Package php80-runtime.x86_64 0:1.0-3.el7.remi will be installed
    --> Processing Dependency: /usr/sbin/semanage for package: php80-runtime-1.0-3.el7.remi.x86_64
    --> Processing Dependency: environment-modules for package: php80-runtime-1.0-3.el7.remi.x86_64
    --> Processing Dependency: scl-utils for package: php80-runtime-1.0-3.el7.remi.x86_64
    --> Running transaction check
    ---> Package environment-modules.x86_64 0:3.2.10-10.el7 will be installed
    --> Processing Dependency: libtcl8.5.so()(64bit) for package: environment-modules-3.2.10-10.el7.x86_64
    ---> Package policycoreutils-python.x86_64 0:2.5-34.el7 will be installed
    --> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-34.el7.x86_64
    --> Processing Dependency: libsemanage-python >= 2.5-14 for package: policycoreutils-python-2.5-34.el7.x86_64
    --> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-34.el7.x86_64
    --> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-34.el7.x86_64
    --> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
    --> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
    --> Processing Dependency: libcgroup for package: policycoreutils-python-2.5-34.el7.x86_64
    --> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
    --> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-34.el7.x86_64
    --> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
    --> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
    ---> Package scl-utils.x86_64 0:20130529-19.el7 will be installed
    --> Running transaction check
    ---> Package audit-libs-python.x86_64 0:2.8.5-4.el7 will be installed
    ---> Package checkpolicy.x86_64 0:2.5-8.el7 will be installed
    ---> Package libcgroup.x86_64 0:0.41-21.el7 will be installed
    ---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
    ---> Package python-IPy.noarch 0:0.75-6.el7 will be installed
    ---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be installed
    ---> Package tcl.x86_64 1:8.5.13-8.el7 will be installed
    --> Finished Dependency Resolution

    Dependencies Resolved

    =============================================================================================================================================================================================================================================
    Package Arch Version Repository Size
    =============================================================================================================================================================================================================================================
    Installing:
    php80-unit-php x86_64 1.21.0-1.el7.remi remi-safe 63 k
    Installing for dependencies:
    audit-libs-python x86_64 2.8.5-4.el7 base 76 k
    checkpolicy x86_64 2.5-8.el7 base 295 k
    environment-modules x86_64 3.2.10-10.el7 base 107 k
    libcgroup x86_64 0.41-21.el7 base 66 k
    libsemanage-python x86_64 2.5-14.el7 base 113 k
    pcre2 x86_64 10.23-2.el7 base 201 k
    php80-php-cli x86_64 8.0.1-1.el7.remi remi-safe 3.5 M
    php80-php-common x86_64 8.0.1-1.el7.remi remi-safe 706 k
    php80-php-embedded x86_64 8.0.1-1.el7.remi remi-safe 1.7 M
    php80-runtime x86_64 1.0-3.el7.remi remi-safe 1.1 M
    policycoreutils-python x86_64 2.5-34.el7 base 457 k
    python-IPy noarch 0.75-6.el7 base 32 k
    scl-utils x86_64 20130529-19.el7 base 24 k
    setools-libs x86_64 3.3.8-4.el7 base 620 k
    tcl x86_64 1:8.5.13-8.el7 base 1.9 M
    unit x86_64 1.21.0-1.el7.remi remi-safe 283 k

    Transaction Summary
    =============================================================================================================================================================================================================================================
    Install 1 Package (+16 Dependent packages)

    Total download size: 11 M
    Installed size: 37 M
    Is this ok [y/d/N]: y
    Downloading packages:
    (1/17): audit-libs-python-2.8.5-4.el7.x86_64.rpm | 76 kB 00:00:00
    (2/17): checkpolicy-2.5-8.el7.x86_64.rpm | 295 kB 00:00:00
    (3/17): environment-modules-3.2.10-10.el7.x86_64.rpm | 107 kB 00:00:00
    (4/17): libcgroup-0.41-21.el7.x86_64.rpm | 66 kB 00:00:00
    (5/17): libsemanage-python-2.5-14.el7.x86_64.rpm | 113 kB 00:00:00
    (6/17): pcre2-10.23-2.el7.x86_64.rpm | 201 kB 00:00:00
    (7/17): php80-php-common-8.0.1-1.el7.remi.x86_64.rpm | 706 kB 00:00:00
    (8/17): php80-php-cli-8.0.1-1.el7.remi.x86_64.rpm | 3.5 MB 00:00:01
    (9/17): php80-php-embedded-8.0.1-1.el7.remi.x86_64.rpm | 1.7 MB 00:00:00
    (10/17): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:00:00
    (11/17): policycoreutils-python-2.5-34.el7.x86_64.rpm | 457 kB 00:00:00
    (12/17): scl-utils-20130529-19.el7.x86_64.rpm | 24 kB 00:00:00
    (13/17): setools-libs-3.3.8-4.el7.x86_64.rpm | 620 kB 00:00:00
    (14/17): tcl-8.5.13-8.el7.x86_64.rpm | 1.9 MB 00:00:00
    (15/17): php80-unit-php-1.21.0-1.el7.remi.x86_64.rpm | 63 kB 00:00:00
    (16/17): php80-runtime-1.0-3.el7.remi.x86_64.rpm | 1.1 MB 00:00:00
    (17/17): unit-1.21.0-1.el7.remi.x86_64.rpm | 283 kB 00:00:00
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Total 6.0 MB/s | 11 MB 00:00:01
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
    Installing : setools-libs-3.3.8-4.el7.x86_64 1/17
    Installing : audit-libs-python-2.8.5-4.el7.x86_64 2/17
    Installing : checkpolicy-2.5-8.el7.x86_64 3/17
    Installing : python-IPy-0.75-6.el7.noarch 4/17
    Installing : 1:tcl-8.5.13-8.el7.x86_64 5/17
    Installing : environment-modules-3.2.10-10.el7.x86_64 6/17
    Installing : libsemanage-python-2.5-14.el7.x86_64 7/17
    Installing : libcgroup-0.41-21.el7.x86_64 8/17
    Installing : policycoreutils-python-2.5-34.el7.x86_64 9/17
    Installing : scl-utils-20130529-19.el7.x86_64 10/17
    Installing : php80-runtime-1.0-3.el7.remi.x86_64 11/17
    Installing : php80-php-common-8.0.1-1.el7.remi.x86_64 12/17
    Installing : php80-php-cli-8.0.1-1.el7.remi.x86_64 13/17
    Installing : php80-php-embedded-8.0.1-1.el7.remi.x86_64 14/17
    Installing : pcre2-10.23-2.el7.x86_64 15/17
    Installing : unit-1.21.0-1.el7.remi.x86_64 16/17
    Installing : php80-unit-php-1.21.0-1.el7.remi.x86_64 17/17
    Verifying : php80-php-common-8.0.1-1.el7.remi.x86_64 1/17
    Verifying : pcre2-10.23-2.el7.x86_64 2/17
    Verifying : php80-unit-php-1.21.0-1.el7.remi.x86_64 3/17
    Verifying : php80-runtime-1.0-3.el7.remi.x86_64 4/17
    Verifying : scl-utils-20130529-19.el7.x86_64 5/17
    Verifying : libcgroup-0.41-21.el7.x86_64 6/17
    Verifying : php80-php-cli-8.0.1-1.el7.remi.x86_64 7/17
    Verifying : libsemanage-python-2.5-14.el7.x86_64 8/17
    Verifying : 1:tcl-8.5.13-8.el7.x86_64 9/17
    Verifying : environment-modules-3.2.10-10.el7.x86_64 10/17
    Verifying : python-IPy-0.75-6.el7.noarch 11/17
    Verifying : unit-1.21.0-1.el7.remi.x86_64 12/17
    Verifying : checkpolicy-2.5-8.el7.x86_64 13/17
    Verifying : policycoreutils-python-2.5-34.el7.x86_64 14/17
    Verifying : audit-libs-python-2.8.5-4.el7.x86_64 15/17
    Verifying : setools-libs-3.3.8-4.el7.x86_64 16/17
    Verifying : php80-php-embedded-8.0.1-1.el7.remi.x86_64 17/17

    Installed:
    php80-unit-php.x86_64 0:1.21.0-1.el7.remi

    Dependency Installed:
    audit-libs-python.x86_64 0:2.8.5-4.el7 checkpolicy.x86_64 0:2.5-8.el7 environment-modules.x86_64 0:3.2.10-10.el7 libcgroup.x86_64 0:0.41-21.el7 libsemanage-python.x86_64 0:2.5-14.el7
    pcre2.x86_64 0:10.23-2.el7 php80-php-cli.x86_64 0:8.0.1-1.el7.remi php80-php-common.x86_64 0:8.0.1-1.el7.remi php80-php-embedded.x86_64 0:8.0.1-1.el7.remi php80-runtime.x86_64 0:1.0-3.el7.remi
    policycoreutils-python.x86_64 0:2.5-34.el7 python-IPy.noarch 0:0.75-6.el7 scl-utils.x86_64 0:20130529-19.el7 setools-libs.x86_64 0:3.3.8-4.el7 tcl.x86_64 1:8.5.13-8.el7
    unit.x86_64 0:1.21.0-1.el7.remi

    Complete!

     
  • 相关阅读:
    elementUI Select 下拉框列表分两列展示
    radio切换后,表格数据记住之前选中的行
    vue 子组件和父组件生命周期顺序
    vue-router理解
    vuex理解
    实验四 决策树算法及应用
    实验三 朴素贝叶斯算法及应用
    实验二 K-近邻算法及应用
    词法分析可视化MFC
    SEO工具ahrefs各参数详解
  • 原文地址:https://www.cnblogs.com/xwhgr/p/14297320.html
Copyright © 2020-2023  润新知