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
Related
i just installed apache by source installation, so after i create virtual host my apachectl doesn't restart, start, stop. My webserver is working i can access but these commands sends me back "illegal option ExeCGI"
This is Virtual host code:
<VirtualHost *:80>
DocumentRoot "/usr/local/apache/htdocs"
ServerName node.iplaygrid.com
<Directory "/usr/local/apache/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Thanks.
Looking at the docs: This option is in a module (mod_cgi). Unless that's active, you won't have the directive available. As you built from source, you'd likely also need to build the modules from source, and definitely load them (or rather: it)
I'm having a lot of trouble setting up a local website that I need to do some work on.
I have 2 local sites: "first_training" and "resus_skills"
The former, first_training, works. I have it set up that first_training.loc/ takes me to the local site. resus_skills is set up in the exact same way, but when I try to access resus_skills.loc/ all I get is:
Here are the details of my setup, as well as some screenshots of it:
/etc/apache2/sites-available/resus_skills.conf :
<VirtualHost *:80>
ServerName resus_skills.loc
ServerAlias www.resus_skills.loc
DocumentRoot "/var/www/resus_skills"
<Directory "/var/www/resus_skills">
Options Indexes FollowSymLinks MultiViews
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I made sure to enable it with sudo a2ensite resus_skills.conf and have confirmed that it's symlink is present in ``/etc/apache2/sites-enabled`
I've made sure my apache server is running:
and I've run apachectl -S to get this result:
I am able to reach first_training.loc/ with no issues, but cannot reach resus_skills.loc/.
I'm unsure how to troubleshoot this - the apache error.log isn't showing me anything.
Before anyone points out what an idiot I've been - I never updated the /etc/hosts file, which was the only missing step.
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
I set up a virtual host on computer A by doing this:
Open apache config file (httpd.conf), insert lines as below:
<VirtualHost 127.0.0.1:80>
<Directory "{$path}/www/design-report/public/">
Options Indexes FollowSymLinks
AllowOverride FileInfo
Order deny,allow
Allow from all
</Directory>
ServerName weeklyreport.abc.com
ServerAlias www.weeklyreport.abc.com 127.0.0.1
DocumentRoot "{$path}/www/design-report/public/"
</VirtualHost>
Then I added a line as below to system32/drivers/etc/hosts:
127.0.0.1 weeklyreport.abc.com
By now on computer A I'm able to access weeklyreport.abc.com just into the right folder. I want to access this address from another computer named B.
So I changed the hosts file on B by adding A's IP like this:
192.xxx.5.xx weeklyreport.abc.com
Now I can access weeklyreport.abc.com from computer B.
But the problem is, it isn't the right folder. By this IP I can only access {$path}/www, not "{$path}/www/design-report/public/".
How can I fix this? Did I miss anything?
You missed the fact that VirtualHost definition tells apache to make virtual host only on given IP. It doesn't match for the external IP. You either need to defined second virtual host or use NameVirtualHost. For more details see Apache docu
HTH,Jan
I have a linux server that I do all of my web development on. I cant find an example of a virtual host.
I need a way to set virtual hosts (i think) so that even when i am running http://dev.example.com/blah i need that URL to be treated as a different site.
I know that i cannot use sub domains because to access the server I have to navigate through a sub domain.
If you need any clarifications please ask.
Virtual hosts are set using a <VirtualHost> section in apache configuration file(s) generally being httpd.conf,apache2.conf.It looks like
<VirtualHost *:80>
ServerAdmin webmaster#dev.example.com
ServerName dev.example.com
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
You can change DocumentRoot as per your convenience.
In few versions of distros such different sections of main trivial configuration file httpd.conf are segregated to separate files.
For example apache2 on latest ubuntu has separate files per virtual host located at /etc/apache2/sites-enabled/
You may find 000-default already in this directory which sets the default host(localhost)
You may copy it and start editing to define a new virtual host.With above snippet you will be configuring new host. Key point is setting DocumentRoot to a different directory for dev.example.com to configure as a different site.
I assume your dev machine is able to resolve what is set for ServerName else you may want to configure it too in /etc/hosts on debian based linux.