I struggle with apache's virtual host configuration. I want to deploy cgit on a subdomain like: http://cgit.mydomain.com
I have used this as a template for my configuration: http://hjemli.net/pipermail/cgit/2011-July/000235.html
Here is my virtual host configuration:
<VirtualHost *>
ServerAdmin admin#mydomain.org
ServerName cgit.mydomain.org
ErrorLog "/var/log/httpd/cgit-error_log"
CustomLog "/var/log/httpd/cgit-access_log" common
DocumentRoot "/usr/share/webapps/cgit/"
<Directory "/usr/share/webapps/cgit/">
AllowOverride None
Options ExecCGI FollowSymlinks
Order allow,deny
Allow from all
</Directory>
Alias /cgit.css "/usr/share/webapps/cgit/cgit.css"
Alias /cgit.png "/usr/share/webapps/cgit/cgit.png"
Alias /favicon.ico "/usr/share/webapps/cgit/favicon.ico"
ScriptAlias / "/usr/share/webapps/cgit/cgit.cgi/"
</VirtualHost>
Here is a part of my cgitrc:
css=/cgit.css
logo=/cgit.png
favicon=/favicon.ico
Everything works fine but the css file and the favicon do not work, so the cgit webpage is broken. When I go to the URL http://cgit.mydomain.com/cgit.css cgit tells me that there is no repo called cgit.css. Usually I shoud see the cgit.css file in my browser.
A possible solution is to use /cgit/ as a script alias but I do not want to have the /cgit/ fragment in my URLs. On http://cgit.osmocom.org it works right.
I am note really shure why but now the setup works! After adding DocumentRoot "/usr/share/webapps/cgit/" to my virtual host I stopped working yesterday.
Today I looked on my cgit website and everything is fine! I think it was something like a cache issue...
The virtual host settings above work.
Related
I've went through all the posts I could find here, still couldn't get this to work:
I Have a Windows 10 + MAMP.
MAMP is set to folder C:/MAMP/htdocs as the root folder
I un-commented the Virtual host line on the httpd.conf:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Added :
<VirtualHost *:80>
DocumentRoot "C:/MAMP/htdocs/team/example"
ServerName dev.example.com
ServerAlias dev.examplecom
</VirtualHost>
into httpds-vhosts.conf to the extra folder (under conf)
added the following to my hosts file:
127.0.0.1 dev.example.com
I Can get to localhost,
But every time I try a domain, it gices me: Not Found (The requested URL / was not found on this server.)
I'm pretty sure I am missing something small, But will greatly appreciate a solution to this.
So far i tried changing the Path in the conf files.
Tried using relative paths rather than absolute.
Tried any idea I could find onlie,
Thanks, and a happy new year :)
Cheers.
Changing the line from Include conf/extra/httpd-vhosts.conf to Include C:/MAMP/conf/extra/httpd-vhosts.conf worked for me.
It seems that httpd.conf requires absolute paths
I didn't see you mention anything about SymLink, maybe that's what you're missing to make it work.
Find this line in that same C:\MAMP\conf\apache\httpd.conf file.
<Directory />
Options FollowSymLinks ExecCGI
AllowOverride none
Order deny,allow
Allow from all
</Directory>
Change AllowOverride from none to all
<Directory />
Options FollowSymLinks ExecCGI
AllowOverride all
Order deny,allow
Allow from all
</Directory>
Although I'm late to the party, hope that helps.
Also make sure to restart the servers on MAMP 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.
Not sure if this question is still relevant but I was having the exact same problem setting up my Virtual Host recently and I was receiving the: Not Found (The requested URL / was not found on this server.). The solution for me was to write it as the following:
<VirtualHost *:80>
DocumentRoot C:/MAMP/htdocs/team/example
ServerName dev.example.com
ServerAlias dev.examplecom
</VirtualHost>
Without the quotations around the DocumentRoot. Seems both simple and dumb but it worked for me. Make sure to restart the Mamp Servers again!
I don't have enough points to comment on James's answer, but this is another quirk of the Windows environment:
In the hosts file, Windows wants two lines for each virtual host:
127.0.0.1 dev.example.com
::1 dev.example.com
Hi I'm trying to install ZF 1.12 with XAMPP .I read everything and did everything exactly as it was written,also configured the "httpd.conf" file like this:
<VirtualHost *:80>
DocumentRoot "/xampp/htdocs/<Your project folder>/public"
ServerName <Your project folder>
ServerAlias www.<Your project folder>
SetEnv APPLICATION_ENV "development"
<Directory "/xampp/htdocs/new/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
but now when i try to start the server i get the following message:
500 Internal Server Error
The server encountered an internal error or misconfiguration and was >unable to complete your request.
Is there anything else that needs to be done
Your Virtual Host definition is incomplete i.e no closing tag ( this may just have been missed when you copy/pasted.
Lets assume you have created and installed the Framework into /xampp/htdocs/project1/public
Lets also assume you want to run this site from a development domain called project1.dev i.e this is what you want to enter into the browser address bar.
Lets also assume you are using Apache 2.4.x and therefore need to use the Apache 2.4 syntax for access.
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/project1/public"
ServerName project1.dev
ServerAlias www.project1.dev
<Directory "C:/xampp/htdocs/new/public">
DirectoryIndex index.php
AllowOverride All
Require local
</Directory>
SetEnv APPLICATION_ENV "development"
</VirtualHost>
Now you need to edit the C:\windows\system32\srivers\etc\hosts and add these 2 lines.
127.0.0.1 project1.dev
::1 project1.dev
Now run this from a command windows launched using "Run as Administrator"
net stop dbscache
net start dnscache
And then restart Apache. Alternatively, just reboot.
I want that every *.dev Host will be routed to my vagrant machine to /var/www/vhosts/*.dev/public, for example my local development environment project1.dev is located in /var/www/vhosts/project1.dev/public
So when I add a new (sub)project into my box, I do not need to change my config.yaml (Vagrant installed via puphpet.com) and reload the machine.
On my computer, I added the following to the hosts file in /private/etc:
192.168.56.101 *.dev
On my VM, I changed my 10-default_vhosts80.conf in /etc/apache2/sites-enabled to:
# ************************************
# Vhost template in module puppetlabs-apache
# Managed by Puppet
# ************************************
<VirtualHost *:80>
ServerName default
## Vhost docroot
DocumentRoot "/var/www/default"
## Directories, there should at least be a declaration for /var/www/default
<Directory "/var/www/default">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
</Directory>
## Load additional static includes
## Logging
ErrorLog "/var/log/apache2/default_vhost_80_error.log"
ServerSignature Off
CustomLog "/var/log/apache2/default_vhost_80_access.log" combined
## Custom fragment
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/default/$1
</VirtualHost>
<VirtualHost *.dev:80>
ServerName dev
VirtualDocumentRoot /var/www/vhosts/%0
</VirtualHost>
Unfortunately, this doesn't work. Any ideas? I am a beginner in this subject.
I use a proxy auto configuration file. This works on Windows, MacOS and Linux. Easy, flexible and no additional software required. The following example routes all *.dev traffic to your vagrant box:
function FindProxyForURL(url, host) {
if (dnsDomainIs(host, ".dev")) {
return "PROXY 127.0.0.1:8080";
}
return 'DIRECT';
}
When needed, replace 127.0.0.1:8080 with the IP and webserver port of your vagrant box. Store this file somewhere. You can store it locally or let the webserver on your Vagrant-box host the file.
Windows: See here how to use the PAC file on Windows.
MacOS: See here how to use the PAC file on MacOS. You can link to the file using file:///Users/username/path/to/proxy.pac.
Linux: For linux it depends, but I'm sure linux users will be able to Google for their specific situation.
Unfortunately hosts files do not support using wildcards. You have to manually define each and every host to redirect.
Also, your hosts file is at /etc/hosts
In the end, I use dnsmasq to route all .localdev Domains to 127.0.0.1. Note that I am using .localdev instead of just .dev or .local as this seems to cause problem (OS X 10.10) because .dev is a proposed gTLD and .local is used by Apple's Bonjour.
Then I configured Apache by creating and enabling this site:
<VirtualHost *:80>
ServerAlias localhost *.localdev #wildcard catch all
VirtualDocumentRoot /hosts/%1/public
UseCanonicalName Off
<Directory "hosts">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
(from: http://brunodbo.ca/blog/2013/04/26/setting-up-wildcard-apache-virtual-host-wildcard-dns)
I am trying to set up the Apache server which comes with OS X Mavericks with vhosts so that a domain name resolves to my user level document webroot. I have followed this tutorial which guided me through setting up the apache server with php:
http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-9-mavericks/
as well as this one which guided me through setting up the vhosts:
http://coolestguidesontheplanet.com/set-virtual-hosts-apache-mac-osx-10-9-mavericks-osx-10-8-mountain-lion/
Following these tutorials, if I type localhost in my browser it correctly resolves to the system level root (/Library/WebServer/Documents/ folder). If I use localhost/~myusername it correctly resolves to my user level root (/users/myusername/Sites/).
However, whenever I navigate to my domain, I get redirected to the system level root rather than my user level root.
My vhosts file reads as follows:
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Library/WebServer/Documents/
</VirtualHost>
<VirtualHost *:80>
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot "/Users/myusername/Sites/mydomain"
<Directory "/Users/myusername/Sites/mydomain">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Any ideas?
Have you enabled Virtualhosts?
NameVirtualHost *:80
And included your vhosts directory
Include <path>/vhosts/*
On a Macbook, you may need to include /private/ at the beginning of any absolute path, so that Apache can read it correctly off the file system.
For others who have the same problem...
It was frustratingly simple - I had missed the "" around the localhost directory.
How annoying!
Try starting apache manually with the -S option to see what the problem might be:
/usr/sbin/httpd -S
I am trying to make a setup so that I can access my website on a virtual host in computer A from computer B. Both A and B are on the same network.
I am using xampp on Win 7.
So here is as the problem goes computer A(server) has a virtual host configuration as follows in the httpd-vhosts.conf file.
NameVirtualHost project:81
<VirtualHost project:81>
DocumentRoot "D:/work/website"
ServerName project:81
<Directory "D:/work/website">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
(using port 81 as port 80 has IIS running, dont know much about these things however)
this configuration works fine on the local machine(server). i.e project:81 in the address bar of the browser opens up the website as it should.
Now on computer B(client) I changed the hosts file to contain the IP of the server along with the name of the virtual host like:-
192.168.1.7 project
now when I enter project:81 on the client browser .. it takes me to the server but its not taking me to the virtual host directory, instead it takes to the default directory .. i.e in my case is
C:\xampp\htdocs
Now I am stuck and unable to make the client to point to the current destination.
So can anybody suggest what I am doing wrong here or something else I need to do in order to have access to the correct virtual host site from the client machine.
Thanks in advance for any help
Ok So Seto El Kahfi's reply to my very old question led me to do some more research and reading on Apache's website.
So what I got is this, my NameVirtualHost directive was improper.
So Instead of this,
NameVirtualHost project:81
<VirtualHost project:81>
DocumentRoot "D:/work/website"
ServerName project:81
<Directory "D:/work/website">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
What I had to do was this.
NameVirtualHost *:81
<VirtualHost *:81>
DocumentRoot "D:/work/website"
ServerName project
<Directory "D:/work/website">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
Notice the ' * ' , I could have used an IP Address there too.(In this case my server's(machine A) local IP) both work. Now all I had to do is enter "project:81" on the client machine, and I get what my eyes wished to see.. :)
Few things I got from this.
1) How to use NameVirtualHost(or what it's purpose basically is.). Read More here
http://httpd.apache.org/docs/2.2/mod/core.html#namevirtualhost
This one is also good http://www.thegeekstuff.com/2011/07/apache-virtual-host/
2)You can use this via command line:
httpd -D DUMP_VHOSTS
to know how your virtual hosts are setup(will also give you some warnings regarding precedence if something's wrong with your setup)
3)Other's gesture to help you makes you help yourself.. :) So keeping helping and rocking.
Have you try to include the port at your client host's file?
192.168.1.7:81 project