사용자 도구

사이트 도구


miniserver:xenial

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판이전 판
다음 판
이전 판
miniserver:xenial [2016/07/28 12:58] – [Ampache] changwoominiserver:xenial [2018/01/02 02:34] (현재) – [Torrent] 잘못된 스크립트 수정 changwoo
줄 140: 줄 140:
  
 ==== Dokuwiki ==== ==== Dokuwiki ====
 +
 <code - vhost-wiki.conf> <code - vhost-wiki.conf>
 # Nginx Configuration # Nginx Configuration
 +
 +# 아래 설정은 https 적용 이후 http -> https 이동에 사용됨.
 +server {
 +    listen     80;
 +    server_name     wiki.changwoo.pe.kr;
 +    return          301 https://$server_name$request_uri;
 +}
  
 server { server {
줄 194: 줄 202:
 </code> </code>
  
 +nginx라면 복구 이후 멋진 URL에서 .htaccess 방식을 선택해야 문서가 올바르게 보인다.
 ==== WordPress ==== ==== WordPress ====
 이 녀석은 조금 복잡하다. 이 녀석은 조금 복잡하다.
줄 270: 줄 279:
  
 <code - vhost-wordpress.conf> <code - vhost-wordpress.conf>
 +
 +# 아래 설정은 https 적용 이후 http -> https 이동에 사용됨.
 +server {
 +    listen     80;
 +    server_name     wiki.changwoo.pe.kr;
 +    return          301 https://$server_name$request_uri;
 +}
 +
 server { server {
  server_name blog.changwoo.pe.kr;  server_name blog.changwoo.pe.kr;
줄 277: 줄 294:
  index index.php;  index index.php;
  
- include /media/storage/www-data/conf.d/wordpress-restrictions.conf;+        # wp-login.php, wp-admin 접근을 IP로 제한 (단, wp-ajax.php는 AJAX를 활용해야 하므로 허용) 
 +        location ~ ^/(wp-admin(?!/admin-ajax\.php)|wp-login.php) { 
 +            allow 192.168.0.0/24; 
 +            deny all; 
 +            include snippets/fastcgi-php.conf; 
 +     fastcgi_pass unix:/run/php/php7.0-fpm.sock; 
 +        }
  
 + include /media/storage/www-data/conf.d/wordpress-restrictions.conf;
  include /media/storage/www-data/conf.d/wordpress.conf;  include /media/storage/www-data/conf.d/wordpress.conf;
 } }
줄 464: 줄 488:
  
 === uWSGI === === uWSGI ===
 +
 +앱이 하나일 때는 아래와 같이 간단하게 master로 돌렸다.
 <code - miniserver-apps.ini> <code - miniserver-apps.ini>
 [uwsgi] [uwsgi]
줄 488: 줄 514:
 daemonize = <path-to-log> daemonize = <path-to-log>
 </code> </code>
 +
 +그러나 복수의 앱을 운영해야 할 시점이 생기자 엡퍼러(emperor) 모드가 필요해졌다. 엠퍼러 모드는 간단하게 이렇게 쓸 수 있다.
 +
 +<code - uwsgi-emperor.ini>
 +uid=owner
 +
 +daemonize=<path-to-log>
 +
 +emperor=<path-to-store-vassals>
 +
 +</code>
 +
 +<path-to-store-vassals>에는 그룹으로 돌릴 ini 파일들을 넣으면 된다. 즉 miniserver-apps.ini 파일 같은 것을 그대로 이 디렉토리에 넣으면 되는데, 이 때 주의할 점은 몇몇 설정들은 이미 엠퍼러에서 진행되었으므로 삭제해야 한다. 예를 들어 miniserver-apps.ini에서 demonize, uid 같은 설정값은 에러를 낼 수 있다.
  
 === rc.local === === rc.local ===
줄 502: 줄 541:
 uwsgi --reload /tmp/project-master.pid uwsgi --reload /tmp/project-master.pid
 kill -HUP `cat /tmp/project-master.pid` kill -HUP `cat /tmp/project-master.pid`
 +killall -s INT uwsgi
 </code> </code>
  
줄 524: 줄 564:
 create mask = 0644 create mask = 0644
 directory mask = 0755 directory mask = 0755
 +</code>
 +
 +심볼릭 링크를 추가하기 위해 다음과 같은 세팅을 주었다((http://unix.stackexchange.com/questions/5120/how-do-you-make-samba-follow-symlink-outside-the-shared-path))
 +<code>
 +[global]
 +allow insecure wide links = yes
 +
 +[share]
 +follow symlinks = yes
 +wide links = yes
 </code> </code>
  
줄 642: 줄 692:
 <code - deluge-daemon> <code - deluge-daemon>
 #!/bin/sh #!/bin/sh
-### BEGIN INIT INFO 
-# Provides:          deluge-daemon 
-# Required-Start:    $local_fs $remote_fs 
-# Required-Stop:     $local_fs $remote_fs 
-# Should-Start:      $network 
-# Should-Stop:       $network 
-# Default-Start:     2 3 4 5 
-# Default-Stop:      0 1 6 
-# Short-Description: Daemonized version of deluge and webui. 
-# Description:       Starts the deluge daemon with the user specified in 
-#                    /etc/default/deluge-daemon. 
-### END INIT INFO 
- 
-# Author: Adolfo R. Brandes  
-# Updated by: Jean-Philippe "Orax" Roemer 
- 
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 
-DESC="Deluge Daemon" 
-NAME1="deluged" 
-NAME2="deluge" 
-DAEMON1=/usr/bin/deluged 
-DAEMON1_ARGS="-d -c /media/storage/changwoo/.config/deluge -L info -l /media/storage/changwoo/.config/deluge/deluge.log"             # Consult `man deluged` for more options 
-DAEMON2=/usr/bin/deluge-web 
-DAEMON2_ARGS=""               # Consult `man deluge-web` for more options 
-PIDFILE1=/var/run/$NAME1.pid 
-PIDFILE2=/var/run/$NAME2.pid 
-UMASK=022                     # Change this to 0 if running deluged as its own user 
-PKGNAME=deluge-daemon 
-SCRIPTNAME=/etc/init.d/$PKGNAME 
- 
-# Exit if the package is not installed 
-[ -x "$DAEMON1" -a -x "$DAEMON2" ] || exit 0 
- 
-# Read configuration variable file if it is present 
-[ -r /etc/default/$PKGNAME ] && . /etc/default/$PKGNAME 
- 
-# Load the VERBOSE setting and other rcS variables 
-[ -f /etc/default/rcS ] && . /etc/default/rcS 
- 
-# Define LSB log_* functions. 
-# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. 
-. /lib/lsb/init-functions 
- 
-if [ -z "$RUN_AT_STARTUP" -o "$RUN_AT_STARTUP" != "YES" ] 
-then 
-   log_warning_msg "Not starting $PKGNAME, edit /etc/default/$PKGNAME to start it." 
-   exit 0 
-fi 
- 
-if [ -z "$DELUGED_USER" ] 
-then 
-    log_warning_msg "Not starting $PKGNAME, DELUGED_USER not set in /etc/default/$PKGNAME." 
-    exit 0 
-fi 
- 
-# 
-# Function to verify if a pid is alive 
-# 
-is_alive() 
-{ 
-   pid=`cat $1` > /dev/null 2>&1 
-   kill -0 $pid > /dev/null 2>&1 
-   return $? 
-} 
- 
-# 
-# Function that starts the daemon/service 
-# 
-do_start() 
-{ 
-   # Return 
-   #   0 if daemon has been started 
-   #   1 if daemon was already running 
-   #   2 if daemon could not be started 
- 
-   is_alive $PIDFILE1 
-   RETVAL1="$?" 
- 
-   if [ $RETVAL1 != 0 ]; then 
-       rm -f $PIDFILE1 
-       start-stop-daemon --start --background --quiet --pidfile $PIDFILE1 --make-pidfile \ 
-       --exec $DAEMON1 --chuid $DELUGED_USER --user $DELUGED_USER --umask $UMASK -- $DAEMON1_ARGS 
-       RETVAL1="$?" 
-   else 
-       is_alive $PIDFILE2 
-       RETVAL2="$?" 
-       [ "$RETVAL2" = "0" -a "$RETVAL1" = "0" ] && return 1 
-   fi 
- 
-   is_alive $PIDFILE2 
-   RETVAL2="$?" 
- 
-   if [ $RETVAL2 != 0 ]; then 
-        sleep 2 
-        rm -f $PIDFILE2 
-        start-stop-daemon --start --background --quiet --pidfile $PIDFILE2 --make-pidfile \ 
-        --exec $DAEMON2 --chuid $DELUGED_USER --user $DELUGED_USER --umask $UMASK -- $DAEMON2_ARGS 
-        RETVAL2="$?" 
-   fi 
-   [ "$RETVAL1" = "0" -a "$RETVAL2" = "0" ] || return 2 
-} 
- 
-# 
-# Function that stops the daemon/service 
-# 
-do_stop() 
-{ 
-   # Return 
-   #   0 if daemon has been stopped 
-   #   1 if daemon was already stopped 
-   #   2 if daemon could not be stopped 
-   #   other if a failure occurred 
- 
-   start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --user $DELUGED_USER --pidfile $PIDFILE2 
-   RETVAL2="$?" 
-   start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --user $DELUGED_USER --pidfile $PIDFILE1 
-   RETVAL1="$?" 
-   [ "$RETVAL1" = "2" -o "$RETVAL2" = "2" ] && return 2 
- 
-   rm -f $PIDFILE1 $PIDFILE2 
- 
-   [ "$RETVAL1" = "0" -a "$RETVAL2" = "0" ] && return 0 || return 1 
-} 
- 
-case "$1" in 
-  start) 
-   [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME1" 
-   do_start 
-   case "$?" in 
-      0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 
-      2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 
-   esac 
-   ;; 
-  stop) 
-   [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME1" 
-   do_stop 
-   case "$?" in 
-      0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 
-      2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 
-   esac 
-   ;; 
-  restart|force-reload) 
-   log_daemon_msg "Restarting $DESC" "$NAME1" 
-   do_stop 
-   case "$?" in 
-     0|1) 
-      do_start 
-      case "$?" in 
-         0) log_end_msg 0 ;; 
-         1) log_end_msg 1 ;; # Old process is still running 
-         *) log_end_msg 1 ;; # Failed to start 
-      esac 
-      ;; 
-     *) 
-        # Failed to stop 
-      log_end_msg 1#!/bin/sh 
 ### BEGIN INIT INFO ### BEGIN INIT INFO
 # Provides:          deluge-daemon # Provides:          deluge-daemon
줄 954: 줄 848:
         # Failed to stop         # Failed to stop
       log_end_msg 1       log_end_msg 1
-      ;; 
-   esac 
-   ;; 
-  *) 
-   echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 
-   exit 3 
-   ;; 
-esac 
- 
-: 
       ;;       ;;
    esac    esac
줄 1017: 줄 901:
 </code> </code>
  
 +
 +===== Resilio-Sync =====
 +[[https://www.resilio.com/ | Resilio-Sync ]]로 비트토렌트 방식의 싱크. [[project:btsyncforrpi | 라즈베리 파이에서 BitTorrentSync로 데이터 동기화하기 ]] 같은 문서로도 작성한 바가 있다. 이게 이름이 바뀌었다.
 +
 +가정용은 무료이니 나같이 그냥 비디오 디렉토리 공유하는 수준에서는 괜찮은 선택인 것 같다.
 +
 +deb 패키지가 제공되니 깔아 주면 그만이다. service resilio-sync start 명령으로 실행하면 되는데, 변경은 다음과 같은 명령으로
 +<code bash>
 +$ sudo systemctl edit resilio-sync.service 
 +
 +[Service]
 +User=changwoo
 +Group=changwoo
 +PIDFile=
 +PIDFile=/home/changwoo/.config/resilio-sync/sync.pid
 +ExecStartPre=
 +ExecStartPre=/bin/mkdir -p /home/changwoo/.config/resilio-sync
 +ExecStartPre=/bin/chown -R changwoo:changwoo /home/changwoo/.config/resilio-sync
 +ExecStart=
 +ExecStart=/usr/bin/rslsync --config /home/changwoo/.config/resilio-sync/config.json
 +</code>
 +
 +systemctl edit 명령은 파일 자체를 변경하는 것이 아니라 overriding 하는 방식이다.그리고 override 할 때 기존 명령어는 한번 비워주는 작업이 필요하다. 그래서 "''ExexStart=''" 같은 라인이 생기는 것이다. 저것이 없으면 에러.
 +
 +<code bash>
 +$ sudo systemctl cat resilio-sync.service
 +
 +[Unit]
 +Description=Resilio Sync service
 +Documentation=https://help.getsync.com/
 +After=network.target network-online.target
 +
 +[Service]
 +Type=forking
 +User=rslsync
 +Group=rslsync
 +UMask=0002
 +Restart=on-failure
 +PermissionsStartOnly=true
 +PIDFile=/var/run/resilio-sync/sync.pid
 +ExecStartPre=/bin/mkdir -p /var/run/resilio-sync
 +ExecStartPre=/bin/chown -R rslsync:rslsync /var/run/resilio-sync
 +ExecStart=/usr/bin/rslsync --config /etc/resilio-sync/config.json
 +
 +[Install]
 +WantedBy=multi-user.target
 +
 +# /etc/systemd/system/resilio-sync.service.d/override.conf
 +[Service]
 +User=changwoo
 +Group=changwoo
 +PIDFile=
 +PIDFile=/home/changwoo/.config/resilio-sync/sync.pid
 +ExecStartPre=
 +ExecStartPre=/bin/mkdir -p /home/changwoo/.config/resilio-sync
 +ExecStartPre=/bin/chown -R changwoo:changwoo /home/changwoo/.config/resilio-sync
 +ExecStart=
 +ExecStart=/usr/bin/rslsync --config /home/changwoo/.config/resilio-sync/config.json
 +
 +
 +</code>
 +
 +이렇게 덧붙여지는 것을 참고하자.
  
  
 +===== SSL 설비 =====
 +이제는 필수로 구비하자. Let's Encrypt가 있다. 아래의 가이드를 따라하면 어렵지 않다.
 +  * https://certbot.eff.org/#ubuntuxenial-nginx
 +  * http://riseshia.github.io/2016/10/16/certbot-let-s-encrypt.html
 +3개월마다 갱신해야 하는데, 나는 아직 자동 갱신을 하지는 않았다. 나중에 확인하고 달아 보도록 하자.
  
  
miniserver/xenial.1469710687.txt.gz · 마지막으로 수정됨: 2016/07/28 12:58 저자 changwoo

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki