2020. 5. 7.

[Linux] apache IP 기반 가상 호스트 실습 정리


가상 호스트를 만들어서 IP마다 웹페이지를 만든다.

* ip 가상으로 할당한다.

cd /etc/sysconfig/network-scripts
cp ifcfg-ens32 ifcfg-ens32:0
vi ifcfg-ens32:0

# device IPADDR 수정한다.
TYPE z" Ethernet" 
PROXY 
ROWSER 
800TPROT0=" none" 
I pv4 FAILURE FATAL=" n o" 
IPV6 
IPV6 
IPV6 FAILURE FATAL ' 
= 'no" 
" stable-privacy" 
IPV6 ADDR GEN 
PREFIX-"24" 
153" 
IPV6 
1

systemctl restart network

Croot@153 cp ifcfg-ens32 ifcfg-ens32:ø 
Croot@153 vi ifcfg-ens32:ø 
Croot@153 systemctl restart network

환경설정이 끝나면 항상 웹관리자로 로그인해서 설정한다.

# 아파치 서버를 정지시키고 환경 파일을 설정한다.
/app/apache/bin/apachectl stop
vi /app/apache/conf/httpd.conf

# 주석처리 해제
# 아래 vhosts.conf에서 설정한다는것이다.
Include conf/extra/httpd-vhosts.conf

# 입력
DocumentRoot /home/web/httpd/152
ServerName 192.168.10.152
DocumentRoot /home/web/httpd/153
ServerName 192.168.10.153

# 수정하여 httpd 아래 모든 폴더에 접속할 있도록 변경해준다.

root@153:- 
#1ncIude conf/extra/httpd-userdir.conf 
# Real-time info on requests and configuration 
#1ncIude conf/extra/httpd-info.conf 
# Virtual hosts 
Include conf/extra/httpd-vhosts.conf 
<virtua1Host 192.168.113.152> 
DocumentRoot / home/web/httpd/152 
192.168.1ø.152 
< /VirtuaIHost> 
<virtua1Host 192.168.1ø.153> 
DocumentRoot / home/web/httpd/153 
192.168.1ø.153 
< /VirtuaIHost> 
# Local access to the Apache HTTP Server Manual 
#1ncIude conf/extra/httpd-manual.conf 
# Distributed authoring and versioning (WebDAV) 
#1ncIude conf/extra/httpd-dav.conf
root@153:- 
# features. 
<Directoy / > 
Options FollowSymLinks 
AllowOverride None 
Order deny, allow 
Deny from all 
Note that from this point forward you must specifically allow 
particular features to be enabled - so if something's not working as 
you might expect, make sure that you have specifically enabled it 
below. 
This should be changed to whatever you set DocumentRoot to. 
<Directoy 
<Directoy "/home/web/httpd/t>


# 가상 호스트 설정
vi /app/apache/conf/extra/httpd-vhosts.conf

NameVirtualHost *:80
// 이거 수정하면 안됨

# 아래 가상환경을 설정해준다.

    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/home/web/httpd/153"
    ServerName 192.168.10.153
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/dummy-host.example.com-error_log"
    CustomLog "logs/dummy-host.example.com-access_log" common

    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/home/web/httpd/152"
    ServerName 192.168.10.152
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/dummy-host.example.com-error_log"
    CustomLog "logs/dummy-host.example.com-access_log" common

# VirtualHost example: 
# Almost any Apache directive may go into a VirtualHost container. 
# The first VirtualHost section is used for all requests that do not 
# match a SetwerName or SetwerAIias in any block. 
<VirtuaIHost * : 80 
webmaster@dummy-host.example.com 
DocumentRoot " / home/web/httpd/153" 
192.168.113.153 
SetwerAIias mwq.dummy-host.example.com 
ErrorLog 
CustomLog "logs/dummy-host.example.com-access_log" 
< /VirtuaIHost> 
<VirtuaIHost * : 80 
webmaster@dummy-host.example.com 
DocumentRoot " / home/web/httpd/152" 
192.168.113.152 
mwq.dummy-host.example.com 
ErrorLog 
CustomLog "logs/dummy-host.example.com-access_log" 
c ormon 
c ormon


# 해당 디렉토리를 만들어주고
cd /home/web/httpd
cp -R html 153
cp -R html 152

# 내용을 수정하여 구분한다.
vi /home/web/httpd/153/index.html
vi /home/web/httpd/152/index.html

# 아파치서버를 재시작해본다.
/app/apache/bin/apachectl restart

확인한다.

9 
19긴168-10-152 
C 0 주의 요함 
152 
19기168-10-153 
192.168.10.152
9 19기168-10-152 
9 19m 68-10-153 
C 주의 요함 1 192.168.10.153 
153



# extra디렉토리의 httpd-vhosts.conf 쪽에서 귀찮타면 httpd.conf 에서 설정하면 된다.

댓글 없음:

댓글 쓰기