설치 가이드 · 7 min read · Nov 29, 2025

CentOS 8에 YOURLS 자체 호스팅 URL 단축기 설치하는 방법

YOURLS는 PHP로 작성된 무료, 오픈 소스 및 자체 호스팅 URL 단축기입니다. TinyURL 또는 Bitly와 매우 유사하며, 자신의 URL 단축 서비스를 운영할 수 있게 해줍니다. 또한 짧은 URL에 브랜드를 추가할 수 있습니다. 개인 및 공개 링크, 사용자 정의 URL 키워드, 클릭 기록 보고서, Ajax 인터페이스, Jsonp 지원 등 다양한 기능을 제공합니다.

이 튜토리얼에서는 Let’s Encrypt SSL을 사용하여 CentOS 8에 YOURLS를 설치하는 방법을 보여줍니다.

전제 조건

  • CentOS 8을 실행하는 서버.
  • 서버 IP를 가리키는 유효한 도메인 이름.
  • 서버에 구성된 루트 비밀번호.

LEMP 서버 설치

먼저, 서버에 Nginx, MariaDB, PHP 및 필요한 PHP 확장을 설치해야 합니다. 다음 명령어로 모두 설치할 수 있습니다:

dnf install nginx mariadb-server php php-fpm php-json php-common php-mysqlnd php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath git unzip wget -y

모든 패키지가 설치되면 PHP-FPM 구성 파일 /etc/php-fpm.d/www.conf를 편집하고 사용자 이름을 apache에서 nginx로 변경합니다:

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

다음 줄을 변경합니다:

user = nginx
group = nginx

파일을 저장하고 닫은 후, 다음 명령어로 Nginx, MariaDB, PHP-FPM 서비스를 시작하고 시스템 재부팅 시 시작되도록 활성화합니다:

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

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

YOURLS용 데이터베이스 생성

다음으로, YOURLS를 위한 데이터베이스와 사용자를 생성해야 합니다. 먼저, 다음 명령어로 MariaDB에 로그인합니다:

mysql

로그인 후, 다음 명령어로 데이터베이스와 사용자를 생성합니다:

MariaDB [(none)]> CREATE DATABASE yourlsdb;  
MariaDB [(none)]> GRANT ALL PRIVILEGES ON yourlsdb.* TO 'yourlsuser'@'localhost' IDENTIFIED BY 'password';

다음으로, 권한을 플러시하고 다음 명령어로 MariaDB에서 종료합니다:

MariaDB [(none)]> FLUSH PRIVILEGES;  
MariaDB [(none)]> \q

이 시점에서 MariaDB가 설치되고 구성되었습니다.

YOURLS 설치

먼저, Nginx 웹 루트로 디렉토리를 변경하고 다음 명령어로 YOURLS의 최신 버전을 다운로드합니다:

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

다음으로, 다음 명령어로 샘플 구성 파일의 이름을 변경합니다:

cd YOURLS/user/  
cp config-sample.php config.php

다음으로, config.php 파일을 편집하고 데이터베이스 설정을 정의합니다:

nano config.php

다음 줄을 변경합니다:

/** MySQL 데이터베이스 사용자 이름 */
define( 'YOURLS_DB_USER', 'yourlsuser' );

/** MySQL 데이터베이스 비밀번호 */
define( 'YOURLS_DB_PASS', 'password' );

/ YOURLS용 데이터베이스 이름
  소문자 [a-z], 숫자 [0-9] 및 밑줄 [_]만 사용 */
define( 'YOURLS_DB_NAME', 'yourlsdb' );

/ MySQL 호스트 이름.
  비표준 포트를 사용하는 경우 'hostname:port' 형식으로 지정합니다. 예: 'localhost:9999' 또는 '127.0.0.1:666' */
define( 'YOURLS_DB_HOST', 'localhost' );

/ MySQL 테이블 접두사
  YOURLS는 이 접두사를 사용하여 테이블을 생성합니다 (예: `yourls_url`, `yourls_options`, ...)
 ** 소문자 [a-z], 숫자 [0-9] 및 밑줄 [_]만 사용 */
define( 'YOURLS_DB_PREFIX', 'yourls_' );

define( 'YOURLS_SITE', 'http://yourls.example.com' );
$yourls_user_passwords = array(
        'admin' => 'yourpassword',

작업이 완료되면 파일을 저장하고 닫습니다. 다음으로, 다음 명령어로 .htaccess 파일을 생성합니다:

nano /var/www/html/YOURLS/.htaccess

다음 줄을 추가합니다:


RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /yourls-loader.php [L]

파일을 저장하고 닫은 후, 다음 명령어로 적절한 권한과 소유권을 부여합니다:

chown -R nginx:nginx /var/www/html/YOURLS  
chmod -R 775 /var/www/html/YOURLS

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

YOURLS를 위한 Nginx 구성

다음으로, YOURLS를 위한 새로운 Nginx 가상 호스트 구성 파일을 생성합니다:

nano /etc/nginx/conf.d/yourls.conf

다음 줄을 추가합니다:

server {
  listen 80;
  server_name yourls.example.com;
  root /var/www/html/YOURLS;
  index index.php index.html index.htm;
  location / {
    try_files $uri $uri/ /yourls-loader.php$is_args$args;
  }

  location ~ \.php$ {
    include fastcgi.conf;

    fastcgi_index index.php;
    fastcgi_pass unix:/run/php-fpm/www.sock;
  }
}

파일을 저장하고 닫은 후, 다음 명령어로 Nginx 및 PHP-FPM 서비스를 재시작합니다:

systemctl restart nginx  
systemctl restart php-fpm

다음 명령어로 Nginx의 상태를 확인할 수도 있습니다:

systemctl status nginx

다음과 같은 출력을 얻어야 합니다:

? nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/nginx.service.d
           ??php-fpm.conf
   Active: active (running) since Tue 2020-10-20 09:37:40 EDT; 5min ago
  Process: 12864 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 12862 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 12860 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 12871 (nginx)
    Tasks: 3 (limit: 12523)
   Memory: 5.5M
   CGroup: /system.slice/nginx.service
           ??12871 nginx: master process /usr/sbin/nginx
           ??12872 nginx: worker process
           ??12873 nginx: worker process

Oct 20 09:37:40 centos systemd[1]: Stopped The nginx HTTP and reverse proxy server.
Oct 20 09:37:40 centos systemd[1]: Starting The nginx HTTP and reverse proxy server...
Oct 20 09:37:40 centos nginx[12862]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Oct 20 09:37:40 centos nginx[12862]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Oct 20 09:37:40 centos systemd[1]: Started The nginx HTTP and reverse proxy server.

SELinux 및 방화벽 구성

기본적으로 CentOS 8에서는 SELinux가 활성화되어 있습니다. 따라서 YOURLS 웹사이트를 위해 이를 구성해야 합니다.

다음 명령어로 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/YOURLS

다음으로, 다음 명령어로 방화벽을 통해 포트 80 및 443을 허용합니다:

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

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

YOURLS 접근

이제 웹 브라우저를 열고 URL http://yourls.example.com/admin을 사용하여 YOURLS에 접근합니다. 다음 페이지가 표시되어야 합니다:

YOURLS

Install YOURLS 버튼을 클릭합니다. 다음 페이지가 표시되어야 합니다:

YOURLS Installer

YOURLS Administration Page”를 클릭합니다. YOURLS 로그인 페이지가 표시되어야 합니다:

Log-in

config.php에서 정의한 관리자 사용자 이름과 비밀번호를 입력한 후 Login 버튼을 클릭합니다. 다음 페이지에서 YOURLS 대시보드를 볼 수 있어야 합니다:

YOURLS admin dashboard

Let’s Encrypt SSL로 YOURLS 보안 설정

다음으로, YOURLS 웹사이트에 Let’s Encrypt SSL을 다운로드하고 설치하기 위해 Certbot 유틸리티를 시스템에 설치해야 합니다.

다음 명령어로 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

다음으로, 다음 명령어로 YOURLS 웹사이트에 대한 SSL 인증서를 얻고 설치합니다:

certbot-auto --nginx -d yourls.example.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): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 yourls.example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/yourls.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/yourls.conf

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

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

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/yourls.example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/yourls.example.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

이제 URL https://yourls.example.com을 사용하여 YOURLS 웹사이트에 안전하게 접근할 수 있습니다.

결론

축하합니다! CentOS 8에 Nginx 및 Let’s Encrypt SSL로 YOURLS를 성공적으로 설치했습니다. 이제 YOURLS를 사용하여 쉽게 자신의 URL 단축기를 호스팅할 수 있습니다. 질문이 있으면 언제든지 문의해 주세요.

Share: X/Twitter LinkedIn

새 게시물을 받은 편지함에서 받기

스팸은 없습니다. 언제든지 구독 해지 가능합니다.