2015-08-30

[debian] apache2 web server 간단한 설정

집에서 사용하는 개인용 Debian에서 apache2로 web server를 설정하는 방법을 기록한다.

1. 준비
Debian 설치시 옵션으로 web server를 사용하겠다고 선택했더니 이미 apache2가 설치되어 있었다. 방화벽도 열려 있었다.
기본 설정 파일 내용은 변경을 거의 안할것다. 일부 보안 관련 설정만 작업 할 것이다.

web root : /var/www/html (기본 설정)

2. security.conf 수정
# vi /etc/apache2/conf-available/security.conf

<Directory />
   AllowOverride None
   Order Deny,Allow
   Deny from all
</Directory>

<Directory /var/www/html>
   AllowOverride None
   Order Deny,Allow
   Allow from all
</Directory>

ServerTokens Prod
ServerSignature Off
TraceEnable On

3. user 추가
# htpasswd -c /etc/apache2/passwd userid

4. 디렉토리 설정
# vi /etc/apache2/conf-available/video.conf
<Directory /var/www/html/video>
   Order Deny,Allow
   AuthType Basic
   AuthName "testauthname"
   AuthUserFile /etc/apache2/passwd
   Require valid-user
</Directory>

5. 설정 파일 link
# ln -s /etc/apache2/conf-available/video.conf /etc/apache2/conf-enabled/video.conf

6. 재시작
# service apache2 restart

웹 브라우저에 video 디렉 토리 접근시 3번 과정에서 추가한 userid와 password를 요구한다.



2015-08-22

[debian] torrent 설정

debian linux에서 torrent daemon(transmission-daemon) 을 설정한다.

1. 준비
torrent 자동 추가 디렉토리 : "/mnt/exhdd/seagate_hdd/torrent/input"
torrent 임시 디렉토리 : "/mnt/exhdd/seagate_hdd/torrent/tmp"
torrent 다운로드 디렉토리 : "/mnt/exhdd/seagate_hdd/torrent/down"


2. 설치
# apt-get install transmission-daemon


3. 서비스 종료 (안하면, 설정이 수정안됨)
# service transmission-daemon stop

4. 설정
# vi /etc/transmission-daemon/settings.json
아래 url에서 설정관련 추가 정보를 얻을수 있다.
https://trac.transmissionbt.com/wiki/EditConfigFiles

{
    "alt-speed-down": 50,
    "alt-speed-enabled": false,
    "alt-speed-time-begin": 540,
    "alt-speed-time-day": 127,
    "alt-speed-time-enabled": false,
    "alt-speed-time-end": 1020,
    "alt-speed-up": 50,
    "bind-address-ipv4": "0.0.0.0",
    "bind-address-ipv6": "::",
    "blocklist-enabled": false,
    "blocklist-url": "http://www.example.com/blocklist",
    "cache-size-mb": 4,
    "dht-enabled": true,
    "download-dir": "/mnt/exhdd/seagate_hdd/torrent/down",
    "download-limit": 100,
    "download-limit-enabled": 0,
    "download-queue-enabled": true,
    "download-queue-size": 5,
    "encryption": 1,
    "idle-seeding-limit": 30,
    "idle-seeding-limit-enabled": false,
    "incomplete-dir": "/mnt/exhdd/seagate_hdd/torrent/tmp",
    "incomplete-dir-enabled": true,
    "lpd-enabled": false,
    "max-peers-global": 200,
    "message-level": 1,
    "peer-congestion-algorithm": "",
    "peer-id-ttl-hours": 6,
    "peer-limit-global": 200,
    "peer-limit-per-torrent": 50,
    "peer-port": 51413,
    "peer-port-random-high": 65535,
    "peer-port-random-low": 49152,
    "peer-port-random-on-start": false,
    "peer-socket-tos": "default",
    "pex-enabled": true,
    "port-forwarding-enabled": false,
    "preallocation": 1,
    "prefetch-enabled": 1,
    "queue-stalled-enabled": true,
    "queue-stalled-minutes": 30,
    "ratio-limit": 2,
    "ratio-limit-enabled": false,
    "rename-partial-files": true,
    "rpc-authentication-required": true,
    "rpc-bind-address": "0.0.0.0",
    "rpc-enabled": true,
    "rpc-password": "torrent_password",
    "rpc-port": 9091,
    "rpc-url": "/transmission/",
    "rpc-username": "torrent_id",
    "rpc-whitelist": "192.168.0.2",
    "rpc-whitelist-enabled": true,
    "scrape-paused-torrents-enabled": true,
    "script-torrent-done-enabled": false,
    "script-torrent-done-filename": "",
    "seed-queue-enabled": false,
    "seed-queue-size": 10,
    "speed-limit-down": 100,
    "speed-limit-down-enabled": false,
    "speed-limit-up": 100,
    "speed-limit-up-enabled": false,
    "start-added-torrents": true,
    "trash-original-torrent-files": false,
    "umask": 18,
    "upload-limit": 100,
    "upload-limit-enabled": 0,
    "upload-slots-per-torrent": 14,
    "utp-enabled": true,
    "watch-dir": "/mnt/exhdd/seagate_hdd/torrent/input",
    "watch-dir-enabled": true,
    "trash-original-torrent_files": true
}


5. 재시작
# service transmission-daemon restart


6. web browser로 동작 확인
web browser에서 http://192.168.0.3:9091/transmission/
id : torrent_id
password : torrent_password




2015-08-20

[debian] samba 설치

debian linux에서 samba를 설치 및 설정 하여 windows와 디렉토리를 공유한다.

1. 준비
공유 할 디렉토리는 /mnt/exhdd 이다.
공유 시 사용할 계정은 userid이다.


2. samba 설치
# apt-get install samba


3. samba 설정, 아래 구문 추가
# vi /etc/samba/smb.conf

[exhdd]
   path = /mnt/exhdd
   valid users = userid
   writeable = yes
   browseable = yes


4. samba 계정 등록
# smbpasswd -a userid
New SMB password:
Retype new SMB password:
Added user sharpis.


5. samba 설정 적용
# service samba reload


6. 탐색기에서 "\\IP주소" 형태로 접속한다.
ex) \\192.168.0.2


[debian] 외장 하드 자동 mount 하는 방법

debian에서 usb 외장하드를 자동 mount 하는 방법
매번 mount 명령을 사용하여 수동 mount 할수 있지만, 부팅시 자동 mount 할수 있게 설정할수 있는 방법 작성한다.

1. 준비
Seagate 외장 HDD, ntfs 포멧 되어 있음.
mount할 디렉토리 경로는 /mnt/exhdd/seagate_hdd 이다.

2. Seagate 외장 HDD의 장치 명 확인
# ls -l /dev/disk/by-label/

lrwxrwxrwx 1 root root 10 Aug 19 22:36 Seagate\x20Backup\x20Plus\x20Drive -> ../../sdb1


3. Seagate 외장 HDD의 uuid확인
# ls -l /dev/disk/by-uuid/

lrwxrwxrwx 1 root root 10 Aug 19 22:36 0bc18742-2f05-4bce-9d40-f2fe5e89bc1a -> ../../sda5
lrwxrwxrwx 1 root root 10 Aug 19 22:36 A4E83FF7E83FC5F8 -> ../../sdb1
lrwxrwxrwx 1 root root 10 Aug 19 22:36 c537dfe8-75dd-41d5-89d9-2e3d8f7a5515 -> ../../sda1


4. fstab 파일 설정, /etc/fstab에 아래 색으로 칠한 구문 추가
# vi /etc/fstab

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=c537dfe8-75dd-41d5-89d9-2e3d8f7a5515 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
UUID=0bc18742-2f05-4bce-9d40-f2fe5e89bc1a none            swap    sw              0       0
/dev/sr0        /media/cdrom0   udf,iso9660 user,noauto     0       0

# external hdd
UUID=A4E83FF7E83FC5F8 /mnt/exhdd/seagate_hdd               ntfs    errors=remount-ro 1       1

5. mount 경로 생성
# mkdir -p /mnt/exhdd/seagate_hdd

6. 재시작
# init 6


7. 확인
# mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,relatime,size=10240k,nr_inodes=216982,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,relatime,size=401404k,mode=755)
/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
mqueue on /dev/mqueue type mqueue (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw,relatime)
tmpfs on /run/user/118 type tmpfs (rw,nosuid,nodev,relatime,size=200704k,mode=700,uid=118,gid=125)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=200704k,mode=700,uid=1000,gid=1000)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime)
/dev/sdb1 on /mnt/exhdd/seagate_hdd type fuseblk (rw,relatime,user_id=0,group_id=0,allow_other,blksize=4096)








2015-08-19

[debian] notebook 덮개 설정

notebook에 debian 설치 후 덮개를 닫을때 절전 모드로 동작하는 문제가 있었다.

notebook 덮개 닫을때 아무 동작 안하게 설정하는 방법은 남긴다.

1. 아래 명령으로 logind.conf 파일을 연다.
# vi /etc/systemd/logind.conf

2. 덮개 닫을때 아무 동작 안하는 설정 추가한다.
   아래 구문을 설정파일에 추가한다.
HandleLidSwitch=ignore

이제 덮개를 닫아도 절전모드로 동작 하지 않는다.