웹사이트 검색

Apache와 함께 WonderCMS를 설치하고 CentOS 8에서 SSL을 암호화하는 방법


이 페이지에서

  1. 전제 조건
  2. Apache 및 PHP 설치
  3. WonderCMS 다운로드
  4. WonderCMS용 Apache 구성
  5. Lets Encrypt SSL로 보안 WonderCMS
  6. 방화벽 및 SELinux 구성\n
  7. WonderCMS에 액세스
  8. 결론

WonderCMS는 간단한 웹사이트와 블로그를 구축하기 위한 무료 오픈 소스의 간단하고 가벼운 콘텐츠 관리 시스템입니다. 플랫 파일 CMS이며 데이터베이스가 필요하지 않습니다. 설치 프로세스는 매우 간단하며 초기 구성이 필요하지 않습니다. WYSIWYG 지원, 유연한 CSS 프레임워크, SEO 친화적 등 다양한 기능을 제공합니다.

이 튜토리얼에서는 CentOS 8에 WonderCMS를 설치하고 Lets Encrypt SSL로 보안하는 방법을 보여줍니다.

전제 조건

  • CentOS 8을 실행하는 서버.\n
  • 서버에 루트 암호가 구성되어 있습니다.\n

아파치와 PHP 설치

먼저 다음 명령을 사용하여 Apache 웹 서버, PHP 및 기타 PHP 확장을 설치합니다.

dnf install httpd php php-mysqlnd php-curl php-opcache php-xml php-xmlrpc php-gd php-mbstring php-zip php-json wget unzip git -y

설치가 완료되면 php.ini 파일을 열고 일부 설정을 변경합니다.

nano /etc/php.ini

요구 사항에 따라 값을 변경하십시오.

memory_limit = 128M
post_max_size = 32M
upload_max_filesize = 16M
max_execution_time = 300
date.timezone = Asia/Kolkata

완료되면 파일을 저장하고 닫습니다. 그런 다음 Apache 서비스를 시작하고 다음 명령을 사용하여 시스템 재부팅 후 시작하도록 다시 시작합니다.

systemctl start httpd
systemctl enable httpd

WonderCMS 다운로드

먼저 Git 저장소에서 최신 버전의 WonderCMS를 다운로드합니다.

cd /var/www/html
git clone https://github.com/robiso/wondercms.git

다운로드가 완료되면 다음 명령을 사용하여 다운로드한 디렉토리에 적절한 권한을 부여하십시오.

chown -R apache:apache /var/www/html/wondercms
chmod -R 775 /var/www/html/wondercms

WonderCMS용 Apache 구성

먼저 다음 명령을 사용하여 WonderCMS용 새 Apache 가상 호스트 구성 파일을 만듭니다.

nano /etc/httpd/conf.d/wondercms.conf

다음 줄을 추가합니다.

<VirtualHost *:80>
  ServerName wonder.linuxbuz.com
  DirectoryIndex index.php
  DocumentRoot /var/www/html/wondercms  
  Redirect /wondercms/loginURL /loginURL

  ErrorLog /var/log/httpd/linuxbuz.com-error.log
  CustomLog /var/log/httpd/linuxbuz.com-access.log combined

  <Directory /var/www/html/wondercms>
      Options FollowSymLinks
      AllowOverride All
      Require all granted
  </Directory>

</VirtualHost>

파일을 저장하고 닫습니다. 그런 다음 다음 명령을 사용하여 Apache 서비스를 다시 시작합니다.

systemctl restart httpd

다음 명령을 사용하여 Apache 서비스의 상태를 확인할 수도 있습니다.

systemctl status httpd

다음 출력이 표시되어야 합니다.

? httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/httpd.service.d
           ??php-fpm.conf
   Active: active (running) since Wed 2020-02-19 08:51:34 EST; 1min 25s ago
     Docs: man:httpd.service(8)
 Main PID: 4716 (httpd)
   Status: "Total requests: 6; Idle/Busy workers 100/0;Requests/sec: 0.0759; Bytes served/sec: 812 B/sec"
    Tasks: 278 (limit: 12558)
   Memory: 43.1M
   CGroup: /system.slice/httpd.service
           ??4716 /usr/sbin/httpd -DFOREGROUND
           ??4718 /usr/sbin/httpd -DFOREGROUND
           ??4719 /usr/sbin/httpd -DFOREGROUND
           ??4720 /usr/sbin/httpd -DFOREGROUND
           ??4721 /usr/sbin/httpd -DFOREGROUND
           ??4935 /usr/sbin/httpd -DFOREGROUND

Feb 19 08:51:34 centos8 systemd[1]: Starting The Apache HTTP Server...

Lets Encrypt SSL로 보안 WonderCMS

다음으로 다음 명령을 사용하여 Certbot Lets Encrypt 클라이언트를 설치합니다.

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

이제 다음 명령을 실행하여 WonderCMS 웹 사이트에 대한 SSL 인증서를 얻고 설치하십시오.

certbot-auto --apache -d wonder.linuxbuz.com

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

참고 : SSL 인증서 관련 오류가 발생하면 Apache 서비스를 다시 시작하고 위 명령을 다시 실행하십시오.

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
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 wonder.linuxbuz.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/wondercms.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/wondercms.conf

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

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

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/wonder.linuxbuz.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/wonder.linuxbuz.com/privkey.pem
   Your cert will expire on 2020-03-23. 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 구성

다음으로 외부 네트워크에서 HTTP 및 HTTPS 서비스를 허용하는 방화벽 규칙을 생성해야 합니다. 다음 명령으로 허용할 수 있습니다.

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

다음으로 WonderCMS용 SELinux를 구성해야 합니다. 다음 명령을 사용하여 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/wondercms

마지막으로 Apache 서비스를 다시 시작하여 변경 사항을 적용합니다.

systemctl restart httpd

WonderCMS에 액세스

이제 웹 브라우저를 열고 URL https://wonder.linuxbuz.com을 입력하십시오. WonderCMS 홈페이지로 리디렉션됩니다.

이제 위 페이지에서 비밀번호를 복사하고 클릭하여 로그인 버튼을 클릭하십시오. 다음 페이지가 표시됩니다.

비밀번호를 붙여넣고 로그인 버튼을 클릭합니다. 다음 페이지가 표시됩니다.

그런 다음 설정 => 보안을 클릭하십시오. 다음 페이지가 표시됩니다.

로그인 URL, 비밀번호를 변경하고 CHANGE PASSWORD 버튼을 클릭합니다.

결론

축하합니다! Lets Encrypt SSL을 사용하여 CentOS 8에 WonderCMS를 성공적으로 설치하고 보호했습니다. 이제 WonderCMS를 사용하여 자신의 블로그와 웹사이트를 쉽게 호스팅할 수 있습니다.