3.223.3.251

Kā instalēt PHP 7.4 / 7.3 vietnē CentOS 8 / RHEL 8

Kā instalēt PHP 7.4 / 7.3 vietnē CentOS 8 / RHEL 8

PHP ir atvērtā koda programmēšanas valoda, kas plaši paredzēta tīmekļa izstrādei, un to izveidoja Rasmus Lerdorf. Tā ir HTML iegulta skriptu valoda dinamisku vietņu izveidei.

Šajā amatā mēs redzēsim, kā instalēt PHP 7.4 / 7.3 uz CentOS 8 / RHEL 8. Pievienot Remi repozitoriju

Remi, trešās puses krātuve, kas piedāvā vairākas PHP versijas (7.4 / 7.3 / 7.2) Red Hat Enterprise Linux.

Remi repozitorijam jūsu sistēmā ir jāiespējo EPEL krātuve.

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

Lai savā sistēmā iespējotu Remi repozitoriju, instalējiet Remi repozitorija automātiskās konfigurācijas pakotni, izmantojot tālāk norādīto komandu.

dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm

Rezultāts:

CentOS-8 - AppStream                                                               1.7 MB/s | 6.3 MB     00:03    
CentOS-8 - Base                                                                    3.0 MB/s | 7.9 MB     00:02    
CentOS-8 - Extras                                                                  5.5 kB/s | 2.1 kB     00:00    
CentOS-8 - PowerTools                                                              916 kB/s | 1.8 MB     00:02    
Extra Packages for Enterprise Linux 8 - x86_64                                     1.9 MB/s | 5.2 MB     00:02    
Google Cloud SDK                                                                   6.6 MB/s |  29 MB     00:04    
Google Compute Engine                                                              1.7 kB/s | 5.8 kB     00:03    
remi-release-8.rpm                                                                  13 kB/s |  20 kB     00:01    
Dependencies resolved.
===================================================================================================================
 Package                     Arch                  Version                       Repository                   Size
===================================================================================================================
Installing:
 remi-release                noarch                8.0-4.el8.remi                @commandline                 20 k

Transaction Summary
===================================================================================================================
Install  1 Package

Total size: 20 k
Installed size: 14 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                           1/1 
  Installing       : remi-release-8.0-4.el8.remi.noarch                                                        1/1 
  Verifying        : remi-release-8.0-4.el8.remi.noarch                                                        1/1 

Installed:
  remi-release-8.0-4.el8.remi.noarch                                                                               
Complete!

Uzskaitiet pieejamo PHP moduļa straumi.

dnf module list php

Jums vajadzētu redzēt zem izvades.

CentOS-8 - AppStream
Name              Stream                Profiles                                Summary                            
php               7.2 [d]               common [d], devel, minimal              PHP scripting language             
Remi's Modular repository for Enterprise Linux 8 - x86_64
Name              Stream                Profiles                                Summary                            
php               remi-7.2              common [d], devel, minimal              PHP scripting language             
php               remi-7.3              common [d], devel, minimal              PHP scripting language             
php               remi-7.4              common [d], devel, minimal              PHP scripting language             
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

CentOS 8 / RHEL 8 instalējiet PHP 7.4

Iespējojiet moduli php: remi-7.4 , lai instalētu PHP 7.4.

dnf module enable php:remi-7.4 -y

Rezultāts

Last metadata expiration check: 0:03:03 ago on Sat 11 Jan 2020 02:41:27 PM UTC.
Dependencies resolved.
===================================================================================================================
 Package                    Arch                      Version                     Repository                  Size
===================================================================================================================
Enabling module streams:
 httpd                                                2.4                                                         
 php                                                  remi-7.4                                                    

Transaction Summary
===================================================================================================================

Complete!

Switching module streams does not alter installed packages (see 'module enable' in dnf(8) for details)

Instalējiet PHP 7.4 uz CentOS 8 / RHEL 8 ar komandu dnf.

dnf install -y php php-cli php-common

CentOS 8 / RHEL 8 instalējiet PHP 7.3

Iespējojiet moduli php: remi-7.3 , lai instalētu PHP 7.3.

dnf module enable php:remi-7.3 -y

Rezultāts:

Last metadata expiration check: 0:03:03 ago on Sat 11 Jan 2020 02:41:27 PM UTC.
Dependencies resolved.
===================================================================================================================
 Package                    Arch                      Version                     Repository                  Size
===================================================================================================================
Enabling module streams:
 httpd                                                2.4                                                         
 nginx                                                1.14                                                        
 php                                                  remi-7.3                                                    

Transaction Summary
===================================================================================================================

Complete!
Switching module streams does not alter installed packages (see 'module enable' in dnf(8) for details)

Instalējiet PHP 7.3 uz CentOS 8 / RHEL 8 ar dnf komandu .

dnf install -y php php-cli php-common

Pārbaudiet PHP versiju

Kad esat instalējis PHP, pārbaudiet PHP versiju ar šādu komandu.

php -v

Rezultāts:

PHP 7.4.1 (cli) (built: Dec 17 2019 16:35:58) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.1, Copyright (c), by Zend Technologies

Instalējiet PHP-FPM

Lai jūsu kodam būtu MySQL atbalsts, varat instalēt pakotni php-mysqlnd .

dnf install -y php-fpm

Instalējiet PHP paplašinājumu

PHP paplašinājumi ir apkopotas bibliotēkas, kas nodrošina īpašu atbalstu jūsu kodam.

Lai jūsu kodā būtu MySQL atbalsts, varat instalēt paketi php-mysqlnd.dnf install -y php-mysqlnd

Kad esat instalējis MySQL paplašinājumu, varat to izmantot zemāk esošajā komandā.

php -m | grep -i mysql

Rezultāts:

mysqli
mysqlnd
pdo_mysql

PHP paplašinājumi programmai WordPress

Lai instalētu un palaistu WordPress savā RHEL 8 datorā, ir nepieciešami šādi paplašinājumi. WordPress instalēšanai iesaka PHP v7.3.

dnf install -y php-dom php-simplexml php-ssh2 php-xml php-xmlreader php-curl php-date php-exif php-filter php-ftp php-gd php-hash php-iconv php-json php-libxml php-pecl-imagick php-mbstring php-mysqlnd php-openssl php-pcre php-posix php-sockets php-spl php-tokenizer php-zlib

PHP paplašinājumi Joomla

Lai instalētu un palaistu Joomla savā RHEL 8 mašīnā, ir nepieciešami šādi paplašinājumi. Joomla nepieciešama PHP v7.1 un jaunāka versija.

dnf install -y php-mysqlnd php-zlib php-xml php-pear php-json php-mcrypt php-pecl-imagick

PHP paplašinājumi Drupal

Lai instalētu un palaistu Joomla savā RHEL 8 mašīnā, ir nepieciešami šādi paplašinājumi. Drupal nepieciešama PHP v7.1 un jaunāka versija.

dnf install -y php-mysqlnd php-date php-dom php-filter php-gd php-hash php-json php-pcre php-pdo php-session php-simplexml php-spl php-tokenizer php-xml

Secinājums

Es ceru, ka esat iemācījies instalēt PHP 7.4 / 7.3 vietnē CentOS 8 / RHEL 8.