yum install httpd* -y
apache 웹 서버 설치 (selinux는 항상 확인할 것)
rpm -qa |grep httpd
yum install httpd* -y
rpm -qa |grep httpd
netstat -lntup |grep httpd
service httpd restart
netstat -lntup |grep httpd
rpm -ql httpd | grep httpd.conf
rpm -ql httpd | grep service
설정 파일: /etc/httpd/conf/httpd.conf
데몬 파일: /usr/lib/systemd/system/httpd.service
chkconfig --level 35 httpd on
systemctl enable httpd.service
systemctl list-unit-files |grep http
firewall-cmd --permanent --add-port 80/tcp
firewall-cmd --reload
firewall-cmd --list-all
보안 포트 설정
#Listen 12.34.56.78:80
Listen 10.10.10.10:8080 <<<<<< IP 바인딩 설정
Listen 80
8080 포트를 쓰는 이유
tomcat WAS(JSP)를 쓰기 위한 웹서버
별도의 테스트 서버나 관리자 페이지
ServerAdmin root@localhost 관리자 메일 주소
ServerName www.sevas10.com:80 서버 네임
<Directory />
AllowOverride none
# Require all denied
</Directory>
#DocumentRoot "/var/www/html"
DocumentRoot "/home/sevas/test"
service httpd restat ( 에러 )
mkdir -p /home/sevas/test ( 경로 만들어주기 )
403 forbidden error 권한 문제
404 not found error 파일 없음
chmod 755 ~sevas
cat > /home/sevas/test/index.html (/home/sevas)
<Directory/>
AllowOverride none
# Require all denied
</Directory>
<Directory "/var/www/html">
Options Indexes FollowSymLinks -> 인덱스 / 링크를 사용할 수 있게 됨(보안이 취약해짐)
AllowOverride None
Require all granted
<Directory /home/sevas/test>
AllowOverride AuthConfig
Options Indexes FollowSymLinks
authentication 인증
authorization 인가 ( 권한부여 )
accounting 계정관리
- 사전준비
1. DocumentRoot "/home/sevas"
2. cat > /home/sevas/index.html
/home/sevas
3. cat > /home/sevas/test/index.html
test
4. mkdir -p /home/sevas/admin
5. cat > /home/sevas/admin/index.html
admin
- /etc/httpd/conf/httpd.conf
<Directory /home/sevas/admin>
#Options Indexes FollowSymLinks
AllowOverride AuthConfig
</Directory>
vi /home/sevas/admin/.htaccess
authname "sevas-auth"
authtype basic
authuserfile /etc/httpd/conf/mypasswd/sevas
require valid-user
`mkdir -p /etc/httpd/conf/mypasswd`
`htpasswd -m -c /etc/httpd/conf/mypasswd/sevas sevas`
결과 ( admin 으로 이동 시 로그인 필요)
[ 사전준비 ][root@localhost conf.d]# useradd test1
[root@localhost conf.d]# useradd test2
[root@localhost conf.d]# chmod 755 ~test1
[root@localhost conf.d]# chmod 755 ~test2
[root@localhost conf.d]# mkdir -p ~test1/public_html
[root@localhost conf.d]# mkdir -p ~test2/public_html
[root@localhost conf.d]# mkdir -p ~sevas/public_html
[root@localhost conf.d]# cat > ~test1/public_html/index.html
test1
^C
[root@localhost conf.d]# cat > ~test2/public_html/index.html
test2
^C
[root@localhost conf.d]# cat > ~sevas/public_html/index.html
sevas
^C
UserDir disabled → 두 설정을 적절히 섞어서 사용
UserDir enabled sevas → ~sevas 만 가능#UserDir public_html
UserDir public_html
alias /linux1 "/a/b/c/"
alias /linux2 "/home/sevas/a/b/c/"mkdir -p /a/b/c
mkdir -p ~sevas/a/b/c
cat > /a/b/c/index.html
linux1
cat > ~sevas/a/b/c/index.html
linux2vi /etc/httpd/conf.d/userdir.conf
alias /linux2 "/export/sdb/home/alias/a/b/c/"
DocumentRoot
UserDir
Alias
virtualhost
a. vi /etc/httpd/conf/httpd.conf
ServerTokens Prod
prod : 웹서버 이름
major: 웹서버 이름 major 버전
minor: 웹서버 이름 minor 버전
min : 웹서버 이름과 minimum 버전
os : 웹서버 버전 운영체제 (기본값)
Full : 전체
vi /etc/httpd/conf/httpd.conf
#Options Indexes FollowSymLinks <<<<<indexes 는 디렉토리 리스닝
Options (기능을 빼줌)
404 not found ( 파일 없음 )
403 forbidden ( 권한 오류 )
500 internal service ( 설정 오류 )
- 보안 : 해당 에러메세지를 구분할 수 없도록 설정
vi /etc/httpd/conf/httpd.conf
ErrorDocument 404 /index.html
ErrorDocument 403 /index.html