웹사이트 검색

Vanila Forum을 설치하고 CentOS 8에서 Lets Encrypt로 보호하는 방법


이 튜토리얼은 다음 OS 버전에 대해 존재합니다.

  • 센트OS 8
  • 센트OS 7

이 페이지에서

  1. 전제 조건
  2. LEMP 서버 설치
  3. MariaDB 데이터베이스 구성
  4. 바닐라 포럼 다운로드
  5. PHP-FPM 풀 구성\n
  6. 바닐라용 Nginx 구성
  7. Lets Encrypt SSL로 바닐라 보안 유지
  8. SELinux 및 방화벽 구성\n
  9. 바닐라 포럼 액세스
  10. 결론

Vanilla는 자신만의 포럼 사이트를 구축하는 데 사용할 수 있는 유연한 무료 오픈 소스 커뮤니티 포럼 소프트웨어입니다. 몇 분 안에 온라인 커뮤니티를 설정할 수 있도록 도와주는 가벼운 다국어 포럼 솔루션입니다. PHP로 작성되었으며 많은 추가 기능과 테마가 함께 제공됩니다. 프리미엄 기능이 포함되어 있으며 최고의 브랜드에서 고객을 참여시키고 충성도를 높이고 지원 비용을 줄이기 위해 사용합니다.

이 튜토리얼에서는 CentOS 8에 Vanilla 포럼을 설치하고 Lets Encrypt SSL로 보호하는 방법을 배웁니다.

전제 조건

  • CentOS 8을 실행하는 서버.\n
  • 서버에 루트 비밀번호가 설정되어 있습니다.\n

LEMP 서버 설치

먼저 시스템에 Nginx 웹 서버, MariaDB 데이터베이스 서버, PHP 및 기타 필수 PHP 확장을 설치해야 합니다. 다음 명령을 실행하여 모두 설치할 수 있습니다.

dnf install nginx mariadb-server php php php-mysqlnd php-opcache php-xml php-xmlrpc php-gd php-mbstring php-json php-fpm php-curl php-pear php-openssl php-intl unzip -y

모든 패키지를 설치한 후 Nginx, PHP-FPM 및 MariaDB 서비스를 시작하고 다음 명령을 사용하여 시스템 재부팅 후 시작할 수 있도록 활성화합니다.

systemctl start nginx
systemctl start php-fpm
systemctl start mariadb
systemctl enable nginx
systemctl enable php-fpm
systemctl enable mariadb

MariaDB 데이터베이스 구성

시작하기 전에 MariaDB를 보호하는 것이 좋습니다. 다음 스크립트를 사용하여 보안을 유지할 수 있습니다.

mysql_secure_installation

아래와 같이 모든 질문에 답하십시오.

Enter current password for root (enter for none):
Set root password? [Y/n] Y
New password:
Re-enter new password:
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

MariaDB를 보호한 후 다음 명령을 사용하여 MariaDB 셸에 로그인합니다.

mysql -u root -p

다음 명령을 사용하여 MariaDB 루트 암호를 제공하고 Vanilla용 데이터베이스 및 사용자를 생성합니다.

MariaDB [(none)]> CREATE DATABASE vanilladb CHARACTER SET utf8 COLLATE utf8_general_ci;
MariaDB [(none)]> CREATE USER 'vanilla'@'localhost' IDENTIFIED BY 'password';

다음으로 다음 명령을 사용하여 Vanilla 데이터베이스에 대한 모든 권한을 부여합니다.

MariaDB [(none)]> GRANT ALL PRIVILEGES ON vanilladb.* TO 'vanilla'@'localhost';

그런 다음 권한을 플러시하고 다음 명령을 사용하여 MariaDB 셸을 종료합니다.

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

바닐라 포럼 다운로드

다음 명령을 사용하여 공식 웹 사이트에서 Vanilla 포럼의 최신 안정 버전을 다운로드할 수 있습니다.

wget https://open.vanillaforums.com/get/vanilla-core-3.3.zip

다운로드가 완료되면 다음 명령을 사용하여 다운로드한 파일의 압축을 풉니다.

unzip vanilla-core-3.3.zip

다음으로 다음 명령을 사용하여 추출된 디렉터리를 Nginx 웹 루트 디렉터리로 이동합니다.

mv package /var/www/html/vanilla

다음으로 바닐라 디렉토리의 소유권을 Nginx로 변경합니다.

chown -R nginx:nginx /var/www/html/vanilla

완료되면 다음 단계로 진행할 수 있습니다.

PHP-FPM 풀 구성

기본적으로 PHP-FPM은 Apache용으로 구성됩니다. 여기서는 Nginx를 웹서버로 사용하겠습니다. 따라서 Nginx용 PHP-FPM을 구성해야 합니다. /etc/php-fpm.d/www.conf 파일을 편집하면 됩니다.

nano /etc/php-fpm.d/www.conf

다음 줄을 변경합니다.

user = nginx
group = nginx

완료되면 파일을 저장하고 닫습니다. 그런 다음 PHP용 세션 디렉터리를 만들고 소유권을 변경합니다.

mkdir -p /var/lib/php/session
chown -R nginx:nginx /var/lib/php/session

다음으로 PHP-FPM 서비스를 다시 시작하여 변경 사항을 적용합니다.

systemctl restart php-fpm

바닐라용 Nginx 구성

다음으로 Vanilla 포럼을 제공할 새 Nginx 가상 호스트 파일을 만듭니다.

nano /etc/nginx/conf.d/vanilla.conf

다음 줄을 추가합니다.

server {

  listen 80;
  server_name vanilla.linuxbuz.com;
  root /var/www/html/vanilla;
  index index.php;

  location ~* /\.git { deny all; return 403; }
  location /build/ { deny all; return 403; }
  location /cache/ { deny all; return 403; }
  location /cgi-bin/ { deny all; return 403; }
  location /uploads/import/ { deny all; return 403; }
  location /conf/ { deny all; return 403; }
  location /tests/ { deny all; return 403; }
  location /vendor/ { deny all; return 403; }

  location ~* ^/index\.php(/|$) {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    try_files $fastcgi_script_name =404;
    set $path_info $fastcgi_path_info;
    fastcgi_param PATH_INFO $path_info;
    fastcgi_index index.php;
    include fastcgi.conf;
    fastcgi_param SCRIPT_NAME /index.php;
    fastcgi_param SCRIPT_FILENAME $realpath_root/index.php;
    fastcgi_param X_REWRITE 1;
    fastcgi_pass unix:/var/run/php-fpm/www.sock;
  }

  location ~* \.php(/|$) {
    rewrite ^ /index.php$uri last;
  }
  location / {
    try_files $uri $uri/ @vanilla;
  }

  location @vanilla {
    rewrite ^ /index.php$uri last;
  }

}

완료되면 파일을 저장하고 닫습니다. 그런 다음 Nginx 서비스를 다시 시작하여 변경 사항을 적용합니다.

systemctl restart nginx

Lets Encrypt SSL로 보안 바닐라

다음으로 시스템에 Certbot 유틸리티를 설치하여 Vanilla 웹사이트용 Lets Encrypt SSL을 다운로드하고 설치해야 합니다.

다음 명령을 사용하여 Certbot 클라이언트를 설치할 수 있습니다.

wget https://dl.eff.org/certbot-auto
mv certbot-auto /usr/local/bin/certbot-auto
chown root /usr/local/bin/certbot-auto
chmod 0755 /usr/local/bin/certbot-auto

다음으로 다음 명령을 사용하여 Vanilla 웹 사이트에 대한 SSL 인증서를 가져와 설치합니다.

certbot-auto --nginx -d vanilla.linuxbuz.com

위의 명령은 먼저 서버에 필요한 모든 종속성을 설치합니다. 설치가 완료되면 아래와 같이 이메일 주소를 제공하고 서비스 약관에 동의하라는 메시지가 표시됩니다.

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to

cancel): 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y

Obtaining a new certificate
Performing the following challenges:
http-01 challenge for vanilla.linuxbuz.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/vanilla.conf

아래와 같이 HTTP 트래픽을 HTTPS로 리디렉션할지 여부를 선택합니다.

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for

new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

2를 입력하고 Enter를 눌러 계속하십시오. 설치가 성공적으로 완료되면 다음과 같은 결과가 표시됩니다.

Redirecting all traffic on port 80 to ssl in /etc/nginx/conf.d/vanilla.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://vanilla.linuxbuz.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=vanilla.linuxbuz.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/vanilla.linuxbuz.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/vanilla.linuxbuz.com/privkey.pem
   Your cert will expire on 2020-06-11. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot-auto
   again with the "certonly" option. To non-interactively renew *all*
   of your certificates, run "certbot-auto renew"
 - 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

SELinux 및 방화벽 구성

기본적으로 SELinux는 CentOS 8에서 활성화되어 있습니다. 따라서 Vanilla 포럼 웹사이트에 맞게 구성해야 합니다.

다음 명령을 사용하여 SELinux를 구성할 수 있습니다.

setsebool httpd_can_network_connect on -P
chcon -R -u system_u -t httpd_sys_rw_content_t -r object_r /var/www/html/vanilla

그런 다음 다음 명령을 사용하여 방화벽을 통해 포트 80 및 443을 허용합니다.

firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload

완료되면 다음 단계로 진행할 수 있습니다.

액세스 바닐라 포럼

웹 브라우저를 열고 URL https://vanilla.linuxbuz.com을 방문하십시오. 다음 페이지로 리디렉션됩니다.

데이터베이스 세부 정보, 애플리케이션 제목, 이메일, 관리자 사용자 이름, 비밀번호를 제공하고 계속 버튼을 클릭합니다. 설치가 완료되면 다음 페이지에 Vanilla 대시보드가 표시됩니다.

결론

축하합니다! Lets Encrypt SSL을 사용하여 CentOS 8에 Vanilla 포럼을 성공적으로 설치했습니다. 이제 자신의 커뮤니티 포럼 웹사이트를 쉽게 호스팅할 수 있습니다. 궁금한 점이 있으면 언제든지 문의해 주세요.