I\'m running windows 7 and recently installed XAMPP to build a dev environment. I\'m not great with the server side of things so I\'m having some problems setting up an alia
Apache 2.4 virtual hosts hack
1.In http.conf specify the ports , below “Listen”
Listen 80
Listen 4000
Listen 7000
Listen 9000
In httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "C:/Users/Vikas/Documents/NetBeansProjects/slider_website_hitesh/public_html"
ServerName hitesh_web.dev
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
<Directory "C:/Users/Vikas/Documents/NetBeansProjects/slider_website_hitesh/public_html">
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "E:/dabkick_git/DabKickWebsite"
ServerName www.my_mobile.dev
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
<Directory "E:/dabkick_git/DabKickWebsite">
Allow from all
Require all granted
</Directory>
</VirtualHost>
In hosts.ics file of windows os “C:\Windows\System32\drivers\etc\host.ics”
127.0.0.1 localhost
127.0.0.1 hitesh_web.dev
127.0.0.1 www.my_mobile.dev
127.0.0.1 demo.multisite.dev
4.now type your “domain names” in the browser it will ping the particular folder specified in the documentRoot path
5.if you want to access those files in a particular port then replace 80 in httpd-vhosts.conf with port numbers like below and restart apache
<VirtualHost *:4000>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "C:/Users/Vikas/Documents/NetBeansProjects/slider_website_hitesh/public_html"
ServerName hitesh_web.dev
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
<Directory "C:/Users/Vikas/Documents/NetBeansProjects/slider_website_hitesh/public_html">
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:7000>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "E:/dabkick_git/DabKickWebsite"
ServerName www.dabkick_mobile.dev
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
<Directory "E:/dabkick_git/DabKickWebsite">
Allow from all
Require all granted
</Directory>
</VirtualHost>
Note: for port number given virtual hosts you have to ping in browser like “http://hitesh_web.dev:4000/” or “http://www.dabkick_mobile.dev:7000/”
6.After doing all those changes you have to save the files and restart apache respectively.
I just found the same issue with Aliases on a Windows install of Xampp.
To solve the 403 error:
<Directory "C:/Your/Directory/With/No/Trailing/Slash">
Require all granted
</Directory>
Alias /dev "C:/Your/Directory/With/No/Trailing/Slash"
The default Xampp set up should be fine with just this. Some people have experienced issues with a deny placed on the root directory so flipping out the directory tag to:
<Directory "C:/Your/Directory/With/No/Trailing/Slash">
Allow from all
Require all granted
</Directory>
Would help with this but the current version of Xampp (v1.8.1 at the time of writing) doesn't require it.
As for op's issue with port 80 Xampp includes a handy Netstat button to discover what's using your ports. Fire that off and fix the conflict, I imagine it could have been IIS but can't be sure.
try this
sudo chmod -R 0777 /opt/lampp/htdocs/testproject
If you have installed a module on Xampp (on Linux) via Bitnami and changed chown
settings, make sure that the /opt/lampp/apps/<app>/htdocs
and tmp
usergroup is daemon
with all other sibling files and folders chown
ed to the user you installed as, e.g. cd /opt/lampp/apps/<app>
, sudo chown -R root:root .
, followed by sudo chown -R root:daemon htdocs tmp
.
I'm using XAMPP with Apache2.4, I had this same issue. I wanted to leave the default xampp/htdocs folder in place, be able to access it from locahost and have a Virtual Host to point to my dev area...
The full contents of my C:\xampp\apache\conf\extra\http-vhosts.conf
file is below...
# Virtual Hosts
#
# Required modules: mod_log_config
# 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.4/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 webmaster@dummy-host.example.com
##DocumentRoot "C:/xampp/htdocs/dummy-host.example.com"
##ServerName dummy-host.example.com
##ServerAlias www.dummy-host.example.com
##ErrorLog "logs/dummy-host.example.com-error.log"
##CustomLog "logs/dummy-host.example.com-access.log" common
##</VirtualHost>
##<VirtualHost *:80>
##ServerAdmin webmaster@dummy-host2.example.com
##DocumentRoot "C:/xampp/htdocs/dummy-host2.example.com"
##ServerName dummy-host2.example.com
##ErrorLog "logs/dummy-host2.example.com-error.log"
##CustomLog "logs/dummy-host2.example.com-access.log" common
##</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:\nick\static"
ServerName dev.middleweek.co.uk
<Directory "C:\nick\static">
Allow from all
Require all granted
</Directory>
</VirtualHost>
I then updated my C:\windows\System32\drivers\etc\hosts
file like this...
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 dev.middleweek.co.uk
127.0.0.1 localhost
Restart your machine for good measure, open the XAMPP Control Panel and start Apache.
Now open your custom domain in your browser, in the above example, it'll be http://dev.middleweek.co.uk
Hope that helps someone!
And if you want to be able to view directory listings under your new Virtual host, then edit your VirtualHost block in C:\xampp\apache\conf\extra\http-vhosts.conf
to include "Options Indexes" like this...
<VirtualHost *:80>
DocumentRoot "C:\nick\static"
ServerName dev.middleweek.co.uk
<Directory "C:\nick\static">
Allow from all
Require all granted
Options Indexes
</Directory>
</VirtualHost>
Cheers, Nick
I finally got it to work.
I'm not sure if the spaces in the path were breaking things but I changed the workspace of my Aptana installation to something without spaces.
Then I uninstalled XAMPP and reinstalled it because I was thinking maybe I made a typo somewhere without noticing and figured I should be working from scratch.
Turns out Windows 7 has a service somewhere that uses port 80 which blocks apache from starting (giving it the -1) error. So I changed the port it listens to port 8080, no more conflict.
Finally I restarted my computer, for some reason XAMPP doesn't like me messing with ini files and just restarting apache wasn't doing the trick.
Anyway, this has been the most frustrating day ever so I really hope my answer ends up helping someone out!