Quantcast
Viewing all articles
Browse latest Browse all 17

Answer by Yash for how to create virtual host on XAMPP

Apache Virtual Host documentation Setting up a virtual host (vhost) provides several benefits:

  • Virtual Hosts make URLs cleaner – localhost/mysite vs mysite.local.
  • Virtual Hosts make permissions easier – restrict access for a single vhost on a local network vs permitting access to all sites on your local network.
  • Some applications require a “.” in the URL (ahem Magento). While you can setup localhost.com/mysite by editing the Windows hosts file, creating a vhost is a better solution.

VirtualHost Directive Contains directives that apply only to a specific hostname or IP address

Location Directive Applies the enclosed directives only to matching URLs

Example changes over configuration file - D:\xampp\apache\conf\extra\httpd-vhosts.conf

<VirtualHost *:80>    ServerAdmin localhost    DocumentRoot "D:/xampp/htdocs"    ServerName localhost</VirtualHost><VirtualHost localhost:80>  ServerAdmin webmaster@host.example.com  DocumentRoot "/www/docs/host.example.com"  #DocumentRoot "D:\xampp\htdocs\phpPages"  ServerName host.example.com  ErrorLog "logs/host.example.com-error_log"  TransferLog "logs/host.example.com-access_log"</VirtualHost># To get view of PHP application in the Browser.<VirtualHost *:80>    ServerAdmin postmaster@dummy-host.localhost    DocumentRoot "D:\xampp\htdocs\app1"    ServerName app1.yash.com    ServerAlias app1.yash.com    ErrorLog "logs/app1.yash.com-error.log"    CustomLog "logs/app1.yash.com-access.log" combined    # App1 communication proxy call to Java War applications from XAMP<Location /ServletApp1>            ProxyPass  http://app1.yashJava.com:8080/ServletApp1            ProxyPassReverse  http://app1.yashJava.com:8080/ServletApp1            Order Allow,Deny            Allow from all</Location></VirtualHost><VirtualHost *:80>    ServerAdmin postmaster@infotreesolutions.com    DocumentRoot "D:\xampp\htdocs\app2"    ServerName app2.yash.com    ErrorLog "logs/app2.yash.com-error.log"    CustomLog "logs/app2.yash.com-access.log" combined    # App1 communication proxy call to Java War applications from XAMP<Location /ServletApp2>            ProxyPass  http://app1.yashJava.com:8080/ServletApp2            ProxyPassReverse  http://app1.yashJava.com:8080/ServletApp2            Order Allow,Deny            Allow from all</Location></VirtualHost>

Update Your Windows Hosts File « Open your Windows hosts file located in C:\Windows\System32\drivers\etc\hosts.

# localhost name resolution is handled within DNS itself.#   127.0.0.1       localhost#   ::1             localhost127.0.0.1       test.com127.0.0.1       example.com127.0.0.1       myssl.yash.com

D:\xampp\apache\conf\httpd.conf, [httpd-ssl.conf](http://httpd.apache.org/docs/2.2/mod/mod_ssl.html)

# Listen: Allows you to bind Apache to specific IP addresses and/or# ports, instead of the default. See also the <VirtualHost> directive.# Listen 0.0.0.0:80 | [::]:80Listen 80LoadModule proxy_http_module modules/mod_proxy_http.soLoadModule speling_module modules/mod_speling.so# ServerAdmin: Your address, where problems with the server should be e-mailed.# This address appears on some server-generated pages, such as error documents.#  e.g. admin@your-domain.comServerAdmin postmaster@localhostServerName localhost:80DocumentRoot "D:/xampp/htdocs"<Directory "D:/xampp/htdocs">    Options Indexes FollowSymLinks Includes ExecCGI    AllowOverride All    Require all granted</Directory># Virtual hostsInclude "conf/extra/httpd-vhosts.conf"# ===== httpd-ssl.conf - SSL Virtual Host Context =====# Note: Configurations that use IPv6 but not IPv4-mapped addresses need two#       Listen directives: "Listen [::]:443" and "Listen 0.0.0.0:443"Listen 443## SSL Virtual Host Context<VirtualHost _default_:443>    DocumentRoot "D:\xampp\htdocs\projectFolderSSL"    ServerName myssl.yash.com:443    ServerAlias myssl.yash.com:443    ServerAdmin webmaster@localhost    ErrorLog "logs/error.log"<IfModule log_config_module>        CustomLog "logs/access.log" combined</IfModule>    ## Redirecting URL from Web server to Application server over different machine.    # myssl.yash.com:443/ServletWebApp<Location /path>        ProxyPass  http://java.yash2.com:8444/ServletWebApp        ProxyPassReverse  http://java.yash2.com:8444/ServletWebApp        Order Allow,Deny        Allow from all</Location>    #SSLCertificateFile "conf/ssl.crt/server.crt"    SSLCertificateFile "D:\SSL_Vendor\yash.crt"    #SSLCertificateKeyFile "conf/ssl.key/server.key"    SSLCertificateKeyFile "D:\SSL_Vendor\private-key.key"    #SSLCertificateChainFile "conf/ssl.crt/server-ca.crt"    SSLCertificateChainFile "D:\SSL_Vendor\intermediate.crt"</VirtualHost># ===== httpd-ssl.conf - SSL Virtual Host Context =====

@see


Viewing all articles
Browse latest Browse all 17

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>