웹사이트 검색

Apache와 함께 DokuWiki를 설치하고 Ubuntu 22.04에서 SSL을 암호화하는 방법


DokuWiki는 웹 브라우저에서 웹사이트를 생성하고 편집할 수 있는 간단하고 가벼운 무료 오픈 소스 위키 소프트웨어입니다. 데이터베이스 대신 파일에 데이터를 저장하는 PHP로 작성된 강력한 애플리케이션입니다. 여기에는 웹사이트를 쉽게 확장하고 최적화할 수 있는 다양한 기능이 내장되어 있습니다. 깔끔하고 읽기 쉬운 구문, 쉬운 유지 관리, 데이터 백업 및 통합으로 인해 점점 더 인기를 얻고 있습니다.

이 문서에서는 Apache와 함께 DokuWiki를 설치하는 방법과 Ubuntu 22.04에서 SSL을 암호화하도록 하겠습니다.

요구사항

  • Ubuntu 22.04를 실행하는 서버.
  • 유효한 도메인 이름은 서버의 IP로 연결됩니다.
  • 루트 비밀번호는 서버에 구성되어 있습니다.

첫 번째 단계

시작하기 전에 모든 시스템 패키지를 최신 버전으로 업데이트하고 업그레이드해야 합니다. 다음 명령을 실행하여 업데이트할 수 있습니다.

apt update -y
apt upgrade -y

모든 패키지가 업데이트되면 다음 단계로 진행할 수 있습니다.

아파치와 PHP를 설치하세요

먼저 서버에 Apache, PHP 및 기타 필수 확장을 설치해야 합니다. 다음 명령을 실행하여 설치할 수 있습니다.

apt-get install apache2 mariadb-server php libapache2-mod-php php-common php-imap php-mbstring php-xmlrpc php-soap php-gd php-xml php-intl php-mysql php-cli php-bcmath php-ldap php-zip php-curl unzip curl -y

모든 패키지가 설치되면 Apache 서비스를 시작하고 시스템 재부팅 시 시작되도록 활성화합니다.

systemctl start apache2
systemctl enable apache2

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

Ubuntu 22.04에 DokuWiki 설치

다음으로, DokuWiki 다운로드 페이지로 이동하여 다음 명령을 사용하여 DokuWiki의 최신 버전을 다운로드하세요:

wget https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz

다운로드가 완료되면 Apache 웹 루트 디렉터리 내에 DokuWiki용 디렉터리를 만듭니다.

mkdir /var/www/html/dokuwiki

다음 명령을 사용하여 다운로드한 파일을 DokuWiki 디렉터리에 압축을 풉니다:

tar -xvzf dokuwiki-stable.tgz -C /var/www/html/dokuwiki/ --strip-components=1

그런 다음 다음 명령을 사용하여 필요한 일부 파일을 복사합니다.

cp /var/www/html/dokuwiki/.htaccess{.dist,}

다음으로, DokuWiki 디렉토리에 대한 소유권을 설정해야 합니다:

chown -R www-data:www-data /var/www/html/dokuwiki

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

DokuWiki용 Apache 구성

다음으로, DokuWiki를 호스팅하기 위한 Apache 가상 호스트에 대한 구성 파일을 생성해야 합니다. 다음 명령을 사용하여 생성할 수 있습니다.

nano /etc/apache2/sites-available/dokuwiki.conf

다음 줄을 붙여넣으세요.

<VirtualHost *:80>
        ServerName    dokuwiki.example.com      
        DocumentRoot  /var/www/html/dokuwiki

        <Directory ~ "/var/www/html/dokuwiki/(bin/|conf/|data/|inc/)">
            <IfModule mod_authz_core.c>
                AllowOverride All
                Require all denied
            </IfModule>
            <IfModule !mod_authz_core.c>
                Order allow,deny
                Deny from all
            </IfModule>
        </Directory>

        ErrorLog   /var/log/apache2/dokuwiki_error.log
        CustomLog  /var/log/apache2/dokuwiki_access.log combined
</VirtualHost>

파일을 저장하고 닫은 후 다음 명령을 사용하여 Apache 가상 호스트에 대한 구성 파일을 활성화합니다.

a2ensite dokuwiki.conf

그런 다음 변경 사항이 적용되도록 Apache 서비스를 다시 로드합니다.

systemctl reload apache2

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

systemctl status apache2

다음과 같은 결과가 출력됩니다.

? apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2022-11-12 13:55:11 UTC; 13s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 16193 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 16197 (apache2)
      Tasks: 6 (limit: 464122)
     Memory: 14.2M
     CGroup: /system.slice/apache2.service
             ??16197 /usr/sbin/apache2 -k start
             ??16198 /usr/sbin/apache2 -k start
             ??16199 /usr/sbin/apache2 -k start
             ??16200 /usr/sbin/apache2 -k start
             ??16201 /usr/sbin/apache2 -k start
             ??16202 /usr/sbin/apache2 -k start

Nov 12 13:55:10 ubuntu22041 systemd[1]: Starting The Apache HTTP Server...

DokuWiki에서 SSL 활성화

Let's Encrypt SSL 인증서로 위키 사이트를 보호하는 것은 좋은 생각입니다. 이를 위해서는 시스템에 Certbot 클라이언트를 설치해야 합니다.

다음 명령을 사용하여 Certbot을 설치할 수 있습니다.

apt-get install certbot python3-certbot-apache -y

Certbot 클라이언트가 성공적으로 설치되면 다음 명령을 실행하여 웹 사이트에 대한 Let's Encrypt SSL 인증서를 설치합니다.

certbot --apache -d dokuwiki.example.com

유효한 이메일 주소를 입력하고 이용 약관에 동의하라는 메시지가 표시됩니다(아래 참조).

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): [email 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 dokuwiki.example.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/dokuwiki-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/dokuwiki-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/dokuwiki-le-ssl.conf

다음으로, 아래 출력에 표시된 대로 HTTP 트래픽을 HTTPS로 리디렉션할지 아니면 모든 트래픽을 보안 HTTPS 액세스로 리디렉션하도록 Nginx를 구성할지 선택합니다.

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를 눌러 프로세스를 시작하십시오. 설치가 완료되면 다음 출력이 표시됩니다.

Enabled Apache rewrite module
Redirecting vhost in /etc/apache2/sites-enabled/dokuwiki.conf to ssl vhost in /etc/apache2/sites-available/dokuwiki-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://dokuwiki.example.com

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

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

이 시점에서 귀하의 Dokuwiki 웹사이트는 Let's Encrypt SSL로 보호됩니다. 이제 HTTPS 프로토콜을 사용하여 웹사이트에 안전하게 액세스할 수 있습니다.

DokuWiki 웹 인터페이스에 접근하기

이제 웹 브라우저를 열고 https://dokuwiki.example.com/install.php URL을 통해 DokuWiki에 액세스하세요. DokuWiki 설치 화면이 나타납니다:

위키 이름, 관리자 사용자 이름, 비밀번호, 이메일 주소를 입력하고 정책을 선택한 후 저장 버튼을 클릭하세요. 다음 페이지로 리디렉션됩니다.

"새 DokuWiki"를 클릭하세요. 다음 화면이 나타나야 합니다:

'로그인' 버튼을 클릭하세요. DokuWiki 로그인 화면으로 리디렉션됩니다(아래 참조).

관리자 사용자 이름과 비밀번호를 입력하고 로그인 버튼을 클릭하세요. 다음 화면에서 DokuWiki 대시보드를 볼 수 있습니다:

결론

축하해요! DokuWiki를 성공적으로 설치하고 Ubuntu 22.04에서 Let's Encrypt SSL을 사용하여 보안을 설정했습니다. 이제 DokuWiki로 자신만의 위키 사이트를 호스팅할 수 있습니다. 질문이 있으시면 언제든지 저에게 연락해 주세요.

관련기사: