오중호랑이
오중호랑이의 비밀로그
오중호랑이
전체 방문자
622,412
오늘
2
어제
13
  • 전체보기 (171)
    • 일상 (120)
    • 개발 (18)
      • 일반 (13)
      • 호랑이와 jQuery (5)
    • 외로움 상자 (33)
      • 호랑이단편집 (2)
      • 힙 to the 합 (4)

최근 글

  • 베스트필드 한줄평
    2022.11.30
    베스트필드 한줄평
  • 알림톡입니다. 많이 알려주세요.
    2022.11.30
  • 알뜰폰은 역시 모빙
    2022.10.08
    알뜰폰은 역시 모빙
  • 네이버지도 Javascript API v3 현위치 표시하기
    2022.08.23
    네이버지도 Javascript API v3 현위치 표시하기
  • 관평동 라면우에무라 첫방문 팁💡
    2022.08.16
    관평동 라면우에무라 첫방문 팁💡

최근 댓글

  • 서버쪽 맥이 잠든상태에서도 가능한건가요?
    맥
  • 글 잘보고 갑니다
    나리카페
  • 정말 고맙습니다. 덕분에 예전 노래들을 꺼낼수 있엇네요
    잠자는아이팟
  • 선생님 잘 사용중입니다! 근데 줄 개행된곳은 띄어쓰기가⋯
    오잉
  • 감사합니다
    오중호랑이
hELLO · Designed By 정상우.
오중호랑이

오중호랑이의 비밀로그

YOURLS를 사용해서 짧은 URL (Shorten URL) 서비스 직접 운영하기
개발/일반

YOURLS를 사용해서 짧은 URL (Shorten URL) 서비스 직접 운영하기

2016. 2. 16. 18:30

짧은 URL서비스가 상당히 많습니다. 굳이 내 서버 들여가면서 운영할 필요가 있을까요?
국내는 네이버 운영 m2.do와 해외쪽으로는 거의 시초라고 볼 수 있는 bit.ly가 있습니다.
두 서비스 모두 무료로 이용가능하지만…

1. 커스텀URL이 사실상 불가능하다는 점과.. (이미 사용된 커스텀 URL이 대부분이고 주소를 줄이기 위해서 특정 구분단어를 넣는것 또한 취지에 어긋남)

2. 자신의 도메인으로 서비스 하고싶을 경우 (bit.ly의 경우 자신의 도메인을 연결 가능하지만 커스텀 URL 네임 스페이스는 모든 사람과 공유함)

짧은 URL 관리프로그램인 YOURLS를 자신의 서버에 설치하면 됩니다.
자신의 도메인과 서버가 준비되어있다는 가정하에 다음과 같이 설치를 하면 됩니다. (여기서는 http://ojtig.er 로 설정)

 

▲ https://github.com/YOURLS/YOURLS 이곳에 접속하여 우측에 Download ZIP을 눌러서 다운로드 하세요.

▲ 압축해제후 다음과 같이 업로드 하세요.

/user/config-sample.php를 열어서 설정을 편집 후 config.php으로 저장하는데, 이 파일에서 거의 모든 설정을 조정합니다.

/* This is a sample config file.
 * Edit this file with your own settings and save it as "config.php"
 *
 * IMPORTANT: edit and save this file as plain ASCII text, using a text editor, for instance TextEdit on Mac OS or
 * Notepad on Windows. Make sure there is no character before the opening <?php at the beginning of this file.
 */

/*
 ** MySQL settings - You can get this info from your web host
 */

/** MySQL database username */
define( 'YOURLS_DB_USER', 'root' );

/** MySQL database password */
define( 'YOURLS_DB_PASS', '#password#' );

/** The name of the database for YOURLS */
define( 'YOURLS_DB_NAME', 'yourls' );

/** MySQL hostname.
 ** If using a non standard port, specify it like 'hostname:port', eg. 'localhost:9999' or '127.0.0.1:666' */
define( 'YOURLS_DB_HOST', 'localhost' );

/** MySQL tables prefix */
define( 'YOURLS_DB_PREFIX', 'yourls_' );

/*
 ** Site options
 */

/** YOURLS installation URL -- all lowercase and with no trailing slash.
 ** If you define it to "http://sho.rt", don't use "http://www.sho.rt" in your browser (and vice-versa) */
define( 'YOURLS_SITE', 'http://ojtig.er' );

/** Server timezone GMT offset */
define( 'YOURLS_HOURS_OFFSET', 0 ); 

/** YOURLS language
 ** Change this setting to use a translation file for your language, instead of the default English.
 ** That translation file (a .mo file) must be installed in the user/language directory.
 ** See http://yourls.org/translations for more information */
define( 'YOURLS_LANG', '' ); 

/** Allow multiple short URLs for a same long URL
 ** Set to true to have only one pair of shortURL/longURL (default YOURLS behavior)
 ** Set to false to allow multiple short URLs pointing to the same long URL (bit.ly behavior) */
define( 'YOURLS_UNIQUE_URLS', true );

/** Private means the Admin area will be protected with login/pass as defined below.
 ** Set to false for public usage (eg on a restricted intranet or for test setups)
 ** Read http://yourls.org/privatepublic for more details if you're unsure */
define( 'YOURLS_PRIVATE', true );

/** A random secret hash used to encrypt cookies. You don't have to remember it, make it long and complicated. Hint: copy from http://yourls.org/cookie **/
define( 'YOURLS_COOKIEKEY', 'modify this text with something random' );

/** Username(s) and password(s) allowed to access the site. Passwords either in plain text or as encrypted hashes
 ** YOURLS will auto encrypt plain text passwords in this file
 ** Read http://yourls.org/userpassword for more information */
$yourls_user_passwords = array(
	'ojtiger' => 'password',
	// 'username2' => 'password2',
	// You can have one or more 'login'=>'password' lines
	);

/** Debug mode to output some internal information
 ** Default is false for live site. Enable when coding or before submitting a new issue */
define( 'YOURLS_DEBUG', false );
	
/*
 ** URL Shortening settings
 */

/** URL shortening method: 36 or 62 */
define( 'YOURLS_URL_CONVERT', 36 );
/*
 * 36: generates all lowercase keywords (ie: 13jkm)
 * 62: generates mixed case keywords (ie: 13jKm or 13JKm)
 * Stick to one setting. It's best not to change after you've started creating links.
 */

/** 
* Reserved keywords (so that generated URLs won't match them)
* Define here negative, unwanted or potentially misleading keywords.
*/
$yourls_reserved_URL = array(
	'porn', 'faggot', 'sex', 'nigger', 'fuck', 'cunt', 'dick',
);

/*
 ** Personal settings would go after here.
 */

상수명을 보시면 알겠지만..
14번줄 데이터베이스 계정
17번줄 데이터베이스 패스워드
24번줄 데이터베이스 호스트
35번줄 자신의 도메인
62번줄 YOURLS솔루션에서 사용할 계정이름과 패스워드 => 배열 형식으로 여러명 지정 가능
그 외 것들은 넘어가거나 나중에 알아보기로 하고 넘어가는걸로 하고..

▲ 데이터베이스에 접속해서 다음과 같이 config.php에서 지정한 대로 데이터베이스를 생성 해주세요.

▲ 생성이 완료되면 http://ojtig.er/admin 으로 접속 하면 다음과 같은 인스톨 화면을 볼 수 있고 인스톨 버튼을 누르면 테이블이 생성되면서 설치가 완료 되지만,

▲ 권한 문제로 .htaccess를 쓸 수 없기에, 수동으로 .htaccess를 작성해주면 됩니다.

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

.htacess파일을 생성 후 위와 같이 리다이렉트 룰을 넣은 후 저장, 아파치 설정을 변경하여 AllowOverride가 허용인지 확인 후 허용, 다 한 후 왜 안되냐고 생각말고 아파치를 재시작 하세요.

service httpd restart

▲상단 config.php에 지정한 계정과 패스워드를 이용하여 로그인 하면 다음과 같은 화면을 볼 수 있습니다.

▲모든 설치가 완료되면 다음과 같은 관리화면을 볼 수 있고 이것저것(?) 눌러봐서 어떤기능인지 확인 할 수 있습니다.

상단 좌측 Manage Plugins에는 플러그인을 관리 할 수 있고, Allow Hyphens in Short URLs를 허용해서 댓시(-)를 사용 가능하게 허용 할 수 있게 할 수 있습니다.
YOURLS는 기본적으로 같은 URL이 등록이 안되는데 그럴 경우 간단하게 의미 없는 파라미터(http://ojtiger.com/?1)를 붙여주면 끝!

▲실사용 문제 없음 (약 3만 클릭)

    '개발/일반' 카테고리의 다른 글
    • 리니지M 고급 변신 뽑기 체험
    • 소설 강제 개행 줄바꿈 수정 사이트
    • txt, doc, pdf, jpg 파일을 ePub으로 변환 <오중호랑이의 ePub제작소>
    • e-Book을 만드는 가장 간단한 방법
    bit.ly, github, m2.do, shorten url, YOURLS, 짧은url
    오중호랑이
    오중호랑이
    ojtiger@ojtiger.com
    댓글쓰기
    소설 강제 개행 줄바꿈 수정 사이트
    다음 글
    소설 강제 개행 줄바꿈 수정 사이트
    txt, doc, pdf, jpg 파일을 ePub으로 변환  <오중호랑이의 ePub제작소>
    이전 글
    txt, doc, pdf, jpg 파일을 ePub으로 변환 <오중호랑이의 ePub제작소>

    티스토리툴바