웹사이트 검색

Ubuntu 20.04에 Polr URL Shortener를 설치하는 방법


이 페이지에서

  1. 전제 조건
  2. 시작하기\n
  3. Apache, MariaDB 및 PHP 설치
  4. Polr용 데이터베이스 만들기
  5. 작성기 설치
  6. 폴러 설치
  7. Polr용 Apache 구성
  8. Polr 웹 인터페이스 액세스
  9. Lets Encrypt Free SSL을 통한 안전한 Polr\n
  10. 결론

Polr은 PHP로 작성된 무료 오픈 소스 URL 단축기입니다. 링크를 만들고 관리할 수 있는 간단하고 사용자 친화적인 인터페이스를 제공합니다. 고유한 URL 단축기를 호스팅하고, URL을 브랜딩하고, 데이터를 제어할 수 있습니다. 강력한 API, URL 전달, 사용자 정의 권한, 테마 등을 포함한 수많은 기능을 제공합니다.

이 게시물에서는 Ubuntu 20.04에서 Apache와 Lets Encrypt SSL을 사용하여 Polr을 설치하는 방법을 보여줍니다.

전제 조건

  • Ubuntu 20.04를 실행하는 서버.\n
  • 서버 IP를 가리키는 유효한 도메인 이름입니다.\n
  • 루트 암호는 서버에서 구성됩니다.\n

시작하기

먼저 다음 명령을 실행하여 시스템 패키지를 업데이트된 버전으로 업데이트합니다.

apt-get update -y

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

Apache, MariaDB 및 PHP 설치

먼저 Apache 서버, MariaDB 데이터베이스, PHP 및 기타 PHP 확장을 서버에 설치해야 합니다. 다음 명령으로 모두 설치할 수 있습니다.

apt-get install apache2 mariadb-server php libapache2-mod-php libapache2-mod-wsgi php-gd php-curl php-xml php-xmlrpc php-curl php-imagick php-mbstring php-zip php-intl -y

모든 패키지가 설치되면 다음 단계로 진행할 수 있습니다.

Polr용 데이터베이스 생성

Polr는 MariaDB/MySQL을 데이터베이스 백엔드로 사용합니다. 따라서 Polr에 대한 데이터베이스와 사용자를 생성해야 합니다.

먼저 다음 명령을 사용하여 MariaDB에 로그인합니다.

mysql

로그인한 후 다음 명령을 사용하여 데이터베이스와 사용자를 생성합니다.

MariaDB [(none)]> CREATE DATABASE polrdb;
MariaDB [(none)]> GRANT ALL ON polrdb.* TO 'polr' IDENTIFIED BY 'password';

다음으로 다음 명령을 사용하여 권한을 플러시하고 MariaDB를 종료합니다.

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

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

작곡가 설치

다음으로 Polr에 필요한 PHP 종속성을 설치하려면 서버에 Composer를 설치해야 합니다.

Composer를 설치하려면 다음 명령을 실행하십시오.

curl -sS https://getcomposer.org/installer | php

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

All settings correct for using Composer
Downloading...

Composer (version 2.1.3) successfully installed to: /root/composer.phar
Use it: php composer.phar

그런 다음 다음 명령을 사용하여 Composer 바이너리를 시스템 위치로 이동합니다.

mv composer.phar /usr/local/bin/composer

다음으로 다음 명령을 사용하여 Composer 버전을 확인합니다.

composer -V

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

Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? yes
Composer version 2.1.3 2021-06-09 16:31:20

폴러 설치

다음으로 Git 저장소에서 최신 버전의 Polr을 다운로드해야 합니다. 다음 명령으로 다운로드할 수 있습니다.

git clone https://github.com/cydrobolt/polr.git --depth=1 /var/www/html/polr

다운로드가 완료되면 디렉터리를 Polr로 변경하고 다음 명령을 사용하여 필요한 모든 종속성을 설치합니다.

cd /var/www/html/polr
composer install --no-dev -o

그런 다음 다음 명령을 사용하여 샘플 환경 파일을 복사합니다.

cp .env.setup .env

다음으로 다음 명령을 사용하여 Polr 디렉터리에 적절한 권한을 설정합니다.

chown -R www-data:www-data /var/www/html/polr
chmod -R 755 /var/www/html/polr

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

Polr용 Apache 구성

다음으로 Polr에 대한 Apache 가상 호스트 구성 파일을 만들어야 합니다. 다음 명령으로 만들 수 있습니다.

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

다음 줄을 추가합니다.

<VirtualHost *:80>
ServerAdmin 
DocumentRoot /var/www/html/polr/public
ServerName polr.example.com
<Directory /var/www/html/polr/public/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/polr-error_log
CustomLog /var/log/apache2/polr-access_log common
</VirtualHost>

파일을 저장하고 닫은 다음 Apache 가상 호스트 파일을 활성화하고 다음 명령을 사용하여 모듈을 다시 작성합니다.

a2enmod rewrite
a2ensite polr.conf

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

systemctl restart 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 Thu 2021-06-17 12:09:42 UTC; 16s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 27602 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 27617 (apache2)
      Tasks: 6 (limit: 2353)
     Memory: 26.6M
     CGroup: /system.slice/apache2.service
             ??27617 /usr/sbin/apache2 -k start
             ??27618 /usr/sbin/apache2 -k start
             ??27619 /usr/sbin/apache2 -k start
             ??27620 /usr/sbin/apache2 -k start
             ??27621 /usr/sbin/apache2 -k start
             ??27622 /usr/sbin/apache2 -k start

Jun 17 12:09:42 ubunt4 systemd[1]: Starting The Apache HTTP Server...

Polr 웹 인터페이스에 액세스

이제 URL http://polr.example.com을 사용하여 Polr 웹 인터페이스에 액세스할 수 있습니다.

데이터베이스 이름, 사용자 이름, 비밀번호, 애플리케이션 설정, Polr URL, 관리자 사용자 이름, 이메일, 비밀번호를 제공하고 설치 버튼을 클릭합니다. Polr이 설치되면 다음 화면이 나타납니다.

홈 페이지를 클릭하십시오. 다음 화면에 Polr 대시보드가 표시되어야 합니다.

Lets Encrypt Free SSL을 통한 보안 Polr

먼저 도메인용 SSL 인증서를 다운로드하고 설치하려면 Certbot Lets Encrypt 클라이언트를 설치해야 합니다.

다음 명령으로 설치할 수 있습니다.

apt-get install python3-certbot-apache -y

일단 설치되면 다음 명령을 실행하여 도메인 polr.example.com에 대한 Lets Encrypt 인증서를 설치할 수 있습니다.

certbot --apache -d polr.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): 

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

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 키를 눌러 도메인용 무료 SSL 인증서를 다운로드하고 설치합니다. 일단 설치가 성공적으로 완료되었습니다. 다음 출력이 표시되어야 합니다.

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

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

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

귀하의 Polr 웹사이트는 이제 Lets Encrypt 무료 SSL로 보호됩니다. URL https://polr.example.com을 사용하여 액세스할 수 있습니다.

결론

위 가이드에서는 Ubuntu 20.04 서버에서 Apache와 Lets Encrypt SSL을 사용하여 Polr을 설치하는 방법을 배웠습니다. 이제 Polr을 사용하여 자신의 링크 단축기를 호스트할 수 있습니다. 궁금한 점이 있으면 언제든지 문의해 주세요.