CentOS 8에서 PHP-FPM 최신 버전 설치 방법을 알아보고, 실습을 통해 쉽게 적용하고 사용할 수 있습니다.
출처 : https://php-fpm.org |
CentOS 8에서 PHP-FPM 최신 버전 설치 방법을 알아보고, 실습을 통해 쉽게 적용하고 사용할 수 있습니다.
CentOS 8에서 PHP 설치 시 기본으로 7.2 버전으로 지정되어 있습니다.
이 버전은 대부분의 최신 PHP 응용 프로그램을 지원하지만, 2019년 11월부터 더 이상 유지 관리되지 않습니다.
최신 PHP 버전은 Remi Repository 추가 후 사용 할 수 있으며, 최신 버전인 7.4버전을 설치하겠습니다.
Remi Repository 추가 전 설치 가능한 PHP 버전 확인하기
[dnf module list php]
[root@RunIT ~]# dnf module list php Last metadata expiration check: 2:16:26 ago on Thu 30 Jan 2020 08:00:18 AM KST. CentOS-8 - AppStream Name Stream Profiles Summary php 7.2 [d] common [d], devel, minimal PHP scripting language php 7.3 common, devel, minimal PHP scripting language Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
Remi Repository 추가하기
Remi Repository 패키지 설치 및 활성화하기
[dnf install -y dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm]
[root@RunIT ~]# dnf install -y dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm Last metadata expiration check: 2:28:07 ago on Thu 30 Jan 2020 08:00:18 AM KST. remi-release-8.rpm 25 kB/s | 20 kB 00:00 Package dnf-utils-4.0.2.2-3.el8.noarch is already installed. Dependencies resolved. ===================================================================================================================================================================================================================================================================== Package Arch Version Repository Size ===================================================================================================================================================================================================================================================================== Installing: yum-utils noarch 4.0.8-3.el8 BaseOS 64 k replacing dnf-utils.noarch 4.0.2.2-3.el8 remi-release noarch 8.0-4.el8.remi @commandline 20 k Upgrading: dnf noarch 4.2.7-7.el8_1 BaseOS 490 k dnf-data noarch 4.2.7-7.el8_1 BaseOS 139 k dnf-plugins-core noarch 4.0.8-3.el8 BaseOS 62 k libdnf x86_64 0.35.1-9.el8_1 BaseOS 606 k librepo x86_64 1.10.3-3.el8 BaseOS 88 k libsolv x86_64 0.7.4-3.el8 BaseOS 351 k python3-dnf noarch 4.2.7-7.el8_1 BaseOS 506 k python3-dnf-plugins-core noarch 4.0.8-3.el8 BaseOS 193 k python3-hawkey x86_64 0.35.1-9.el8_1 BaseOS 96 k python3-libdnf x86_64 0.35.1-9.el8_1 BaseOS 689 k python3-librepo x86_64 1.10.3-3.el8 BaseOS 51 k yum noarch 4.2.7-7.el8_1 BaseOS 181 k Installing weak dependencies: sqlite x86_64 3.26.0-3.el8 BaseOS 665 k Transaction Summary ===================================================================================================================================================================================================================================================================== Install 3 Packages Upgrade 12 Packages Total size: 4.1 M Total download size: 4.1 M Downloading Packages: (1/14): yum-utils-4.0.8-3.el8.noarch.rpm 1.6 MB/s | 64 kB 00:00 (2/14): dnf-4.2.7-7.el8_1.noarch.rpm 10 MB/s | 490 kB 00:00 (3/14): sqlite-3.26.0-3.el8.x86_64.rpm 12 MB/s | 665 kB 00:00 (4/14): dnf-data-4.2.7-7.el8_1.noarch.rpm 7.2 MB/s | 139 kB 00:00 (5/14): dnf-plugins-core-4.0.8-3.el8.noarch.rpm 3.1 MB/s | 62 kB 00:00 (6/14): librepo-1.10.3-3.el8.x86_64.rpm 4.3 MB/s | 88 kB 00:00 (7/14): libdnf-0.35.1-9.el8_1.x86_64.rpm 17 MB/s | 606 kB 00:00 (8/14): libsolv-0.7.4-3.el8.x86_64.rpm 11 MB/s | 351 kB 00:00 (9/14): python3-dnf-4.2.7-7.el8_1.noarch.rpm 18 MB/s | 506 kB 00:00 (10/14): python3-hawkey-0.35.1-9.el8_1.x86_64.rpm 6.2 MB/s | 96 kB 00:00 (11/14): python3-librepo-1.10.3-3.el8.x86_64.rpm 7.4 MB/s | 51 kB 00:00 (12/14): python3-dnf-plugins-core-4.0.8-3.el8.noarch.rpm 5.5 MB/s | 193 kB 00:00 (13/14): python3-libdnf-0.35.1-9.el8_1.x86_64.rpm 32 MB/s | 689 kB 00:00 (14/14): yum-4.2.7-7.el8_1.noarch.rpm 18 MB/s | 181 kB 00:00 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 4.7 MB/s | 4.1 MB 00:00 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Running scriptlet: librepo-1.10.3-3.el8.x86_64 1/1 Upgrading : librepo-1.10.3-3.el8.x86_64 1/28 Upgrading : libsolv-0.7.4-3.el8.x86_64 2/28 Upgrading : libdnf-0.35.1-9.el8_1.x86_64 3/28 Upgrading : python3-libdnf-0.35.1-9.el8_1.x86_64 Upgrading : python3-hawkey-0.35.1-9.el8_1.x86_64 5/28 Upgrading : dnf-data-4.2.7-7.el8_1.noarch 6/28 Upgrading : python3-dnf-4.2.7-7.el8_1.noarch 7/28 Upgrading : python3-dnf-plugins-core-4.0.8-3.el8.noarch 8/28 Upgrading : dnf-plugins-core-4.0.8-3.el8.noarch 9/28 Installing : sqlite-3.26.0-3.el8.x86_64 10/28 Upgrading : dnf-4.2.7-7.el8_1.noarch 11/28 Running scriptlet: dnf-4.2.7-7.el8_1.noarch 11/28 Installing : yum-utils-4.0.8-3.el8.noarch 12/28 Upgrading : yum-4.2.7-7.el8_1.noarch 13/28 Upgrading : python3-librepo-1.10.3-3.el8.x86_64 14/28 Installing : remi-release-8.0-4.el8.remi.noarch 15/28 Obsoleting : dnf-utils-4.0.2.2-3.el8.noarch 16/28 Cleanup : python3-librepo-1.9.2-1.el8.x86_64 17/28 Cleanup : dnf-plugins-core-4.0.2.2-3.el8.noarch 18/28 Cleanup : python3-dnf-plugins-core-4.0.2.2-3.el8.noarch 19/28 Cleanup : yum-4.0.9.2-5.el8.noarch 20/28 Running scriptlet: dnf-4.0.9.2-5.el8.noarch 21/28 Cleanup : dnf-4.0.9.2-5.el8.noarch 21/28 Running scriptlet: dnf-4.0.9.2-5.el8.noarch 21/28 Cleanup : python3-dnf-4.0.9.2-5.el8.noarch 22/28 Cleanup : python3-hawkey-0.22.5-5.el8_0.x86_64 23/28 Cleanup : dnf-data-4.0.9.2-5.el8.noarch 24/28 Cleanup : python3-libdnf-0.22.5-5.el8_0.x86_64 25/28 Cleanup : libdnf-0.22.5-5.el8_0.x86_64 26/28 Cleanup : librepo-1.9.2-1.el8.x86_64 27/28 Cleanup : libsolv-0.6.35-6.el8.x86_64 28/28 Running scriptlet: libsolv-0.6.35-6.el8.x86_64 28/28 Verifying : sqlite-3.26.0-3.el8.x86_64 1/28 Verifying : yum-utils-4.0.8-3.el8.noarch 2/28 Verifying : dnf-utils-4.0.2.2-3.el8.noarch 3/28 Verifying : remi-release-8.0-4.el8.remi.noarch 4/28 Verifying : dnf-4.2.7-7.el8_1.noarch 5/28 Verifying : dnf-4.0.9.2-5.el8.noarch 6/28 Verifying : dnf-data-4.2.7-7.el8_1.noarch 7/28 Verifying : dnf-data-4.0.9.2-5.el8.noarch 8/28 Verifying : dnf-plugins-core-4.0.8-3.el8.noarch 9/28 Verifying : dnf-plugins-core-4.0.2.2-3.el8.noarch 10/28 Verifying : libdnf-0.35.1-9.el8_1.x86_64 11/28 Verifying : libdnf-0.22.5-5.el8_0.x86_64 12/28 Verifying : librepo-1.10.3-3.el8.x86_64 13/28 Verifying : librepo-1.9.2-1.el8.x86_64 14/28 Verifying : libsolv-0.7.4-3.el8.x86_64 15/28 Verifying : libsolv-0.6.35-6.el8.x86_64 16/28 Verifying : python3-dnf-4.2.7-7.el8_1.noarch 17/28 Verifying : python3-dnf-4.0.9.2-5.el8.noarch 18/28 Verifying : python3-dnf-plugins-core-4.0.8-3.el8.noarch 19/28 Verifying : python3-dnf-plugins-core-4.0.2.2-3.el8.noarch 20/28 Verifying : python3-hawkey-0.35.1-9.el8_1.x86_64 21/28 Verifying : python3-hawkey-0.22.5-5.el8_0.x86_64 22/28 Verifying : python3-libdnf-0.35.1-9.el8_1.x86_64 23/28 Verifying : python3-libdnf-0.22.5-5.el8_0.x86_64 24/28 Verifying : python3-librepo-1.10.3-3.el8.x86_64 25/28 Verifying : python3-librepo-1.9.2-1.el8.x86_64 26/28 Verifying : yum-4.2.7-7.el8_1.noarch 27/28 Verifying : yum-4.0.9.2-5.el8.noarch 28/28 Upgraded: dnf-4.2.7-7.el8_1.noarch dnf-data-4.2.7-7.el8_1.noarch dnf-plugins-core-4.0.8-3.el8.noarch libdnf-0.35.1-9.el8_1.x86_64 librepo-1.10.3-3.el8.x86_64 libsolv-0.7.4-3.el8.x86_64 python3-dnf-4.2.7-7.el8_1.noarch python3-dnf-plugins-core-4.0.8-3.el8.noarch python3-hawkey-0.35.1-9.el8_1.x86_64 python3-libdnf-0.35.1-9.el8_1.x86_64 python3-librepo-1.10.3-3.el8.x86_64 yum-4.2.7-7.el8_1.noarch Installed: yum-utils-4.0.8-3.el8.noarch remi-release-8.0-4.el8.remi.noarch sqlite-3.26.0-3.el8.x86_64 Complete!
Remi Repository 추가 후 설치 가능한 PHP 버전 확인하기
[dnf module list php]
[root@RunIT ~]# dnf module list php Remi's Modular repository for Enterprise Linux 8 - x86_64 132 kB/s | 531 kB 00:04 Safe Remi's RPM repository for Enterprise Linux 8 - x86_64 205 kB/s | 1.4 MB 00:06 Last metadata expiration check: 0:00:01 ago on Thu 30 Jan 2020 10:33:25 AM KST. CentOS-8 - AppStream Name Stream Profiles Summary php 7.2 [d] common [d], devel, minimal PHP scripting language php 7.3 common, 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
위 버전 리스트에서 7.2 [d] 부분으로 기본으로 7.2버전이 선택되어 있는 것을 확인 할 수 있습니다.
PHP 7.4 Repository 활성화하기
[module reset php]
[root@RunIT ~]# module reset php Last metadata expiration check: 0:27:02 ago on Thu 30 Jan 2020 10:33:25 AM KST. Dependencies resolved. Nothing to do. Complete!
[dnf module enable php:remi-7.4]
[root@RunIT ~]# dnf module enable php:remi-7.4 Last metadata expiration check: 0:27:08 ago on Thu 30 Jan 2020 10:33:25 AM KST. Dependencies resolved. ===================================================================================================================================================================================================================================================================== Package Architecture Version Repository Size ===================================================================================================================================================================================================================================================================== Enabling module streams: php remi-7.4 Transaction Summary ===================================================================================================================================================================================================================================================================== Is this ok [y/N]: y Complete!
PHP 7.4 Repository 활성화 확인하기
[dnf module list php]
[root@RunIT ~]# dnf module list php Last metadata expiration check: 0:02:16 ago on Thu 30 Jan 2020 11:02:20 AM KST. CentOS-8 - AppStream Name Stream Profiles Summary php 7.2 [d] common [d], devel, minimal PHP scripting language php 7.3 common, 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 [e] common [d], devel, minimal PHP scripting language Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
remi-7.4 [e]버전이 활성화 된 것을 알 수 있습니다.
PHP-FPM 7.4 버전 설치하기
설치 가능한 PHP-FPM 버전 확인하기
[dnf info php-fpm]
[root@RunIT ~]# dnf info php-fpm Last metadata expiration check: 0:14:03 ago on Thu 30 Jan 2020 11:02:20 AM KST. Available Packages Name : php-fpm Version : 7.4.2 Release : 1.el8.remi Architecture : x86_64 Size : 1.6 M Source : php-7.4.2-1.el8.remi.src.rpm Repository : remi-modular Summary : PHP FastCGI Process Manager URL : http://www.php.net/ License : PHP and Zend and BSD and MIT and ASL 1.0 and NCSA Description : PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI : implementation with some additional features useful for sites of : any size, especially busier sites.
PHP-FPM 설치하기
[dnf install php-fpm -y]
[root@RunIT ~]# dnf install php-fpm -y Last metadata expiration check: 0:15:54 ago on Thu 30 Jan 2020 11:02:20 AM KST. Dependencies resolved. ===================================================================================================================================================================================================================================================================== Package Architecture Version Repository Size ===================================================================================================================================================================================================================================================================== Installing: php-fpm x86_64 7.4.2-1.el8.remi remi-modular 1.6 M Installing dependencies: httpd-filesystem noarch 2.4.37-16.module_el8.1.0+256+ae790463 AppStream 35 k php-common x86_64 7.4.2-1.el8.remi remi-modular 1.2 M php-json x86_64 7.4.2-1.el8.remi remi-modular 73 k Installing weak dependencies: nginx-filesystem noarch 1:1.14.1-9.module_el8.0.0+184+e34fea82 AppStream 24 k Enabling module streams: httpd 2.4 nginx 1.14 Transaction Summary ===================================================================================================================================================================================================================================================================== Install 5 Packages Total download size: 2.9 M Installed size: 20 M Is this ok [y/N]: y Downloading Packages: (1/5): httpd-filesystem-2.4.37-16.module_el8.1.0+256+ae790463.noarch.rpm 2.2 MB/s | 35 kB 00:00 (2/5): nginx-filesystem-1.14.1-9.module_el8.0.0+184+e34fea82.noarch.rpm 1.0 MB/s | 24 kB 00:00 (3/5): php-json-7.4.2-1.el8.remi.x86_64.rpm 51 kB/s | 73 kB 00:01 (4/5): php-common-7.4.2-1.el8.remi.x86_64.rpm 292 kB/s | 1.2 MB 00:04 (5/5): php-fpm-7.4.2-1.el8.remi.x86_64.rpm 324 kB/s | 1.6 MB 00:05 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 465 kB/s | 2.9 MB 00:06 warning: /var/cache/dnf/remi-modular-6408ecca79e22107/packages/php-common-7.4.2-1.el8.remi.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 5f11735a: NOKEY Remi's Modular repository for Enterprise Linux 8 - x86_64 3.0 MB/s | 3.1 kB 00:00 Importing GPG key 0x5F11735A: Userid : "Remi's RPM repository" Fingerprint: 6B38 FEA7 231F 87F5 2B9C A9D8 5550 9759 5F11 735A From : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el8 Is this ok [y/N]: y Key imported successfully Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : php-json-7.4.2-1.el8.remi.x86_64 1/5 Running scriptlet: php-common-7.4.2-1.el8.remi.x86_64 2/5 Installing : php-common-7.4.2-1.el8.remi.x86_64 2/5 Running scriptlet: nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch 3/5 Installing : nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch 3/5 Running scriptlet: httpd-filesystem-2.4.37-16.module_el8.1.0+256+ae790463.noarch 4/5 Installing : httpd-filesystem-2.4.37-16.module_el8.1.0+256+ae790463.noarch 4/5 Installing : php-fpm-7.4.2-1.el8.remi.x86_64 5/5 Running scriptlet: php-fpm-7.4.2-1.el8.remi.x86_64 5/5 Verifying : httpd-filesystem-2.4.37-16.module_el8.1.0+256+ae790463.noarch 1/5 Verifying : nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch 2/5 Verifying : php-common-7.4.2-1.el8.remi.x86_64 3/5 Verifying : php-fpm-7.4.2-1.el8.remi.x86_64 4/5 Verifying : php-json-7.4.2-1.el8.remi.x86_64 5/5 Installed: php-fpm-7.4.2-1.el8.remi.x86_64 nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch httpd-filesystem-2.4.37-16.module_el8.1.0+256+ae790463.noarch php-common-7.4.2-1.el8.remi.x86_64 php-json-7.4.2-1.el8.remi.x86_64 Complete!
추가 패키지 필요 시 dnf install php-추가패키지명 실행으로 설치하시면 됩니다.
PHP-FPM 7.4 설치 확인하기
[php-fpm -v]
[root@RunIT ~]# php-fpm -v PHP 7.4.2 (fpm-fcgi) (built: Jan 21 2020 11:35:20) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies
PHP-FPM 7.4 실행하기
php-fpm 서비스 실행 및 상태 확인하기
systemctl 명령을 사용해서 php-fpm 서비스 실행합니다.
[systemctl start php-fpm]
systemctl 명령을 사용해서 php-fpm 서비스 상태를 확인합니다.
[systemctl status php-fpm]
[root@RunIT ~]# systemctl status php-fpm ● php-fpm.service - The PHP FastCGI Process Manager Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2020-01-30 11:34:21 KST; 19s ago Main PID: 12646 (php-fpm) Status: "Processes active: 0, idle: 5, Requests: 0, slow: 0, Traffic: 0req/sec" Tasks: 6 (limit: 26213) Memory: 18.7M CGroup: /system.slice/php-fpm.service ├─12646 php-fpm: master process (/etc/php-fpm.conf) ├─12648 php-fpm: pool www ├─12649 php-fpm: pool www ├─12650 php-fpm: pool www ├─12651 php-fpm: pool www └─12652 php-fpm: pool www Jan 30 11:34:20 testserver systemd[1]: Starting The PHP FastCGI Process Manager... Jan 30 11:34:21 testserver systemd[1]: Started The PHP FastCGI Process Manager.
PHP-FPM 서비스 활성화 및 부팅 시 자동 실행 적용하기
[systemctl enable php-fpm]
[root@RunIT ~]# systemctl enable php-fpm Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.
마무리
리눅스 서버에서 php-fpm 서비스를 설치하고 실행하는 방법에 대해 알아보았습니다.
이 글을 통해 쉽게 php-fpm 서비스를 설치 및 등록할 수 있습니다.
COMMENTS