การ config virtual host ใน apache webserver สามารถทำได้ดังนี้
1. config/httpd.conf ทำการ include file conf/extra/httpd-vhosts.conf ดังนี้
2. ทำการ config ใน file conf/extra/httpd-vhosts.conf เพื่อเพิ่ม virtual host ที่เราต้องการสร้าง ดังนี้
คำอธิบาย
DocumentRoot คือ folder root ของ project
ServerName คือ ชื่อของ virtual ที่เราต้องการสร้าง
ErrorLogม CustomLog คือ log files ต่างๆ ซึ่งจะแยกตาม virtual host
ในการใช้งานในเครื่อง dev บน windows แบบง่ายๆ ก็ไป config ใน file hosts ได้เลย เช่น
ถ้าบน linux ก็ไปกำหนดใน file /etc/hosts นะครับ
----- เพิ่มเติม ------
วันนี้เจอปัญหาบน server คือไม่สามารถ access ได้โดยตรง ซึ่งพบว่า ใน file httpd.conf นั้นไม่ได้ allow ในการ access directory ไว้ ดังนั้นวิธีการแก้ไขคือ
- ใน file conf/httpd.conf นั้นกำหนด AllowOverride All
หรือ
- ใน file conf/extra/httpd-vhosts.conf กำหนด AllowOverride All ในแต่ละ virtual host ที่กำหนด
1. config/httpd.conf ทำการ include file conf/extra/httpd-vhosts.conf ดังนี้
Quote
Include onf/extra/httpd-vhosts.conf
2. ทำการ config ใน file conf/extra/httpd-vhosts.conf เพื่อเพิ่ม virtual host ที่เราต้องการสร้าง ดังนี้
<VirtualHost *:80> ServerAdmin admin@xx.com DocumentRoot "C:/AppServ/www/my" ServerName my.xxx.com ErrorLog "logs/my-error.log" CustomLog "logs/my-access.log" common </VirtualHost> <Directory "C:/AppServ/www/my"> Order Deny,Allow Allow from all </Directory>
คำอธิบาย
DocumentRoot คือ folder root ของ project
ServerName คือ ชื่อของ virtual ที่เราต้องการสร้าง
ErrorLogม CustomLog คือ log files ต่างๆ ซึ่งจะแยกตาม virtual host
ในการใช้งานในเครื่อง dev บน windows แบบง่ายๆ ก็ไป config ใน file hosts ได้เลย เช่น
Quote
127.0.0.1 my.xxx.com
ถ้าบน linux ก็ไปกำหนดใน file /etc/hosts นะครับ
----- เพิ่มเติม ------
วันนี้เจอปัญหาบน server คือไม่สามารถ access ได้โดยตรง ซึ่งพบว่า ใน file httpd.conf นั้นไม่ได้ allow ในการ access directory ไว้ ดังนั้นวิธีการแก้ไขคือ
- ใน file conf/httpd.conf นั้นกำหนด AllowOverride All
หรือ
- ใน file conf/extra/httpd-vhosts.conf กำหนด AllowOverride All ในแต่ละ virtual host ที่กำหนด
0 Comments On This Entry
Search My Blog
Recent Entries
Recent Comments
Tags
- Android
- Apache WebServer
- autowired
- captcha
- CodeIgniter
- Cometd
- CSS
- elgg
- floating point
- Groovy and Grails
- Hibernate
- html
- It's me
- Java Technologies
- JQuery
- log4j
- maven
- memcache
- My Bookmark
- MySql
- naming convention
- NJUG
- nosql
- Oracle
- php
- re-captcha
- Scala
- SDLC
- solr
- Spring Framework
- springframework
- Streaming
- Subversion
- svn
- Testing
- timezone
- tip
- Tomcat
- tools team
- transaction
- Velocity
- Web Technologies
- WebOS
- xml-rpc
- yii
Help
Leave Comment








