2012년 6월 27일 수요일

Virtual Host on MAX OSX


Virtual Host on MAX OSX
1. 아파치 활성화:
     라이언: 시스템설정 > 공유 > 웹공유 체크
     마운틴라이언: sudo apachectl start (http://v.daum.net/link/32342588)
2. Installing mod_jk for Apache 2.2 on Mac OS X 10.5 Leopard
출처 http://www.bartbusschots.ie/blog/?p=1347

2.1 tomcat connector 설치
source 파일 다운, 압축해제 후 컴파일
-----------
$ cd native
$ ./configure CFLAGS='-arch x86_64' APXSLDFLAGS='-arch x86_64' --with-apxs=/usr/sbin/apxs
$ make
(make가 안될경우 애플개발자 사이트에서  command line tool ~~ 항목 설치)
$ sudo make install


    ./configure.....에서 에러날 경우 XCode설치 후 심볼릭링크 생성해줌

$ sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain

(출처: http://apple.stackexchange.com/questions/58186/how-to-compile-mod-wsgi-on-mountain-lion-by-fixing-apxserror-command-failed-w)


----------
2.2. workers.properties 작성
-----------
etc/apache2/extra/workers.properties
#
# The workers that jk should create and work with
#
worker.list=worker1

#
# Defining a worker named ajp13 and of type ajp13
# Note that the name and the type do not have to match.
#
worker.ajp13.type=worker1
worker.ajp13.host=localhost
worker.ajp13.port=8009
-------------
3. httpd-vhosts.conf 설정
etc/apache2/extra/httpd-vhosts.conf

###########start
# Load mod_jk module
# Update this path to match your modules location
LoadModule jk_module libexec/apache2/mod_jk.so
# Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to httpd.conf)
JkWorkersFile /etc/apache2/workers.properties
# Where to put jk shared memory
# Update this path to match your local state directory or logs directory
JkShmFile /var/log/apache2/mod_jk.shm
# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile /var/log/apache2/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

# Send everything for context /example to worker named ajp13

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# 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 ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
        ServerAdmin admin@beautyhub.co.kr
        DocumentRoot "/Users/jryeong/DEV/server/apache2/mobile"
        ServerName m.beautyhub2.co.kr
        ErrorLog "/Users/jryeong/DEV/server/logs/httpd/m.beautyhub2.co.kr.error.log"
        CustomLog "/Users/jryeong/DEV/server/logs/httpd/m.beautyhub2.co.kr.access.log" common
        <Directory "/Users/jryeong/DEV/server/apache2/mobile">
           Options None
           AllowOverride None
           Order allow,deny
           Allow from all
       </Directory>
</VirtualHost>

<VirtualHost *:80>
        ServerAdmin admin@beautyhub.co.kr
        DocumentRoot "/Users/jryeong/DEV/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/beautyhub"
        ServerName api.beautyhub2.co.kr
        ErrorLog "/Users/jryeong/DEV/server/logs/httpd/api.beautyhub2.co.kr.error.log"
        CustomLog "/Users/jryeong/DEV/server/logs/httpd/api.beautyhub2.co.kr.access.log" common
        JkMount /* worker1
        JkUnMount /*.js worker1
        JkUnMount /*.css worker1
        JkUnMount /*.swf worker1
        JkUnMount /*.png worker1
        JkUnMount /*.gif worker1
        JkUnMount /*.ico worker1
       <Directory "/Users/jryeong/DEV/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/beautyhub">
           Options None
           AllowOverride None
           Order allow,deny
           Allow from all
       </Directory>
 </VirtualHost>
##########end

4. hots 파일 설정
/etc/hosts
-----------
127.0.0.1       localhost
255.255.255.255 broadcasthost
127.0.0.1       m.beautyhub2.co.kr
127.0.0.1       api.beautyhub2.co.kr
::1             localhost
fe80::1%lo0     localhost
----------

5. m.beautyhub2.co.kr/index.html에 접속
권한 에러 나올 경우
폴더에 권한을 설정

6./etc/apache2/httpd.conf에서
httpd-vhosts.conf를 읽어들이도록 주석해제


7. 이클립스에서 테스트
    디플로이용 서버 추가시 http server 선택 후 디플로이 폴더 선택
/Users/jryeong/DEV/server/apache2