본문 바로가기
Linux/서버구축 1.2.3...

워드프레스를 위한 Rocky Linux/AlmaLinux 서버 구축 (2)

by aegypius 2024. 10. 9.
728x90
반응형

(9) php의 설치

Rocky Linux 9.4(AlmaLinux 9.4)에 php를 설치하면 8.0 버전이 설치된다. 아래와 같다.

가급적이면...php는 아래와 같이 8.0.30버전을 사용하기로 했다. 나중에 Rocky Linux나 AlmaLinux의 상위 버전이 나온다면 그때에는 php 8.4.x나 그 이후의 버전을 사용해도 될지는 모르겠지만....그때는 apache도 2.4.57이 아닌 상위버전으로 바뀌어 있을 것이다. 리눅스 배포판의 기본 패키지인데도..뭔가 궁합이 잘 맞지 않는다. 이러한 점에서는 Rocky linux보다는 AlmaLinux가 그나머 더 나은 편이긴 했다. (대략 2주정도 설치, 재설치를 반복한 후의 느낌이다...)

php를 설치한 후에는 php.ini를 편집하여 upload_max_filesize를 대략 8~16M 정도로 사용하는데에 불편함 없이 설정하자. 그 이외의 나머지 값(memory_limit, post_max_size, max_exection_time 등은 굳이 수정할 필요를 못느꼈다.)

[root@contabo /]# dnf install php
Last metadata expiration check: 2:04:46 ago on Mon 14 Oct 2024 11:49:15 AM KST.
Dependencies resolved.
===========================================================================================================================
 Package                         Architecture          Version                              Repository                Size
===========================================================================================================================
Installing:
 php                             x86_64                8.0.30-1.el9_2                       appstream                7.7 k
Installing dependencies:
 libxslt                         x86_64                1.1.34-9.el9                         appstream                240 k
 nginx-filesystem                noarch                1:1.20.1-16.el9_4.1                  appstream                8.1 k
 php-common                      x86_64                8.0.30-1.el9_2                       appstream                665 k
Installing weak dependencies:
 php-cli                         x86_64                8.0.30-1.el9_2                       appstream                3.1 M
 php-fpm                         x86_64                8.0.30-1.el9_2                       appstream                1.6 M
 php-mbstring                    x86_64                8.0.30-1.el9_2                       appstream                468 k
 php-opcache                     x86_64                8.0.30-1.el9_2                       appstream                509 k
 php-pdo                         x86_64                8.0.30-1.el9_2                       appstream                 81 k
 php-xml                         x86_64                8.0.30-1.el9_2                       appstream                131 k

Transaction Summary
===========================================================================================================================
Install  10 Packages

Total download size: 6.7 M
Installed size: 36 M
Is this ok [y/N]:

 

yum이나 dnf를 이용해서 기본적으로 설치할 수 있는 php의 버전을 확인해보자.

[root@rocky /]# yum module list
Last metadata expiration check: 2:28:46 ago on Wed 09 Oct 2024 01:03:25 PM KST.
Rocky Linux 9 - AppStream
Name          Stream     Profiles                                 Summary
mariadb       10.11      client, galera, server [d]               MariaDB Module
maven         3.8        common [d]                               Java project management and project comprehension tool
nginx         1.22       common [d]                               nginx webserver
nginx         1.24       common [d]                               nginx webserver
nodejs        18         common [d], development, minimal, s2i    Javascript runtime
nodejs        20         common [d], development, minimal, s2i    Javascript runtime
php           8.1 [x]    common [d], devel, minimal               PHP scripting language
php           8.2 [x]    common [d], devel, minimal               PHP scripting language
postgresql    15         client, server [d]                       PostgreSQL server and client module
postgresql    16         client, server [d]                       PostgreSQL server and client module
redis         7          common [d]                               Redis persistent key-value database
ruby          3.1        common [d]                               An interpreter of object-oriented scripting language
ruby          3.3        common [d]                               An interpreter of object-oriented scripting language

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
[root@rocky /]#

 

만약 php 8.2를 설치하고자 한다면 아래와 같이 php 8.2 패키지를 활성화(enable)해야 한다.

[root@rocky /]# dnf module enable php:8.2
Last metadata expiration check: 2:32:47 ago on Wed 09 Oct 2024 01:03:25 PM KST.
Dependencies resolved.
==========================================================================================================================
 Package                      Architecture                Version                      Repository                    Size
==========================================================================================================================
Enabling module streams:
 php                                                      8.2

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

Is this ok [y/N]:

 

혹시 php 8.2보다 상위 버전인 8.3이나 8.4 버전을 설치하려고 한다거나 그보다 낮은 7.4 버전의 설치를 원한다면 아래와 같이 remi 저장소를 추가로 설치해야 한다. Remi's RPM repository의 설치에 대해서는 예전글 CentOS에서 설치하는 방법에 대해서 잠깐 언급했는데 여기서도 그냥 설치하는 방법만 설명한다. -_-; 아래와 같다.

[root@rocky /]# dnf install http://rpms.remirepo.net/enterprise/remi-release-9.rpm
Last metadata expiration check: 2:35:25 ago on Wed 09 Oct 2024 01:03:25 PM KST.
remi-release-9.rpm                                                                         47 kB/s |  30 kB     00:00
Dependencies resolved.
==========================================================================================================================
 Package                      Architecture           Version                           Repository                    Size
==========================================================================================================================
Installing:
 remi-release                 noarch                 9.4-2.el9.remi                    @commandline                  30 k
Installing dependencies:
 epel-release                 noarch                 9-7.el9                           extras                        19 k

Transaction Summary
==========================================================================================================================
Install  2 Packages

Total size: 49 k
Total download size: 19 k
Installed size: 57 k
Is this ok [y/N]:

 

설치를 마쳤다면 아래와 같이 설치가능한 패키지 목록을 다시 한 번 확인해 보자.

[root@rocky /]# dnf module list
Last metadata expiration check: 0:11:54 ago on Wed 09 Oct 2024 03:39:23 PM KST.
Rocky Linux 9 - AppStream
Name         Stream         Profiles                               Summary
mariadb      10.11          client, galera, server [d]             MariaDB Module
maven        3.8            common [d]                             Java project management and project comprehension tool
nginx        1.22           common [d]                             nginx webserver
nginx        1.24           common [d]                             nginx webserver
nodejs       18             common [d], development, minimal, s2i  Javascript runtime
nodejs       20             common [d], development, minimal, s2i  Javascript runtime
php          8.1 [x]        common [d], devel, minimal             PHP scripting language
php          8.2 [x]        common [d], devel, minimal             PHP scripting language
postgresql   15             client, server [d]                     PostgreSQL server and client module
postgresql   16             client, server [d]                     PostgreSQL server and client module
redis        7              common [d]                             Redis persistent key-value database
ruby         3.1            common [d]                             An interpreter of object-oriented scripting language
ruby         3.3            common [d]                             An interpreter of object-oriented scripting language

Remi's Modular repository for Enterprise Linux 9 - x86_64
Name         Stream         Profiles                               Summary
composer     2              common [d]                             Dependency Manager for PHP
memcached    remi           common [d]                             High Performance, Distributed Memory Object Cache
php          remi-7.4 [x]   common [d], devel, minimal             PHP scripting language
php          remi-8.0 [x]   common [d], devel, minimal             PHP scripting language
php          remi-8.1 [x]   common [d], devel, minimal             PHP scripting language
php          remi-8.2 [x]   common [d], devel, minimal             PHP scripting language
php          remi-8.3 [x]   common [d], devel, minimal             PHP scripting language
php          remi-8.4 [x]   common [d], devel, minimal             PHP scripting language
redis        remi-5.0       common [d]                             Redis persistent key-value database
redis        remi-6.0       common [d]                             Redis persistent key-value database
redis        remi-6.2       common [d]                             Redis persistent key-value database
redis        remi-7.0       common [d]                             Redis persistent key-value database
redis        remi-7.2       common [d]                             Redis persistent key-value database

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

 

위의 목록에서 [x]로 표시된 것들은 활성화가 안되어 있다는 표시이다. 따라서 이 상태에서 dnf(yum) install php라고 입력하면 여전히 php 8.0.30버전이 설치될 것이다. 8.2를 설치하고자 한다면 Rocky Linux의 AppStream에서 선택할 수 도 있고, Remi에서 선택할 수 도 있다. 프로그램(패키지, 모듈)의 선택은 아래와 같이 dnf(yum)의 명령으로 설정할 수 있다.

[root@rocky /]# dnf module enable php:8.2
[or]
[root@rocky /]# dnf module enable php:remi-8.4

잘은 모르겠지만 php 8.x 는 버전이 높아지면서 새로운 함수나 속성등이 추가된 것이기 때문에 추가된 기능을 사용할 것이 아니라면 어떤 버전이든지 크게 문제되지는 않을 것 같다. 그래서 8.4를 설치해 보려고 한다. 아래와 같다.

[root@rocky /]# dnf module enable php:remi-8.4
Last metadata expiration check: 0:26:02 ago on Wed 09 Oct 2024 03:39:23 PM KST.
Dependencies resolved.
==========================================================================================================================
 Package                      Architecture                Version                      Repository                    Size
==========================================================================================================================
Enabling module streams:
 php                                                      remi-8.4

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

Is this ok [y/N]: y
Complete!
[root@rocky /]# dnf module list
Last metadata expiration check: 0:26:19 ago on Wed 09 Oct 2024 03:39:23 PM KST.
Rocky Linux 9 - AppStream
Name         Stream         Profiles                               Summary
mariadb      10.11          client, galera, server [d]             MariaDB Module
maven        3.8            common [d]                             Java project management and project comprehension tool
nginx        1.22           common [d]                             nginx webserver
nginx        1.24           common [d]                             nginx webserver
nodejs       18             common [d], development, minimal, s2i  Javascript runtime
nodejs       20             common [d], development, minimal, s2i  Javascript runtime
php          8.1            common [d], devel, minimal             PHP scripting language
php          8.2            common [d], devel, minimal             PHP scripting language
postgresql   15             client, server [d]                     PostgreSQL server and client module
postgresql   16             client, server [d]                     PostgreSQL server and client module
redis        7              common [d]                             Redis persistent key-value database
ruby         3.1            common [d]                             An interpreter of object-oriented scripting language
ruby         3.3            common [d]                             An interpreter of object-oriented scripting language

Remi's Modular repository for Enterprise Linux 9 - x86_64
Name         Stream         Profiles                               Summary
composer     2              common [d]                             Dependency Manager for PHP
memcached    remi           common [d]                             High Performance, Distributed Memory Object Cache
php          remi-7.4       common [d], devel, minimal             PHP scripting language
php          remi-8.0       common [d], devel, minimal             PHP scripting language
php          remi-8.1       common [d], devel, minimal             PHP scripting language
php          remi-8.2       common [d], devel, minimal             PHP scripting language
php          remi-8.3       common [d], devel, minimal             PHP scripting language
php          remi-8.4 [e]   common [d], devel, minimal             PHP scripting language
redis        remi-5.0       common [d]                             Redis persistent key-value database
redis        remi-6.0       common [d]                             Redis persistent key-value database
redis        remi-6.2       common [d]                             Redis persistent key-value database
redis        remi-7.0       common [d]                             Redis persistent key-value database
redis        remi-7.2       common [d]                             Redis persistent key-value database

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
[root@rocky /]#

 

만약 다른 버전을 설치하고자 한다면 선택한 모듈을 비활성화(disable)한 후에 설치하려는 모듈을 활성화고 설치를 시도하면 된다. 위와 같이 8.4버전이 활성화 되었으므로 바로 설치를 시작해보자. 아래와 같다.

[root@rocky /]# dnf install php
Last metadata expiration check: 0:28:45 ago on Wed 09 Oct 2024 03:39:23 PM KST.
Dependencies resolved.
==========================================================================================================================
 Package                        Architecture         Version                             Repository                  Size
==========================================================================================================================
Installing:
 php                            x86_64               8.4.0~rc2-1.el9.remi                remi-modular               1.9 M
Installing dependencies:
 capstone                       x86_64               4.0.2-10.el9                        appstream                  766 k
 libsodium                      x86_64               1.0.18-8.el9                        epel                       161 k
 libxslt                        x86_64               1.1.34-9.el9                        appstream                  240 k
 oniguruma5php                  x86_64               6.9.9-1.el9.remi                    remi-safe                  219 k
 php-common                     x86_64               8.4.0~rc2-1.el9.remi                remi-modular               749 k
Installing weak dependencies:
 nginx-filesystem               noarch               1:1.20.1-16.el9_4.1                 appstream                  8.1 k
 php-cli                        x86_64               8.4.0~rc2-1.el9.remi                remi-modular               3.8 M
 php-fpm                        x86_64               8.4.0~rc2-1.el9.remi                remi-modular               2.0 M
 php-mbstring                   x86_64               8.4.0~rc2-1.el9.remi                remi-modular               536 k
 php-opcache                    x86_64               8.4.0~rc2-1.el9.remi                remi-modular               484 k
 php-pdo                        x86_64               8.4.0~rc2-1.el9.remi                remi-modular                97 k
 php-sodium                     x86_64               8.4.0~rc2-1.el9.remi                remi-modular                44 k
 php-xml                        x86_64               8.4.0~rc2-1.el9.remi                remi-modular               921 k

Transaction Summary
==========================================================================================================================
Install  14 Packages

Total download size: 12 M
Installed size: 59 M
Is this ok [y/N]: y
Downloading Packages:
(1/14): libsodium-1.0.18-8.el9.x86_64.rpm                                                 2.9 MB/s | 161 kB     00:00
(2/14): php-common-8.4.0~rc2-1.el9.remi.x86_64.rpm                                        392 kB/s | 749 kB     00:01
(3/14): php-8.4.0~rc2-1.el9.remi.x86_64.rpm                                               902 kB/s | 1.9 MB     00:02
(4/14): php-mbstring-8.4.0~rc2-1.el9.remi.x86_64.rpm                                      2.2 MB/s | 536 kB     00:00
(5/14): php-fpm-8.4.0~rc2-1.el9.remi.x86_64.rpm                                           3.8 MB/s | 2.0 MB     00:00
(6/14): php-opcache-8.4.0~rc2-1.el9.remi.x86_64.rpm                                       2.0 MB/s | 484 kB     00:00
(7/14): php-pdo-8.4.0~rc2-1.el9.remi.x86_64.rpm                                           439 kB/s |  97 kB     00:00
(8/14): php-cli-8.4.0~rc2-1.el9.remi.x86_64.rpm                                           1.4 MB/s | 3.8 MB     00:02
(9/14): php-sodium-8.4.0~rc2-1.el9.remi.x86_64.rpm                                        203 kB/s |  44 kB     00:00
(10/14): php-xml-8.4.0~rc2-1.el9.remi.x86_64.rpm                                          3.5 MB/s | 921 kB     00:00
(11/14): oniguruma5php-6.9.9-1.el9.remi.x86_64.rpm                                        976 kB/s | 219 kB     00:00
(12/14): nginx-filesystem-1.20.1-16.el9_4.1.noarch.rpm                                    9.9 kB/s | 8.1 kB     00:00
(13/14): libxslt-1.1.34-9.el9.x86_64.rpm                                                  149 kB/s | 240 kB     00:01
(14/14): capstone-4.0.2-10.el9.x86_64.rpm                                                 427 kB/s | 766 kB     00:01
--------------------------------------------------------------------------------------------------------------------------
Total                                                                                     1.5 MB/s |  12 MB     00:07
Extra Packages for Enterprise Linux 9 - x86_64                                            1.6 MB/s | 1.6 kB     00:00
Importing GPG key 0x3228467C:
 Userid     : "Fedora (epel9) <epel@fedoraproject.org>"
 Fingerprint: FF8A D134 4597 106E CE81 3B91 8A38 72BF 3228 467C
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-9
Is this ok [y/N]: y
Key imported successfully
Remi's Modular repository for Enterprise Linux 9 - x86_64                                 3.0 MB/s | 3.1 kB     00:00
Importing GPG key 0x478F8947:
 Userid     : "Remi's RPM repository (https://rpms.remirepo.net/) <remi@remirepo.net>"
 Fingerprint: B1AB F71E 14C9 D748 97E1 98A8 B195 27F1 478F 8947
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el9
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
  Running scriptlet: php-common-8.4.0~rc2-1.el9.remi.x86_64                                                          1/14
  Installing       : php-common-8.4.0~rc2-1.el9.remi.x86_64                                                          1/14
  Installing       : php-cli-8.4.0~rc2-1.el9.remi.x86_64                                                             2/14
  Installing       : php-pdo-8.4.0~rc2-1.el9.remi.x86_64                                                             3/14
  Installing       : capstone-4.0.2-10.el9.x86_64                                                                    4/14
  Installing       : php-opcache-8.4.0~rc2-1.el9.remi.x86_64                                                         5/14
  Installing       : libxslt-1.1.34-9.el9.x86_64                                                                     6/14
  Installing       : php-xml-8.4.0~rc2-1.el9.remi.x86_64                                                             7/14
  Running scriptlet: nginx-filesystem-1:1.20.1-16.el9_4.1.noarch                                                     8/14
  Installing       : nginx-filesystem-1:1.20.1-16.el9_4.1.noarch                                                     8/14
  Installing       : php-fpm-8.4.0~rc2-1.el9.remi.x86_64                                                             9/14
  Running scriptlet: php-fpm-8.4.0~rc2-1.el9.remi.x86_64                                                             9/14
  Installing       : oniguruma5php-6.9.9-1.el9.remi.x86_64                                                          10/14
  Installing       : php-mbstring-8.4.0~rc2-1.el9.remi.x86_64                                                       11/14
  Installing       : libsodium-1.0.18-8.el9.x86_64                                                                  12/14
  Installing       : php-sodium-8.4.0~rc2-1.el9.remi.x86_64                                                         13/14
  Installing       : php-8.4.0~rc2-1.el9.remi.x86_64                                                                14/14
  Running scriptlet: php-8.4.0~rc2-1.el9.remi.x86_64                                                                14/14
  Verifying        : libsodium-1.0.18-8.el9.x86_64                                                                   1/14
  Verifying        : php-8.4.0~rc2-1.el9.remi.x86_64                                                                 2/14
  Verifying        : php-cli-8.4.0~rc2-1.el9.remi.x86_64                                                             3/14
  Verifying        : php-common-8.4.0~rc2-1.el9.remi.x86_64                                                          4/14
  Verifying        : php-fpm-8.4.0~rc2-1.el9.remi.x86_64                                                             5/14
  Verifying        : php-mbstring-8.4.0~rc2-1.el9.remi.x86_64                                                        6/14
  Verifying        : php-opcache-8.4.0~rc2-1.el9.remi.x86_64                                                         7/14
  Verifying        : php-pdo-8.4.0~rc2-1.el9.remi.x86_64                                                             8/14
  Verifying        : php-sodium-8.4.0~rc2-1.el9.remi.x86_64                                                          9/14
  Verifying        : php-xml-8.4.0~rc2-1.el9.remi.x86_64                                                            10/14
  Verifying        : oniguruma5php-6.9.9-1.el9.remi.x86_64                                                          11/14
  Verifying        : nginx-filesystem-1:1.20.1-16.el9_4.1.noarch                                                    12/14
  Verifying        : libxslt-1.1.34-9.el9.x86_64                                                                    13/14
  Verifying        : capstone-4.0.2-10.el9.x86_64                                                                   14/14

Installed:
  capstone-4.0.2-10.el9.x86_64                libsodium-1.0.18-8.el9.x86_64           libxslt-1.1.34-9.el9.x86_64
  nginx-filesystem-1:1.20.1-16.el9_4.1.noarch oniguruma5php-6.9.9-1.el9.remi.x86_64   php-8.4.0~rc2-1.el9.remi.x86_64
  php-cli-8.4.0~rc2-1.el9.remi.x86_64         php-common-8.4.0~rc2-1.el9.remi.x86_64  php-fpm-8.4.0~rc2-1.el9.remi.x86_64
  php-mbstring-8.4.0~rc2-1.el9.remi.x86_64    php-opcache-8.4.0~rc2-1.el9.remi.x86_64 php-pdo-8.4.0~rc2-1.el9.remi.x86_64
  php-sodium-8.4.0~rc2-1.el9.remi.x86_64      php-xml-8.4.0~rc2-1.el9.remi.x86_64

Complete!
[root@rocky /]# php -v
PHP 8.4.0RC2 (cli) (built: Oct  8 2024 13:57:40) (NTS gcc x86_64)
Copyright (c) The PHP Group
Built by Remi's RPM repository <https://rpms.remirepo.net/> #StandWithUkraine
Zend Engine v4.4.0RC2, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.0RC2, Copyright (c), by Zend Technologies
[root@rocky /]#

별 탈 없이 설치되었다. 원활한 워드프레스의 호스팅을 위해서 아래의 추가 모듈들을 추가로 설치할 것이다.

1. php-mysqlnd
2. php-gd
3. php-ldap
4. php-imap
5. php-imagick
6. php-zip
7. php-intl

혹시 설치가 안되는 것(php-imap, php-imagick)이 있다면 아래의 epel과 certbot을 설치 후에 다시 시도해보자. 추후 워드프레스를 설치한 후에 '사이트 건강'에서 필요한 모듈이 누락되었다는 메시지를 확인하고 설치해도 된다.

그리고 netstat와 ifconfig의 사용을 위해서 net-tools를 설치하자. (# dnf install net-tools)

### varnish cache server와 mail server까지 설정할 수 있을까....??? 얼마나...걸릴까.....[2024-10.09 16:27 임시저장]

 

(10) Virtual Host 설정 (apache)

아파치의 가상호스트 설정은 CentOS에서 사용하던 Apache 2.4.7과 지금 Rocky Linux에 설치한 Apache 2.4.57과의 차이점을 발견하지 못했다. 아직은 설치 후 기본적인 테스트만 진행하고 있기 때문일지도 모르겠지만....워드프레스를 새로 설치해서 사이트를 하나 만들다보면 뭔가 이상한 점이 나올지도 모르겠다. 이미 발견한 (적어도 내게는)치명적인 문제점은  내가 해결할 수 있는 문제는 아닌 듯...하다.

1. /etc/httpd/conf.d/userdir.conf를 열어서 중간정도에 Userdir disabled를 enabled로 수정하고
2. 각 계정별 홈디렉토리를 아래와 같이 설정하자. 워드프레스에서는 .htaccess 파일을 사용하기 때문에 AllowOverride의 옵션을 아래와 같이 주었다.

<Directory "/home/ACCOUNT/*">
    AllowOverride all
    Require all granted
</Directory>

위의 설정을 하지 않으면 403 Forbidden 오류가 발생하는데...가끔 하는 설정이다보니까 까먹기도 한다. -_-; 홈디렉토리에 디렉토리를 하나 만들어두고 퍼미션은 755로 설정하는 것도 잊지 말자. 기본 값이긴 하지만....

여기까지의 설정으로 워드프레스 호스팅이 가능한데.....CentOS 7 을 사용했을 때와 거의 동일하다. CentOS 8부터 기본으로 추가된 DNF는 YUM으로 대체할 수 있으며, DNF(YUM) MODULE은 새로 추가된 듯 하다. 결론적으로 리눅스를 웹서버와 네임서버 등의 용도로 사용하는 나에게는 Rocky Linux나 AlmaLinux와 CentOS와의 차이점을 찾아낼 수는 없었다. 

워드프레스의 '사이트 건강'메뉴에서 ftp 자격 증명에 대한 내용은 이전글을 참고하면 될 것이다. 아래와 같이 해당 계정을 apache 그룹에 포함시킨 후.....

# gpasswd -a ACCOUNT apache

워드프레스가 설치된 최상위 디렉토리는 해당 계정에게 소유권을 주고, wp-config.php의 생성이 끝난 후에 작업 계정을 apache 그룹에 포함시키고나서 파일과 디렉토리의 퍼미션과 소유권을 변경하자. 

[2024-10-10 22:10
# Rocky Linux에서 아직 남아있는 작업 #

 - wordpress 멀티사이트 테스트
 - phpmyadmin의 설치 (사실 거의 사용하지는 않는다)
 - varnish cache server 설정
 - mail server 구축

 

(11) Certbot, SSL, https, Let's Encrypt....

Rocky Linux에서의 certbot 설치는 CentOS 8에서의 방법과 동일하다. 간단하게 아래와 같이 입력해보자. 혹시 설치가 안된다면 아래와 같이 epel-release와 mod_ssl을 먼저 설치한 후에 certbot을 설치하면 된다.

#dnf install epel-release mod_ssl

 

[root@rocky /]# dnf install certbot python3-certbot-apache mod_ssl
Last metadata expiration check: 2:16:38 ago on Fri 11 Oct 2024 12:12:48 PM KST.
Dependencies resolved.
============================================================================================================================
 Package                                 Architecture        Version                           Repository              Size
============================================================================================================================
Installing:
 certbot                                 noarch              2.11.0-1.el9                      epel                    49 k
 mod_ssl                                 x86_64              1:2.4.57-11.el9_4.1               appstream              108 k
 python3-certbot-apache                  noarch              2.11.0-1.el9                      epel                   285 k
Installing dependencies:
 augeas-libs                             x86_64              1.13.0-6.el9_4                    appstream              404 k
 fontawesome-fonts                       noarch              1:4.7.0-13.el9                    appstream              204 k
 python3-acme                            noarch              2.11.0-1.el9                      epel                   159 k
 python3-augeas                          noarch              0.5.0-25.el9                      appstream               27 k
 python3-certbot                         noarch              2.11.0-1.el9                      epel                   685 k
 python3-cffi                            x86_64              1.14.5-5.el9                      baseos                 241 k
 python3-chardet                         noarch              4.0.0-5.el9                       baseos                 209 k
 python3-configargparse                  noarch              1.7-1.el9                         epel                    45 k
 python3-configobj                       noarch              5.0.6-25.el9                      appstream               62 k
 python3-cryptography                    x86_64              36.0.1-4.el9                      baseos                 1.2 M
 python3-idna                            noarch              2.10-7.el9_4.1                    baseos                  97 k
 python3-importlib-metadata              noarch              4.12.0-2.el9                      epel                    43 k
 python3-josepy                          noarch              1.13.0-1.el9                      epel                    60 k
 python3-parsedatetime                   noarch              2.6-5.el9                         epel                    79 k
 python3-pyOpenSSL                       noarch              21.0.0-1.el9                      epel                    90 k
 python3-pycparser                       noarch              2.20-6.el9                        baseos                 124 k
 python3-pyrfc3339                       noarch              1.1-11.el9                        epel                    18 k
 python3-pysocks                         noarch              1.7.1-12.el9                      baseos                  34 k
 python3-pytz                            noarch              2021.1-5.el9                      appstream               47 k
 python3-requests                        noarch              2.25.1-8.el9                      baseos                 113 k
 python3-urllib3                         noarch              1.26.5-5.el9_4.1                  baseos                 187 k
 python3-zipp                            noarch              3.20.1-2.el9                      epel                    26 k
 sscg                                    x86_64              3.0.0-7.el9                       appstream               45 k
Installing weak dependencies:
 python-josepy-doc                       noarch              1.13.0-1.el9                      epel                    19 k

Transaction Summary
============================================================================================================================
Install  27 Packages

Total download size: 4.5 M
Installed size: 19 M
Is this ok [y/N]: y
Downloading Packages:
(1/27): python-josepy-doc-1.13.0-1.el9.noarch.rpm                                           5.6 kB/s |  19 kB     00:03
(2/27): certbot-2.11.0-1.el9.noarch.rpm                                                      13 kB/s |  49 kB     00:03
(3/27): python3-acme-2.11.0-1.el9.noarch.rpm                                                 17 kB/s | 159 kB     00:09
(4/27): python3-configargparse-1.7-1.el9.noarch.rpm                                         6.2 kB/s |  45 kB     00:07
(5/27): python3-importlib-metadata-4.12.0-2.el9.noarch.rpm                                  5.6 kB/s |  43 kB     00:07
(6/27): python3-josepy-1.13.0-1.el9.noarch.rpm                                              5.1 kB/s |  60 kB     00:11
(7/27): python3-certbot-apache-2.11.0-1.el9.noarch.rpm                                      8.6 kB/s | 285 kB     00:33
(8/27): python3-parsedatetime-2.6-5.el9.noarch.rpm                                          3.4 kB/s |  79 kB     00:23
(9/27): python3-pyOpenSSL-21.0.0-1.el9.noarch.rpm                                           3.0 kB/s |  90 kB     00:29
(10/27): python3-pyrfc3339-1.1-11.el9.noarch.rpm                                            1.1 kB/s |  18 kB     00:15
(11/27): python3-idna-2.10-7.el9_4.1.noarch.rpm                                             107 kB/s |  97 kB     00:00
(12/27): python3-chardet-4.0.0-5.el9.noarch.rpm                                             453 kB/s | 209 kB     00:00
(13/27): python3-requests-2.25.1-8.el9.noarch.rpm                                           470 kB/s | 113 kB     00:00
(14/27): python3-urllib3-1.26.5-5.el9_4.1.noarch.rpm                                        805 kB/s | 187 kB     00:00
(15/27): python3-pysocks-1.7.1-12.el9.noarch.rpm                                            150 kB/s |  34 kB     00:00
(16/27): python3-cryptography-36.0.1-4.el9.x86_64.rpm                                       1.7 MB/s | 1.2 MB     00:00
(17/27): python3-cffi-1.14.5-5.el9.x86_64.rpm                                               1.0 MB/s | 241 kB     00:00
(18/27): python3-pycparser-2.20-6.el9.noarch.rpm                                            539 kB/s | 124 kB     00:00
(19/27): python3-certbot-2.11.0-1.el9.noarch.rpm                                            9.1 kB/s | 685 kB     01:15
(20/27): python3-pytz-2021.1-5.el9.noarch.rpm                                                25 kB/s |  47 kB     00:01
(21/27): python3-configobj-5.0.6-25.el9.noarch.rpm                                          163 kB/s |  62 kB     00:00
(22/27): fontawesome-fonts-4.7.0-13.el9.noarch.rpm                                          112 kB/s | 204 kB     00:01
(23/27): python3-zipp-3.20.1-2.el9.noarch.rpm                                               1.9 kB/s |  26 kB     00:13
(24/27): augeas-libs-1.13.0-6.el9_4.x86_64.rpm                                              486 kB/s | 404 kB     00:00
(25/27): python3-augeas-0.5.0-25.el9.noarch.rpm                                              44 kB/s |  27 kB     00:00
(26/27): mod_ssl-2.4.57-11.el9_4.1.x86_64.rpm                                               166 kB/s | 108 kB     00:00
(27/27): sscg-3.0.0-7.el9.x86_64.rpm                                                        185 kB/s |  45 kB     00:00
----------------------------------------------------------------------------------------------------------------------------
Total                                                                                        56 kB/s | 4.5 MB     01:23
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                    1/1
  Installing       : python3-pytz-2021.1-5.el9.noarch                                                                  1/27
  Installing       : python3-pyrfc3339-1.1-11.el9.noarch                                                               2/27
  Installing       : python3-idna-2.10-7.el9_4.1.noarch                                                                3/27
  Installing       : sscg-3.0.0-7.el9.x86_64                                                                           4/27
  Installing       : mod_ssl-1:2.4.57-11.el9_4.1.x86_64                                                                5/27
  Installing       : augeas-libs-1.13.0-6.el9_4.x86_64                                                                 6/27
  Installing       : python3-augeas-0.5.0-25.el9.noarch                                                                7/27
  Installing       : python3-configobj-5.0.6-25.el9.noarch                                                             8/27
  Installing       : fontawesome-fonts-1:4.7.0-13.el9.noarch                                                           9/27
  Installing       : python3-pycparser-2.20-6.el9.noarch                                                              10/27
  Installing       : python3-cffi-1.14.5-5.el9.x86_64                                                                 11/27
  Installing       : python3-cryptography-36.0.1-4.el9.x86_64                                                         12/27
  Installing       : python3-pyOpenSSL-21.0.0-1.el9.noarch                                                            13/27
  Installing       : python3-pysocks-1.7.1-12.el9.noarch                                                              14/27
  Installing       : python3-urllib3-1.26.5-5.el9_4.1.noarch                                                          15/27
  Installing       : python3-chardet-4.0.0-5.el9.noarch                                                               16/27
  Installing       : python3-requests-2.25.1-8.el9.noarch                                                             17/27
  Installing       : python3-zipp-3.20.1-2.el9.noarch                                                                 18/27
  Installing       : python3-importlib-metadata-4.12.0-2.el9.noarch                                                   19/27
  Installing       : python3-parsedatetime-2.6-5.el9.noarch                                                           20/27
  Installing       : python3-configargparse-1.7-1.el9.noarch                                                          21/27
  Installing       : python-josepy-doc-1.13.0-1.el9.noarch                                                            22/27
  Installing       : python3-josepy-1.13.0-1.el9.noarch                                                               23/27
  Installing       : python3-acme-2.11.0-1.el9.noarch                                                                 24/27
  Installing       : python3-certbot-2.11.0-1.el9.noarch                                                              25/27
  Installing       : certbot-2.11.0-1.el9.noarch                                                                      26/27
  Running scriptlet: certbot-2.11.0-1.el9.noarch                                                                      26/27
Created symlink /etc/systemd/system/timers.target.wants/certbot-renew.timer → /usr/lib/systemd/system/certbot-renew.timer.

Certbot auto renewal timer is not started by default.
Run 'systemctl start certbot-renew.timer' to enable automatic renewals.

  Installing       : python3-certbot-apache-2.11.0-1.el9.noarch                                                       27/27
  Running scriptlet: python3-certbot-apache-2.11.0-1.el9.noarch                                                       27/27
  Verifying        : certbot-2.11.0-1.el9.noarch                                                                       1/27
  Verifying        : python-josepy-doc-1.13.0-1.el9.noarch                                                             2/27
  Verifying        : python3-acme-2.11.0-1.el9.noarch                                                                  3/27
  Verifying        : python3-certbot-2.11.0-1.el9.noarch                                                               4/27
  Verifying        : python3-certbot-apache-2.11.0-1.el9.noarch                                                        5/27
  Verifying        : python3-configargparse-1.7-1.el9.noarch                                                           6/27
  Verifying        : python3-importlib-metadata-4.12.0-2.el9.noarch                                                    7/27
  Verifying        : python3-josepy-1.13.0-1.el9.noarch                                                                8/27
  Verifying        : python3-parsedatetime-2.6-5.el9.noarch                                                            9/27
  Verifying        : python3-pyOpenSSL-21.0.0-1.el9.noarch                                                            10/27
  Verifying        : python3-pyrfc3339-1.1-11.el9.noarch                                                              11/27
  Verifying        : python3-zipp-3.20.1-2.el9.noarch                                                                 12/27
  Verifying        : python3-idna-2.10-7.el9_4.1.noarch                                                               13/27
  Verifying        : python3-chardet-4.0.0-5.el9.noarch                                                               14/27
  Verifying        : python3-requests-2.25.1-8.el9.noarch                                                             15/27
  Verifying        : python3-urllib3-1.26.5-5.el9_4.1.noarch                                                          16/27
  Verifying        : python3-pysocks-1.7.1-12.el9.noarch                                                              17/27
  Verifying        : python3-cryptography-36.0.1-4.el9.x86_64                                                         18/27
  Verifying        : python3-cffi-1.14.5-5.el9.x86_64                                                                 19/27
  Verifying        : python3-pycparser-2.20-6.el9.noarch                                                              20/27
  Verifying        : python3-pytz-2021.1-5.el9.noarch                                                                 21/27
  Verifying        : fontawesome-fonts-1:4.7.0-13.el9.noarch                                                          22/27
  Verifying        : python3-configobj-5.0.6-25.el9.noarch                                                            23/27
  Verifying        : augeas-libs-1.13.0-6.el9_4.x86_64                                                                24/27
  Verifying        : python3-augeas-0.5.0-25.el9.noarch                                                               25/27
  Verifying        : mod_ssl-1:2.4.57-11.el9_4.1.x86_64                                                               26/27
  Verifying        : sscg-3.0.0-7.el9.x86_64                                                                          27/27

Installed:
  augeas-libs-1.13.0-6.el9_4.x86_64                          certbot-2.11.0-1.el9.noarch
  fontawesome-fonts-1:4.7.0-13.el9.noarch                    mod_ssl-1:2.4.57-11.el9_4.1.x86_64
  python-josepy-doc-1.13.0-1.el9.noarch                      python3-acme-2.11.0-1.el9.noarch
  python3-augeas-0.5.0-25.el9.noarch                         python3-certbot-2.11.0-1.el9.noarch
  python3-certbot-apache-2.11.0-1.el9.noarch                 python3-cffi-1.14.5-5.el9.x86_64
  python3-chardet-4.0.0-5.el9.noarch                         python3-configargparse-1.7-1.el9.noarch
  python3-configobj-5.0.6-25.el9.noarch                      python3-cryptography-36.0.1-4.el9.x86_64
  python3-idna-2.10-7.el9_4.1.noarch                         python3-importlib-metadata-4.12.0-2.el9.noarch
  python3-josepy-1.13.0-1.el9.noarch                         python3-parsedatetime-2.6-5.el9.noarch
  python3-pyOpenSSL-21.0.0-1.el9.noarch                      python3-pycparser-2.20-6.el9.noarch
  python3-pyrfc3339-1.1-11.el9.noarch                        python3-pysocks-1.7.1-12.el9.noarch
  python3-pytz-2021.1-5.el9.noarch                           python3-requests-2.25.1-8.el9.noarch
  python3-urllib3-1.26.5-5.el9_4.1.noarch                    python3-zipp-3.20.1-2.el9.noarch
  sscg-3.0.0-7.el9.x86_64

Complete!
[root@rocky /]#

 

설치 후 시험삼아서 특정 도메인에 와일드카드 인증서를 발급받아 보기로 했다. 아래와 같다.

certbot certonly --manual --preferred-challenges=dns --server https://acme-v02.api.letsencrypt.org/directory --agree-tos -d *.subdomain.domain.tld -d subdomain.domain.tld

 

참고로 테스트 했던 도메인은 서브도메인까지 한글로된 도메인이기에 아래와 같이 도메인이름을 puny-code.puny-code로 포현했고, 와일드카드 인증서를 위해서 *.puny-code.puny-code로도 표현했다. 처음 서너번의 시도에서는 마지막 과정에서 오류가 발생했는데 원인을 모르겠다. 기존과는 다르게 e-mail 항목을 수동으로 넣지 않고 생략했는데, 이메일은 묻지도 않고 성공적으로 발급받았다. 네임서버의 설정에서는 아래의 실제 화면과 같이 도메인의 끝에 .을 잊지 말고 넣어야 한다. 또한 TXT 레코드에서는 문자열을 " "으로 감싸주자~.

또한 인증서의 발급과정이(AlmaLinux였다) 정상적으로 끝났음에도 /etc/options-ssl-apache.conf가 생성되지 않아서 기존의 CentOS 7에 있던 파일을 그대로 복해사두었다. 이 파일은 Let's Encrypt의 certbot을 설치할 때에 함께 생성되는 파일 같은데....왜 누락이 됬는지 알 수 가 없다......

# This file contains important security parameters. If you modify this file
# manually, Certbot will be unable to automatically provide future security
# updates. Instead, Certbot will print and log an error message with a path to
# the up-to-date file that you will need to refer to when manually updating
# this file.

SSLEngine on

# Intermediate configuration, tweak to your needs
SSLProtocol             all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLCipherSuite          ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
SSLHonorCipherOrder     off

SSLOptions +StrictRequire

# Add vhost name to log entries:
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" vhost_combined
LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost_common

 

[root@rocky named]# certbot certonly --manual --preferred-challenges=dns --server https://acme-v02.api.letsencrypt.org/directory --agree-tos -d *.puny-code.puny-code -d puny-code.puny-code
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Requesting a certificate for *.puny-code.puny-code and puny-code.puny-code

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please deploy a DNS TXT record under the name:

_acme-challenge.puny-code.puny-code.

with the following value:

jQSqnZ-Im3bKY1KFgDrsySI2snMOUL307-tII7sV5Cc

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Press Enter to Continue

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please deploy a DNS TXT record under the name:

_acme-challenge.puny-code.puny-code.

with the following value:

a-LTLD2_gfw5816edVQYbiUj-R5rGO8otc019qPa5MQ

(This must be set up in addition to the previous challenges; do not remove,
replace, or undo the previous challenge tasks yet. Note that you might be
asked to create multiple distinct TXT records with the same name. This is
permitted by DNS standards.)

Before continuing, verify the TXT record has been deployed. Depending on the DNS
provider, this may take some time, from a few seconds to multiple minutes. You can
check if it has finished deploying with aid of online tools, such as the Google
Admin Toolbox: https://toolbox.googleapps.com/apps/dig/#TXT/_acme-challenge.puny-code.puny-code.
Look for one or more bolded line(s) below the line ';ANSWER'. It should show the
value(s) you've just added.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Press Enter to Continue

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/puny-code.puny-code./fullchain.pem
Key is saved at:         /etc/letsencrypt/live/puny-code.puny-code./privkey.pem
This certificate expires on 2025-01-09.
These files will be updated when the certificate renews.

NEXT STEPS:
- This certificate will not be renewed automatically. Autorenewal of --manual certificates requires the use of an authentication hook script (--manual-auth-hook) but one was not provided. To renew this certificate, repeat this same certbot command before the certificate's expiry date.
We were unable to subscribe you the EFF mailing list. You can try again later by visiting https://act.eff.org.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[root@rocky named]#

이번(?)에도 역시 자동인증이 아닌 메뉴얼 인증이 요구되는 와일드카드 인증서는 자동갱신이 되지 않는다. 귀찮더라도 3개월에 한 번씩 수동으로 이 작업을 반복해야 한다. 아니면 Let's Encrypt에서는 제공하지는 않지만 스스로 스크립트를 만들어야 할 지도 모르겠다...

Let's Encrypt에서 와일드카드 SSL 인증서 발급까지 마쳤으니, 이제는 워드프레스 멀티사이트와 phpmyadmin을 설치해 보고, 특별한 것이 없다면 정리하지는 않을 것이다....

 

(12) mod_security 설치

mod_security의 설치는 이전글과 다를것이 없다.

728x90
반응형

댓글