웹사이트 검색

LAMP와 무료 Lets Encrypt SSL을 Rocky Linux에 설치하는 방법


이 페이지에서

  1. 전제 조건
  2. Apache/Httpd 웹 서버 설치
  3. PHP 패키지 설치
  4. MariaDB 서버 설치 및 구성
  5. WordPress용 데이터베이스 및 사용자 생성
  6. 워드프레스 다운로드\n
  7. 워드프레스 설정\n
  8. Rocky Linux에서 httpd mod_ssl 활성화\n
  9. Rocky Linux에서 SSL Letsencrypt 생성
  10. WordPress용 가상 호스트 설정\n
  11. 워드프레스 설치\n
  12. 결론

WordPress는 현재 수백만 명의 사람들이 사용하는 가장 인기 있는 콘텐츠 관리 시스템(CMS) 중 하나입니다. WordPress 프로젝트는 2003년에 CMS "b2/cafelog"의 포크로 시작되었으며 GPLv2 라이센스와 함께 제공되며 무료 오픈 소스 소프트웨어가 됩니다.

현재 인터넷 웹사이트의 34% 이상이 워드프레스를 사용하고 있습니다. WordPress가 인기 있는 이유 중 하나는 단순하고 사용하기 쉽고 유연하기 때문입니다. 수백/수천 개의 플러그인을 통해 WordPress는 간단한 블로깅 엔진, 전자 상거래 웹사이트, 간단한 회사 프로필, 온라인 포럼 커뮤니티 등과 같은 다양한 방식으로 사용될 수 있습니다.

이 가이드에서는 Rocky Linux 8.4에 WordPress CMS를 설치하는 방법을 배웁니다. LAMP 스택(Linux, Apache2/httpd, MySQL/MariaDB 및 PHP) 아래에 WordPress를 설치하게 됩니다.

전제 조건

  • Rocky Linux 서버. 모든 패키지가 최신 버전으로 업데이트되었는지 확인하십시오.\n
  • 루트 권한이 있는 사용자. 이 사용자는 sudo 명령을 통해 루트 권한을 얻습니다.\n

Apache/Httpd 웹 서버 설치

처음에는 Rocky Linux 서버에 Apache 또는 httpd 웹 서버를 설치합니다.

1. 아래의 dnf 명령을 실행하여 httpd 웹 서버를 설치합니다.

sudo dnf install httpd

"y"를 입력하고 "Enter"를 눌러 httpd 패키지를 확인하고 설치하십시오.

2. 설치가 완료되면 다음 명령을 사용하여 httpd 서비스를 활성화하고 시작합니다.

sudo systemctl enable httpd
sudo systemctl start httpd

"systemctl enable" 명령은 부팅할 때마다 서비스가 시작되도록 합니다.

3. 그런 다음 아래 명령을 실행하여 httpd 서비스를 확인합니다.

sudo systemctl status httpd

그러면 아래와 비슷한 결과를 얻을 수 있습니다.

상단 스크린샷에서 볼 수 있듯이 httpd가 활성화되어 실행 중입니다.

PHP 패키지 설치

현재 WordPress CMS를 설치하려면 PHP 7.4 이상이 필요합니다. 이제 remi 저장소에서 PHP 7.4를 설치합니다.

1. 다음 명령을 실행하여 epel 및 remi 리포지토리를 추가합니다.

sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

epel 및 remi 저장소를 추가하려면 "y"를 입력하고 "Enter"를 누르십시오.

설치가 완료되면 다음 명령을 사용하여 epel 및 Remi 리포지토리를 확인합니다.

sudo dnf repolist

리포지토리 목록에 epel 및 remi 리포지토리가 표시됩니다.

2. 다음으로 기본 리포지토리 모듈 PHP를 재설정합니다. 그런 다음 remi 저장소에서 PHP 7.4용 모듈을 활성화합니다.

다음 명령을 실행하여 기본 php 모듈 리포지토리를 재설정합니다.

sudo dnf module reset php

이 과정에서 "y"를 입력하고 "Enter"를 눌러 gpg 키 remi 저장소를 추가합니다.

그런 다음 아래 명령을 실행하여 remi 저장소에서 php 모듈을 활성화하십시오.

sudo dnf module enable php:remi-7.4

"y"를 입력하여 확인하고 "Enter"를 눌러 계속하십시오. 이제 PHP와 WordPress 설치를 위한 모든 확장을 설치할 준비가 되었습니다.

3. 다음 명령을 실행하여 몇 가지 필요한 확장과 함께 php를 설치합니다.

sudo dnf install php php-common php-mysqlnd php-gd php-imagick php-bcmath

설치가 완료되면 다음 단계로 이동합니다.

MariaDB 서버 설치 및 구성

이 단계에서는 MariaDB 데이터베이스 서버를 설치하고 MariaDB 배포를 보호하며 WordPress용 새 데이터베이스 및 사용자를 생성합니다.

1. MariaDB 데이터베이스 서버를 설치하려면 아래 명령을 실행하십시오.

sudo dnf install mariadb mariadb-server

mariadb 설치를 기다립니다.

2. 설치가 완료되면 다음 명령을 사용하여 MariaDB 서비스를 활성화하고 시작합니다.

sudo systemctl enable mariadb
sudo systemctl start mariadb

4. mariadb가 활성화되고 실행될 것입니다. 다음 명령을 실행하여 MariaDB 서비스를 확인합니다.

sudo systemctl status mariadb

mariadb 서비스가 실행 중인 경우 아래와 유사한 출력이 표시됩니다.

5. 다음으로 MariaDB의 루트 암호를 설정하고 일부 기본 구성을 제거하여 MariaDB 배포를 보호해야 합니다. 이를 위해 기본 MariaDB 설치에 포함된 명령줄 도구 mysql_secure_installation을 사용할 수 있습니다.

아래의 "mysql_secure_installation" 명령을 실행합니다.

mysql_secure_installation

처음에는 mariadb 루트 비밀번호를 설정하라는 메시지가 표시됩니다.

강력한 mariadb 루트 암호를 입력하고 반복한 다음 "Enter"를 눌러 계속하십시오.

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

이제 "Y"를 입력하고 "Enter"를 눌러 mariadb 서버에서 기본 익명 사용자를 제거합니다.

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

그런 다음 기본 사용자 루트에 대한 원격 로그인을 비활성화합니다. 계속하려면 "Y"를 입력하고 "Enter"를 누르십시오.

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

"Y"를 다시 입력하여 기본 데이터베이스 "test"를 제거하고 "Enter"를 누르십시오.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

마지막으로 "Y"를 다시 입력하면 모든 테이블 권한을 다시 로드하여 새 구성을 적용할 수 있습니다.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

이제 프로세스가 완료되었으며 다음 출력이 표시됩니다.

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

WordPress용 데이터베이스 및 사용자 생성

1. 아래의 mysql 명령을 사용하여 mariadb 셸에 로그인합니다.

mysql -u root -p

2. 이제 다음 mysql 쿼리를 실행하여 새 데이터베이스 "wordpress_db"를 만듭니다.

CREATE DATABASE wordpress_db;

3. 다음 쿼리를 실행하여 새 데이터베이스 사용자 "wpuser"를 만듭니다. 강력한 비밀번호로 "strongpassword"를 변경하십시오.

CREATE USER  IDENTIFIED BY 'strongpassword';

4. "wpuser" 사용자가 다음 쿼리를 사용하여 "wordpress_db"에 액세스하고 쓸 수 있도록 허용합니다.

GRANT ALL PRIVILEGES ON wordpress_db.* to ;

5. 이제 모든 테이블 권한을 다시 로드하여 새 데이터베이스 구성을 적용합니다.

FLUSH PRIVILEGES;

그런 다음 "quit"를 입력하고 "Enter"를 눌러 mariadb 셸을 종료할 수 있습니다.

워드프레스 다운로드

1. 작업 디렉토리를 "/var/www"로 변경하고 아래와 같이 wget 명령을 사용하여 WordPress 소스 코드를 다운로드합니다.

cd /var/www/
wget https://wordpress.org/latest.tar.gz

2. WordPress 소스 코드 "latest.tar.gz"를 추출하면 새 디렉터리 "wordpress"가 생성되고 "wordpress" 디렉터리의 소유자를 "apache" 사용자로 변경합니다.

tar -xzvf latest.tar.gz
sudo chown -R apache:apache wordpress/

이제 WordPress 설치를 구성할 준비가 되었습니다.

워드프레스 설정

이 단계에서는 WordPress 구성 "wp-config.php"를 편집하고, 데이터베이스 세부 정보를 설정하고, 인증 키와 솔트를 추가합니다(추가 보안 보호를 위해).

1. 먼저 작업 디렉토리를 "/var/www/wordpress"로 변경합니다.

cd /var/www/wordpress/

2. 샘플 구성 "wp-config-sample.php"를 "wp-config.php"에 복사한 다음 nano 편집기를 사용하여 구성 파일을 편집합니다.

cp wp-config-sample.php wp-config.php
nano wp-config.php

3. 데이터베이스 정보로 데이터베이스 세부 정보(DB_NAME, DB_USER 및 DB_PASSWORD)를 변경합니다.

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress_db' );

/** MySQL database username */
define( 'DB_USER', 'wpuser' );

/** MySQL database password */
define( 'DB_PASSWORD', 'strongpassword' );

/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );

/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );

4. 이 링크를 방문하여 인증 키와 솔트를 생성한 다음 구성을 아래와 같이 "wp-config.php" 파일에 붙여넣습니다.

/**#@+
 * Authentication unique keys and salts.
 *
 * Change these to different unique phrases! You can generate these using
 * the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
 *
 * You can change these at any point in time to invalidate all existing cookies.
 * This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define('AUTH_KEY',         'v$4/xyGF7t!^(-Xr~lUKT,1oBxOpxzXPAs)kPE_C%Oc^~^%JN]C-y(k>~Wj+JZRM');
define('SECURE_AUTH_KEY',  'y<|#/jfYs,Y_l;{[`2uNp9SMNH8zNGK[eb&RYqb-+bd<a,Fi<9z9rj2_#=R(5O&s');
define('LOGGED_IN_KEY',    '&U8Z{I~,xV%D>FDq+Qx{@hmv:~G/<+_8fPvQ(m%oR.A)%ZPtp``sZWK! !G6C%UYPrKU{xQJD.<bd45');
/**#@-*/

저장하고 종료하려면 "Ctrl+x"를 누르고 "y"를 입력하십시오.

Rocky Linux에서 httpd mod_ssl 활성화

이 자습서에서는 WordPress를 설치하고 Letsencrypt의 SSL로 보안을 설정합니다. 따라서 Rocky Linux에서 httpd 서버에 대해 mod_ssl을 활성화해야 합니다.

1. 아래의 dnf 명령을 사용하여 "mod_ssl" 패키지를 설치합니다.

sudo dnf install mod_ssl mod_http2

2. 그런 다음 아래의 openssl 명령을 사용하여 localhost에 대한 기본 SSL을 생성합니다.

openssl req -newkey rsa:2048 -nodes -keyout /etc/pki/tls/private/localhost.key -x509 -days 365 -out /etc/pki/tls/certs/localhost.crt

이 인증서는 WordPress 도메인 이름이 아닌 localhost에만 사용되므로 모든 질문에 대해 Enter 키를 누르기만 하면 됩니다.

3. 이제 다음 명령을 실행하여 httpd 웹 서버에서 mod_ssl을 사용할 수 있는지 확인합니다.

apachectl -M | grep ssl

"ssl"과 같은 출력이 있으면 mod_ssl이 활성화된 것입니다. 그렇지 않으면 빈 출력이 표시됩니다.

Rocky Linux에서 SSL Letsencrypt 생성

이 단계에서는 cerbot 도구를 설치하고 WordPress 설치를 위한 SSL 인증서를 생성합니다. webroot 플러그인으로 SSL Letsencrypts를 생성하게 됩니다.

1. 다음 명령을 실행하여 SSL Letsencrypt 생성을 위한 certbot 도구를 설치합니다.

sudo dnf install certbot

설치 과정을 기다립니다.

2. 설치가 완료되면 다음 명령을 사용하여 letsencrypt 인증을 위한 새 디렉토리를 생성합니다.

sudo mkdir -p /var/lib/letsencrypt/.well-known
sudo chgrp apache /var/lib/letsencrypt
sudo chmod g+s /var/lib/letsencrypt

3. 다음으로 작업 디렉토리를 "/etc/httpd/conf.d/"로 변경하고 nano 편집기를 사용하여 새 구성 "well-known.conf"를 만듭니다.

cd /etc/httpd/conf.d/
nano well-known.conf

다음 구성을 추가합니다.

Alias /.well-known/acme-challenge/ "/var/lib/letsencrypt/.well-known/acme-challenge/"
<Directory "/var/lib/letsencrypt/">
    AllowOverride None
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    Require method GET POST OPTIONS
</Directory>

저장하고 종료하려면 "Ctrl+x"를 누르고 "y"를 입력하십시오.

4. 이제 다음 명령을 실행하여 httpd 구성을 확인하고 httpd 서비스를 다시 시작합니다.

apachectl configtest
sudo systemctl restart httpd

오류가 없으면 webroot 플러그인으로 SSL Letsencrypt를 생성할 준비가 된 것입니다.

5. SSL Letsencrypt를 생성하기 전에 도메인 이름이 서버 IP 주소로 확인되는지 확인하십시오. 그런 다음 아래 certbot 명령을 실행하여 webroot 플러그인으로 SSL Letsencrypt를 생성할 수 있습니다. 또한 이메일 주소와 도메인 이름을 자신의 것으로 변경하십시오.

sudo certbot certonly --agree-tos --email www.domain.com

프로세스가 완료되면 "/etc/letsencrypt/live/domain.com/" 디렉터리에서 SSL 인증서를 사용할 수 있습니다.

WordPress용 가상 호스트 설정

이 단계에서는 WordPress에 대한 새로운 apache/httpd 가상 호스트 구성을 추가합니다.

1. 작업 디렉토리를 "/etc/httpd/conf.d"로 변경하고 nano 편집기를 사용하여 새 구성 "wordpress.conf"를 만듭니다.

cd /etc/httpd/conf.d/
nano wordpress.conf

세부 도메인 이름과 SSL 경로 디렉터리를 자신의 것으로 변경하고 구성을 "wordpress.conf" 파일에 붙여넣습니다.

# httpd port 80
<VirtualHost *:80>
  ServerName domain.com
  ServerAlias www.domain.com

  # automatic redirect http to https
  Redirect permanent / https://domain.com/
</VirtualHost>

# httpd port 443/ssl
<VirtualHost *:443>
  ServerName domain.com
  ServerAlias www.domain.com

  # WordPress path directory
  DocumentRoot /var/www/wordpress

  Protocols h2 http:/1.1

  <If "%{HTTP_HOST} == 'www.domain.com'">
    Redirect permanent / https://domain.com/
  </If>
 
  ErrorLog /var/log/httpd/domain.com-error.log
  CustomLog /var/log/httpd/domain.com-access.log combined

  SSLEngine On
  SSLCertificateFile /etc/letsencrypt/live/domain.com/fullchain.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pem
 
  SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
  SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
  SSLCompression off

  <Directory /var/www/wordpress/>
       Options FollowSymlinks
       AllowOverride All
       Require all granted
  </Directory>
 
  <Directory /var/www/wordpress/>
       RewriteEngine on
       RewriteBase /
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteRule ^(.*) index.php [PT,L]
  </Directory>
</VirtualHost>

구성을 저장하고 종료하려면 "Ctrl+x"를 누르고 "Y"를 입력하십시오.

3. 다음으로 다음 명령을 실행하여 httpd 구성을 확인합니다.

sudo apachectl configtest

오류가 없으면 아래 명령을 사용하여 httpd 서비스를 다시 시작하십시오.

sudo systemctl restart httpd

이제 웹 브라우저를 통해 워드프레스를 설치할 준비가 되었습니다.

워드프레스 설치

관련된 모든 서버 구성이 완료되면 웹 브라우저를 통해 WordPress 설치에 액세스할 수 있습니다.

1. 웹 브라우저를 열고 WordPress 설치의 URL 주소를 입력합니다.

이제 보안 HTTPS 연결로 리디렉션되고 다음과 같은 페이지가 표시됩니다.

WordPress 설치 언어를 선택하고 기본값은 "영어(미국)"이며 "계속"을 클릭합니다.

2. 이제 "사이트 제목"을 입력하고 WordPress 설치를 위한 새 사용자 이름, 이메일 및 비밀번호를 입력합니다.

그런 다음 "WordPress 설치" 버튼을 클릭하여 설치를 시작합니다.

3. 설치가 완료되면 다음 페이지가 나타납니다.

계속하려면 로그인 버튼을 클릭하십시오.

4. 이제 WordPress 로그인 페이지로 리디렉션됩니다.

사용자 이름과 암호를 입력한 다음 "로그인"을 클릭하십시오.

5. 그러면 기본 WordPress 색인 페이지가 표시됩니다.

6. 커서를 "내 블로그" 메뉴로 이동하고 "대시보드" 또는 "테마"를 클릭하면 아래와 같은 워드프레스 관리자 대시보드가 나타납니다.

7. WordPress 플러그인을 설치하려면 "플러그인" 메뉴로 커서를 이동하고 새로 추가를 클릭하면 플러그인 페이지로 리디렉션됩니다.

설치하려는 플러그인을 선택하고 "지금 설치"를 클릭한 다음 "활성화" 버튼을 클릭하여 플러그인을 활성화할 수 있습니다.

결론

축하합니다! Rocky Linux 서버에 LAMP Stack이 포함된 WordPress CMS를 성공적으로 설치했습니다. 다음은 이 튜토리얼에서 배운 내용입니다.

  • LAMP 스택 설치
  • MariaDB 배포 보안
  • mysql/mariadb 쉘에서 mysql 데이터베이스 및 사용자 생성
  • certbot webroot 플러그인을 위한 apache/httpd 웹 서버 설정\n
  • SSL Letsencrypt 생성
  • 마지막은 WordPress 설치입니다.

다음 단계에서는 테마를 선택하거나 구입하여 WordPress에 설치할 수 있습니다.