Sunday, June 26, 2011

Multi web server configuration in one computer


Below is an example to host an extra web server in port 8081 in localhost.
Add following lines in conf/httpd.conf in Apache:
---------------------------------------------------------------------------
# testserver website
<VirtualHost *:8081>
ServerName egps.localhost:8081
DocumentRoot C:/Users/jiansen/Desktop/testserver/htdocs
    <Directory />
Options FollowSymLinks
AllowOverride None
DirectoryIndex index.php
php_value include_path ".;C:/Users/jiansen/Desktop/testserver/etc/"
Order allow,deny
Allow from all
 
  <IfModule rewrite_module>
#RewriteEngine On
#RewriteRule !maintenance_msg\.php$ /maintenance_msg.php [R,L]

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://localhost/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://192.168.1.52/.*$ [NC]
RewriteRule .*\.(jpe?g|png|gif|bmp|swf|flv) - [NC,F,L]
       </IfModule>   
     </Directory>
</VirtualHost>
----------------------------------------------------------------------------------------------------------

Explanation:
The extra web server port is 8081 in localhost, the document root is
C:/Users/jiansen/Desktop/testserver/htdocs, load index.php by default,
php include path is: C:/Users/jiansen/Desktop/testserver/etc/

php include path can also set in php.ini, for example in my php.ini:
include_path = ".;c:\php\includes;c:\php\PEAR\pear;c:\php\PEAR\Mail-1.2.0\Mail"

No comments:

Post a Comment