ServerRoot "/etc/httpd" # 설정·로그 기준 디렉터리Listen 80 # 수신 포트ServerName www.example.com:80 # 서버 이름DocumentRoot "/var/www/html" # 웹 문서 루트 (핵심!)DirectoryIndex index.html # 기본 문서ServerAdmin root@example.com # 관리자 이메일MaxClients 256 # 동시 접속 최대(prefork)ErrorLog "logs/error_log" # 에러 로그CustomLog "logs/access_log" combined # 접근 로그<Directory "/var/www/html"> # 디렉터리별 접근 제어 AllowOverride None # .htaccess 허용 범위 Require all granted # 접근 허용(2.4 문법)</Directory>
지시어
의미
함정
DocumentRoot
웹 문서 최상위 경로
웹 서버 설정의 기본 항목
Listen
수신 포트(기본 80)
Port가 아님(2.2 이후)
DirectoryIndex
기본 표시 문서
index.html
ServerName
서버 이름:포트
AllowOverride
.htaccess 적용 범위
None이면 .htaccess 무시
웹 문서가 위치하는 최상위 디렉터리를 지정하는 지시어 → DocumentRoot. 수신 포트는 Listen(과거 Port 아님).
가상호스트: 한 서버에 여러 사이트는 <VirtualHost *:80> 블록에 ServerName과 DocumentRoot를 각각 지정한다.
DNS 서버 BIND는 메인 설정(/etc/named.conf)과 존 데이터(/var/named/*.zone) 두 파일로 동작한다.
둘을 구분하는 것이 핵심이다.
// /etc/named.confoptions { listen-on port 53 { any; }; // 수신 인터페이스 directory "/var/named"; // 존 파일 위치 allow-query { any; }; // 질의 허용 대상};zone "example.com" IN { type master; // master(주)/slave(보조) file "example.com.zone"; // 존 데이터 파일명};
존 파일(example.com.zone)에는 리소스 레코드(RR)가 들어간다.
$TTL 86400@ IN SOA ns.example.com. admin.example.com. ( 2026060501 ; Serial (수정 시 반드시 증가!) 3600 ; Refresh 1800 ; Retry 604800 ; Expire 86400 ) ; Minimum TTL@ IN NS ns.example.com. ; 네임서버@ IN MX 10 mail.example.com. ; 메일 서버(우선순위)ns IN A 192.168.1.10 ; 정방향: 이름→IPwww IN A 192.168.1.20mail IN A 192.168.1.30ftp IN CNAME www ; 별칭
레코드
의미
기억법
SOA
권한 시작·존 정보
Serial 증가 필수
NS
네임서버 지정
Name Server
A
이름→IPv4
Address
AAAA
이름→IPv6
A 4개
MX
메일 서버(우선순위)
Mail eXchange
CNAME
별칭(정규이름)
Canonical Name
PTR
IP→이름(역방향)
Pointer
⚠️ 함정: 존 파일을 수정하면 SOA의 Serial 값을 반드시 증가시켜야 slave가 변경을 감지한다. Serial을 안 올리면 보조 서버에 갱신이 안 된다.
정방향 vs 역방향: 이름→IP는 A 레코드(정방향), IP→이름은 PTR 레코드(역방향, in-addr.arpa 존). 메일 서버 지정은 MX.
# /etc/samba/smb.conf[global] workgroup = WORKGROUP security = user # 인증 방식[share] path = /srv/share # 공유할 실제 경로 writable = yes # 쓰기 허용(= read only = no) valid users = @staff # 접근 허용 계정(@=그룹) guest ok = no # 게스트 접근
# /etc/ssh/sshd_configPort 22 # 수신 포트PermitRootLogin no # root 직접 로그인 금지(권장)PasswordAuthentication yes # 암호 인증 허용PubkeyAuthentication yes # 공개키 인증PermitEmptyPasswords no # 빈 암호 금지AllowUsers alice bob # 허용 계정 화이트리스트MaxAuthTries 3 # 인증 시도 횟수 제한
지시어
보안 의미
PermitRootLogin
no면 root 직접 로그인 차단
PasswordAuthentication
no면 키 인증만 강제
PermitEmptyPasswords
no여야 빈 암호 차단
Port
기본 22, 변경으로 스캔 회피
AllowUsers/DenyUsers
계정 단위 허용/거부
sshd_config(서버, 데몬)와 ssh_config(클라이언트)는 다른 파일. root 로그인 차단은 서버 파일의 PermitRootLogin no. 수정 후 systemctl restart sshd로 적용.
systemctl enable --now httpd # 부팅 시 자동 시작 + 즉시 기동systemctl status named # 상태·최근 로그 확인systemctl is-enabled sshd # 부팅 자동시작 여부ss -tuln | grep ':53' # 포트가 실제로 열렸는지 확인
enable vs start: start는 지금만 기동, enable은 부팅 시 자동 시작. 둘 다는 enable --now. 설정만 고치고 재시작을 안 하면 변경이 반영되지 않는다 — 작업형의 흔한 감점.
NFS는 예외: exports 수정은 서비스 재시작 없이 exportfs -ra(재내보내기)로 즉시 적용할 수 있다. nfs-server는 rpcbind(111)에 의존하므로 둘 다 살아 있어야 한다.