On my Windows 7 PC, I'm using XAMPP => Apache to run a testing webserver. But for a certain website I don't want the regular "C:\xampp\htdocs", but a custom path - which when I work on Ubuntu I usually setup in VirtualHost just as a DocumentRoot and it works.
On this PC the target path is similar to: "C:\Users\X\Disk External\DIRWITHDIÁCRÍCÍCS\WEBS\some path\path"
However on this PC when I do
<VirtualHost test2020.test:443>
DocumentRoot "C:\Users\X\Disk External\DIRWITHDIÁCRÍCÍCS\WEBS\some path\path"
ServerName test2020.test
ServerAlias www.test2020.test
</VirtualHost>
The DocumentRoot directive is completely ignored - it still seems to target files in the default C:\xampp\htdocs
I've also tried moving the files around the system and changing forward/backward slashes with no success:
DocumentRoot "C:/Users/X/Disk External/DIRWITHDIÁCRÍCÍCS/WEBS/some path/path"
DocumentRoot C:\xampp\htdocs\testdocumentroot
DocumentRoot "C:\Users\X\www"
Also I've tried swapping order of DocumentRoot and ServerName with no success.
I've checked C:\xampp\apache\conf\httpd.conf - the line Include conf/extra/httpd-vhosts.conf IS uncommented.
And the file C:\xampp\apache\conf\extra\httpd-vhosts.conf seems to affect apache start-up when set-up wrongly.
EDIT: also I did restart apache between each try :)
What am I missing?
So it's just my idiotism, I've tried to overdomain everything, but the directive attribute inside the VirtualHost tag is for network incoming limitation. For regular cases * is just fine there, also then I had a problem with Directory tag directive because aparently there's a new directive for Apache 2.4+
<VirtualHost test2020.test:443> => <VirtualHost *:443>
Working final code:
# (or *:80 for http:// , 443 is for https://)
<VirtualHost *:443>
DocumentRoot "C:\Users\X\Disk External\DIRWITHDIÁCRÍCÍCS\WEBS\some path\path"
ServerName test2020.test
ServerAlias www.test2020.test
<Directory "C:\Users\X\Disk External\DIRWITHDIÁCRÍCÍCS\WEBS\some path\path">
# NEW&SIMPLE FROM APACHE 2.4+ !
Require all granted
</Directory>
</VirtualHost>
Related
I have a new laptop, and am now trying to run a laravel application.
First, am trying to setup a virtual host for the project so that I can access blog.local
I went my hosts file and setup the drivers like the following:
127.0.0.1 localhost
127.0.0.1 test.local
127.0.0.1 blog.local
The for the apache configuration I have the following:
<VirtualHost *:80>
DocumentRoot "C:\XAMPP\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:\XAMPP\htdocs\blog"
ServerName blog.local
</VirtualHost>
When I try to access my url I do not see the site but the files only:
For this and future projects, how can I create a local url and see the front-end when I visit it?
You need to address your public folder,
<VirtualHost *:80>
DocumentRoot "C:\XAMPP\htdocs\blog\public"
ServerName blog.local
</VirtualHost>
The document root is a directory (a folder) that is stored on your host's servers and that is designated for holding web pages. When someone else looks at your website, this is the location they will be accessing.
Change the DocumentRoot to according to your PHP project is located.
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/blog/public"
ServerName blog.local
</VirtualHost>
Restart the servers after making any changes! If you don’t reset the server to apply the changes, nothing will work even though you know you’ve done everything right.
I am trying to create a virtual host for a Zend Framework project, but it is not working.
I added the string "127.0.0.1 mysite.local" to the hosts file (/private/etc/hosts), and this is what I put in httpd.conf:
<VirtualHost *:80>
ServerName mysite.local
DocumentRoot "/Applications/MAMP/htdocs/mysite/public"
SetEnv APPLICATION_ENV "development"
<Directory "/Applications/MAMP/htdocs/mysite/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I restarted server, and then I try to access it in browser like: http://mysite.local:8888/, but it takes me to "htdocs" root, not to the Zend Project.
Am I missing something? Did I type something wrong? I'm using MacOSX, I tried putting port 8888 instead of 80 in the VirtualHost definition but it didn't work too.
Thanks
I am using MAMP. I want separate domains to use different roots on my local computer.
I want "localhost" to go to my htdocs folder.
I want "wowzers.loc" to use /Donald/Projects/wowzers as its root.
I want "secondsite.loc" to use /Donald/Projects/secondsite as its
root.
Here is my httpd-vhosts.conf file:
NameVirtualHost *:80
<VirtualHost *>
DocumentRoot "/Users/donald/Projects/wowzers"
ServerName wowzers.loc
</VirtualHost>
<VirtualHost *>
DocumentRoot "/Users/donald/Projects/secondsite"
ServerName secondsite.loc
</VirtualHost>
Right now, typing "localhost", "wowzers.loc", or "secondsite.loc" will all navigate to the first entry in my vhosts file. In this example, everything navigates to "wowzers.loc".
Why do all my servernames point to the top entry?
You should try it without the quotes around DocumentRoot and also pass the same argument from NameVirtualHost to VirtualHost i.e.: <VirtualHost *:80>
Apache documentation
What steps are needed to complete adding another website to OS X (Lion) ?
I want to have the 2 websites organized in 2 folders under 'Sites', but not sure how to get there. As can be seen in the image below, the MB currently has the 'default' (first) website spread out in Sites. I am concerned that putting this default site into a folder of Sites, call it 'siteA' will cause it to disappear.
These sites are not hosted on this MB. (OK, well they are, ...) It is being used for the development, viewing and testing within BBEdit.
After the steps below, the URL http://bella, replies Forbidden - You don't have permission to access / on this server. (??)
Suggestions welcomed. Thanks in advance.
So far, I've added or amended:
-- private/etc/hosts (added the following)
127.0.0.1 bella
-- private/etc/apache2/http.conf (uncommented 2nd line)
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf
-- /private/etc/apache2/extra/httpd-vhosts.conf (added 2 VirtualHost blocks)
# 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>
DocumentRoot "/Library/WebServer/Documents"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/dolan2go/Sites/Bella"
ServerName bella
</VirtualHost>
The directory structure of my Macbook currently looks like:
Have to make a few modifications to get this to work. With the desire to have folders 'FirstSite' & 'Bella' in the 'Sites' folder. (My User directory structure has been altered because of a HD & SSD hardware mod)
Amend the hosts.conf file to: (last 2 lines - see note below)
127.0.0.1 bella.local
127.0.0.1 firstSite.local
Uncomment the line to use the vhosts.conf file (as in original question)
Amend the httpd-vhosts.conf to:
# Localhost first
<VirtualHost *:80>
DocumentRoot "/Volumes/HDD 1/<username>/Sites"
ServerName localhost
</VirtualHost>
# local test Sites
<VirtualHost *:80>
DocumentRoot "/Volumes/HDD 1/<username>/Sites/FirstSite"
ServerName firstSite.local
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Volumes/HDD 1/<username>/Sites/Bella"
ServerName bella.local
</VirtualHost>
# Allow from localhost only or other directives
<Directory "/Volumes/HDD 1/<username>/Sites/FirstSite">
Order Deny,Allow
Allow from 127.0.0.1
Deny from all
</Directory>
<Directory "/Volumes/HDD 1/<username>/Sites/Bella">
Order Deny,Allow
Allow from 127.0.0.1
Deny from all
</Directory>
Now I can access the local version of both sites with http://bella.local & http://firstSite.local (I decided to add the local to help distinguish between the local and remote versions.)
A reply by twtwtw 3/4 down the page at Local Web Server for Lion really helped clear the issue.
How can I set up virtualhost for multiple domain name on Windows?
I will use it for my own test projects. I have three projects that I need to set up and at the moment I'm using xampplite for the portable Apache.
www.foo-bar.com --> direct to c:\xampplite\htdocs\foo-bar\
www.abcdef.com --> directo to c:\xampplite\htdocs\abcdef\
www.qwerty.com --> direct to c:\xampplite\htdocs\qwerty\web\
I also need to access on another project, but it just like typing
http://localhost/my-project/
How can I write the vhost configuration for that?
You need to do several steps in order to make this work.
Update the hosts file. On Windows XP, you can find it under c:\WINDOWS\system32\drivers\etc\. You should already see the first line from below. It takes care of your mentioned other project. Add the additional ones to make any requests to the mentioned virtual hosts routed back to your own machine.
127.0.0.1 localhost
127.0.0.1 foo-bar.com
127.0.0.1 abcdef.com
127.0.0.1 qwerty.com
Update the vhosts file in Apache configuration. Under your XAMPP folder, add the following to apache\conf\extra\httpd-vhosts.conf and if needed change the ports (i.e., if you use 8080 instead of port 80).
<VirtualHost *:80>
DocumentRoot C:/xampplite/htdocs/foo-bar/
ServerName www.foo-bar.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:/xampplite/htdocs/abcdef/
ServerName www.abcdef.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:/xampplite/htdocs/qwerty/web/
ServerName www.qwerty.com
</VirtualHost>
Do a quick configuration check. Open {XAMPP-folder}\apache\conf\httpd.conf your file and make sure that the following part is not commented out by a preceding # character:
Include conf/extra/httpd-vhosts.conf
Restart XAMPP.
... and you should be all setup now. Your other project should be accessible at the URI you mentioned if you just put it under C:/xampplite/htdocs/my-project/.
To get C:/xampp/htdocs/my-project/ working, I had to add the following (default?) VirtualHost to apache\conf\extra\httpd-vhosts.conf (in step 2 of MicE's tutorial).
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
127.0.0.5 abcd.com
< VirtualHost 127.0.0.5 >
ServerName abcd.com
DocumentRoot "C:\xampp\htdocs\laravel\public"
<Directory "C:\xampp\htdocs\laravel\public">
DirectoryIndex index.php
AllowOverride All
Order allow, deny
Allow from all
</Directory>
< / VirtualHost >