Dalam artikel ini, kami akan membahas langkah-langkah terperinci untuk menginstal PHP 7.4 pada sistem operasi CentOS 7. Mulai dari menambahkan repositori yang diperlukan, mengaktifkan repositori Remi, hingga memasang PHP 7.4 dan modul terkait untuk Apache. Tutorial ini dirancang untuk membantu Anda meningkatkan versi PHP pada server CentOS 7 Anda, memastikan kinerja dan keamanan yang optimal untuk aplikasi web Anda. Ikuti panduan ini untuk setup PHP 7.4 yang lancar dan efektif.
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
[root@cloud-one ~]# yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm Loaded plugins: fastestmirror Examining /var/tmp/yum-root-M4WDnT/epel-release-latest-7.noarch.rpm: epel-release-7-14.noarch Marking /var/tmp/yum-root-M4WDnT/epel-release-latest-7.noarch.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package epel-release.noarch 0:7-14 will be installed --> Finished Dependency Resolution Dependencies Resolved =============================================================================================================== Package Arch Version Repository Size =============================================================================================================== Installing: epel-release noarch 7-14 /epel-release-latest-7.noarch 25 k Transaction Summary =============================================================================================================== Install 1 Package Total size: 25 k Installed size: 25 k Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : epel-release-7-14.noarch 1/1 Verifying : epel-release-7-14.noarch 1/1 Installed: epel-release.noarch 0:7-14 Complete! [root@cloud-tam ~]# [root@cloud-tam ~]# yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm Loaded plugins: fastestmirror remi-release-7.rpm | 28 kB 00:00:00 Examining /var/tmp/yum-root-M4WDnT/remi-release-7.rpm: remi-release-7.9-6.el7.remi.noarch Marking /var/tmp/yum-root-M4WDnT/remi-release-7.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package remi-release.noarch 0:7.9-6.el7.remi will be installed --> Finished Dependency Resolution Dependencies Resolved =============================================================================================================== Package Arch Version Repository Size =============================================================================================================== Installing: remi-release noarch 7.9-6.el7.remi /remi-release-7 39 k Transaction Summary =============================================================================================================== Install 1 Package Total size: 39 k Installed size: 39 k Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : remi-release-7.9-6.el7.remi.noarch 1/1 Verifying : remi-release-7.9-6.el7.remi.noarch 1/1 Installed: remi-release.noarch 0:7.9-6.el7.remi Complete! [root@cloud-one ~]#
sudo yum -y install yum-utils
[root@cloud-one ~]# yum -y install yum-utils Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * epel: linux.domainesia.com * remi-safe: cdn.centos.no Resolving Dependencies --> Running transaction check ---> Package yum-utils.noarch 0:1.1.31-54.el7_8 will be installed --> Processing Dependency: python-kitchen for package: yum-utils-1.1.31-54.el7_8.noarch --> Running transaction check ---> Package python-kitchen.noarch 0:1.1.1-5.el7 will be installed --> Processing Dependency: python-chardet for package: python-kitchen-1.1.1-5.el7.noarch --> Running transaction check ---> Package python-chardet.noarch 0:2.2.1-3.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved =============================================================================================================== Package Arch Version Repository Size =============================================================================================================== Installing: yum-utils noarch 1.1.31-54.el7_8 base 122 k Installing for dependencies: python-chardet noarch 2.2.1-3.el7 base 227 k python-kitchen noarch 1.1.1-5.el7 base 267 k Transaction Summary =============================================================================================================== Install 1 Package (+2 Dependent packages) Total download size: 616 k Installed size: 2.8 M Downloading packages: (1/3): python-chardet-2.2.1-3.el7.noarch.rpm | 227 kB 00:00:00 (2/3): python-kitchen-1.1.1-5.el7.noarch.rpm | 267 kB 00:00:00 (3/3): yum-utils-1.1.31-54.el7_8.noarch.rpm | 122 kB 00:00:00 --------------------------------------------------------------------------------------------------------------- Total 945 kB/s | 616 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : python-chardet-2.2.1-3.el7.noarch 1/3 Installing : python-kitchen-1.1.1-5.el7.noarch 2/3 Installing : yum-utils-1.1.31-54.el7_8.noarch 3/3 Verifying : python-kitchen-1.1.1-5.el7.noarch 1/3 Verifying : yum-utils-1.1.31-54.el7_8.noarch 2/3 Verifying : python-chardet-2.2.1-3.el7.noarch 3/3 Installed: yum-utils.noarch 0:1.1.31-54.el7_8 Dependency Installed: python-chardet.noarch 0:2.2.1-3.el7 python-kitchen.noarch 0:1.1.1-5.el7 Complete! [root@cloud-one ~]#
[root@cloud-one ~]# yum-config-manager --disable 'remi-php*'
sudo yum install php php-cli php-fpm php-gd php-mysqlnd php-pdo php-xml php-mbstring php-intl php-json php-zip php-pecl-apcu -y
[root@cloud-one ~]# sudo yum install php php-cli php-fpm php-gd php-mysqlnd php-pdo php-xml php-mbstring php-intl php-json php-zip php-pecl-apcu -y
[root@cloud-one ~]# sudo yum install php php-cli php-fpm php-gd php-mysqlnd php-pdo php-xml php-mbstring php-intl php-json php-zip php-pecl-apcu -y Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * epel: mirror.gi.co.id * remi-php74: cdn.centos.no * remi-safe: cdn.centos.no Resolving Dependencies --> Running transaction check ---> Package php.x86_64 0:7.4.33-15.el7.remi will be obsoleting --> Processing Dependency: php-common(x86-64) = 7.4.33-15.el7.remi for package: php-7.4.33-15.el7.remi.x86_64 --> Processing Dependency: php-sodium(x86-64) = 7.4.33-15.el7.remi for package: php-7.4.33-15.el7.remi.x86_64 ---> Package php-cli.x86_64 0:7.4.33-15.el7.remi will be obsoleting ---> Package php-fpm.x86_64 0:7.4.33-15.el7.remi will be installed ... ... Verifying : php70w-common-7.0.33-1.w7.x86_64 36/37 Verifying : 1:php70w-pear-1.10.4-1.w7.noarch 37/37 Installed: php.x86_64 0:7.4.33-15.el7.remi php-cli.x86_64 0:7.4.33-15.el7.remi php-common.x86_64 0:7.4.33-15.el7.remi php-fpm.x86_64 0:7.4.33-15.el7.remi php-gd.x86_64 0:7.4.33-15.el7.remi php-intl.x86_64 0:7.4.33-15.el7.remi php-json.x86_64 0:7.4.33-15.el7.remi php-mbstring.x86_64 0:7.4.33-15.el7.remi php-mysqlnd.x86_64 0:7.4.33-15.el7.remi php-pdo.x86_64 0:7.4.33-15.el7.remi php-pear.noarch 1:1.10.15-3.el7.remi php-pecl-apcu.x86_64 0:5.1.23-1.el7.remi.7.4 php-pecl-mcrypt.x86_64 0:1.0.7-1.el7.remi.7.4 php-pecl-zip.x86_64 0:1.22.3-1.el7.remi.7.4 php-process.x86_64 0:7.4.33-15.el7.remi php-xml.x86_64 0:7.4.33-15.el7.remi Dependency Installed: gd3php.x86_64 0:2.3.3-7.el7.remi libicu73.x86_64 0:73.2-1.el7.remi libraqm.x86_64 0:0.7.0-4.el7 libsodium.x86_64 0:1.0.18-1.el7 libwebp7.x86_64 0:1.0.3-2.el7.remi libzip5.x86_64 0:1.10.1-1.el7.remi libzstd.x86_64 0:1.5.5-1.el7 oniguruma5php.x86_64 0:6.9.9-1.el7.remi php-sodium.x86_64 0:7.4.33-15.el7.remi Replaced: php70w.x86_64 0:7.0.33-1.w7 php70w-cli.x86_64 0:7.0.33-1.w7 php70w-common.x86_64 0:7.0.33-1.w7 php70w-gd.x86_64 0:7.0.33-1.w7 php70w-intl.x86_64 0:7.0.33-1.w7 php70w-mbstring.x86_64 0:7.0.33-1.w7 php70w-mcrypt.x86_64 0:7.0.33-1.w7 php70w-mysql.x86_64 0:7.0.33-1.w7 php70w-pdo.x86_64 0:7.0.33-1.w7 php70w-pear.noarch 1:1.10.4-1.w7 php70w-process.x86_64 0:7.0.33-1.w7 php70w-xml.x86_64 0:7.0.33-1.w7 Complete! [root@cloud-one ~]#
sudo yum install php74-php mod_php
[root@cloud-one ~]# yum install php74-php mod_php Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * epel: mirror.gi.co.id * remi-php74: cdn.centos.no * remi-safe: cdn.centos.no Package php-7.4.33-15.el7.remi.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check ---> Package php74-php.x86_64 0:7.4.33-15.el7.remi will be installed --> Processing Dependency: php74-php-common(x86-64) = 7.4.33-15.el7.remi for package: php74-php-7.4.33-15.el7.remi.x86_64 --> Processing Dependency: php74-php-cli(x86-64) = 7.4.33-15.el7.remi for package: php74-php-7.4.33-15.el7.remi.x86_64 --> Processing Dependency: php74-php-sodium(x86-64) = 7.4.33-15.el7.remi for package: php74-php-7.4.33-15.el7.remi.x86_64 --> Running transaction check ---> Package php74-php-cli.x86_64 0:7.4.33-15.el7.remi will be installed ---> Package php74-php-common.x86_64 0:7.4.33-15.el7.remi will be installed --> Processing Dependency: php74-php-json(x86-64) = 7.4.33-15.el7.remi for package: php74-php-common-7.4.33-15.el7.remi.x86_64 --> Processing Dependency: php74-runtime for package: php74-php-common-7.4.33-15.el7.remi.x86_64 ---> Package php74-php-sodium.x86_64 0:7.4.33-15.el7.remi will be installed --> Running transaction check ---> Package php74-php-json.x86_64 0:7.4.33-15.el7.remi will be installed ---> Package php74-runtime.x86_64 0:7.4-3.el7.remi will be installed --> Processing Dependency: environment-modules for package: php74-runtime-7.4-3.el7.remi.x86_64 --> Processing Dependency: scl-utils for package: php74-runtime-7.4-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 scl-utils.x86_64 0:20130529-19.el7 will be installed --> Running transaction check ---> Package tcl.x86_64 1:8.5.13-8.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved =============================================================================================================== Package Arch Version Repository Size =============================================================================================================== Installing: php74-php x86_64 7.4.33-15.el7.remi remi-safe 1.7 M Installing for dependencies: environment-modules x86_64 3.2.10-10.el7 base 107 k php74-php-cli x86_64 7.4.33-15.el7.remi remi-safe 3.5 M php74-php-common x86_64 7.4.33-15.el7.remi remi-safe 702 k php74-php-json x86_64 7.4.33-15.el7.remi remi-safe 80 k php74-php-sodium x86_64 7.4.33-15.el7.remi remi-safe 85 k php74-runtime x86_64 7.4-3.el7.remi remi-safe 1.1 M scl-utils x86_64 20130529-19.el7 base 24 k tcl x86_64 1:8.5.13-8.el7 base 1.9 M Transaction Summary =============================================================================================================== Install 1 Package (+8 Dependent packages) Total download size: 9.2 M Installed size: 29 M Is this ok [y/d/N]: y Downloading packages: (1/9): php74-php-7.4.33-15.el7.remi.x86_64.rpm | 1.7 MB 00:00:00 (2/9): php74-php-common-7.4.33-15.el7.remi.x86_64.rpm | 702 kB 00:00:00 (3/9): php74-php-cli-7.4.33-15.el7.remi.x86_64.rpm | 3.5 MB 00:00:00 (4/9): php74-php-json-7.4.33-15.el7.remi.x86_64.rpm | 80 kB 00:00:00 (5/9): php74-php-sodium-7.4.33-15.el7.remi.x86_64.rpm | 85 kB 00:00:00 (6/9): php74-runtime-7.4-3.el7.remi.x86_64.rpm | 1.1 MB 00:00:00 (7/9): scl-utils-20130529-19.el7.x86_64.rpm | 24 kB 00:00:00 (8/9): tcl-8.5.13-8.el7.x86_64.rpm | 1.9 MB 00:00:00 (9/9): environment-modules-3.2.10-10.el7.x86_64.rpm | 107 kB 00:00:01 --------------------------------------------------------------------------------------------------------------- Total 6.1 MB/s | 9.2 MB 00:00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : scl-utils-20130529-19.el7.x86_64 1/9 Installing : 1:tcl-8.5.13-8.el7.x86_64 2/9 Installing : environment-modules-3.2.10-10.el7.x86_64 3/9 Installing : php74-runtime-7.4-3.el7.remi.x86_64 4/9 Installing : php74-php-json-7.4.33-15.el7.remi.x86_64 5/9 Installing : php74-php-common-7.4.33-15.el7.remi.x86_64 6/9 Installing : php74-php-sodium-7.4.33-15.el7.remi.x86_64 7/9 Installing : php74-php-cli-7.4.33-15.el7.remi.x86_64 8/9 Installing : php74-php-7.4.33-15.el7.remi.x86_64 9/9 ===================================================================== WARNING : PHP 7.4 have reached its "End of Life" in November 2022. Even, if this package includes some of the important security fixes, backported from 8.1, the UPGRADE to a maintained version is very strongly RECOMMENDED. ===================================================================== Verifying : php74-php-7.4.33-15.el7.remi.x86_64 1/9 Verifying : 1:tcl-8.5.13-8.el7.x86_64 2/9 Verifying : scl-utils-20130529-19.el7.x86_64 3/9 Verifying : php74-php-sodium-7.4.33-15.el7.remi.x86_64 4/9 Verifying : environment-modules-3.2.10-10.el7.x86_64 5/9 Verifying : php74-php-json-7.4.33-15.el7.remi.x86_64 6/9 Verifying : php74-runtime-7.4-3.el7.remi.x86_64 7/9 Verifying : php74-php-common-7.4.33-15.el7.remi.x86_64 8/9 Verifying : php74-php-cli-7.4.33-15.el7.remi.x86_64 9/9 Installed: php74-php.x86_64 0:7.4.33-15.el7.remi Dependency Installed: environment-modules.x86_64 0:3.2.10-10.el7 php74-php-cli.x86_64 0:7.4.33-15.el7.remi php74-php-common.x86_64 0:7.4.33-15.el7.remi php74-php-json.x86_64 0:7.4.33-15.el7.remi php74-php-sodium.x86_64 0:7.4.33-15.el7.remi php74-runtime.x86_64 0:7.4-3.el7.remi scl-utils.x86_64 0:20130529-19.el7 tcl.x86_64 1:8.5.13-8.el7 Complete! [root@cloud-one ~]#
[root@cloud-one ~]# systemctl restart httpd [root@cloud-one ~]#
[root@cloud-one ~]# php -v PHP 7.4.33 (cli) (built: Jun 5 2024 05:05:14) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies [root@cloud-one ~]# [root@cloud-one ~]#