Multiple virtual hosts on localhost for development [closed] - apache

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I'm using Xampp (Apace 2.2.20) on mac os lion for development. I have a number of CMS projects and i want to access them by going to cms1.localhost, cms2.localhost, cms3.localhost etc
Currently, with the setup I have below, everything goes to whatever is in the first virtual hosts directive ie (/Applications/XAMPP/migration/trunk).
Can anyone please point me in the right direction. I can't think what else to do in terms of debug etc so that help would be useful too. Thanks a lot.
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Applications/XAMPP/migration/trunk"
</Virtualhost>
<VirtualHost *:80>
ServerName rix.localhost
DocumentRoot "/Applications/XAMPP/projects/giving"
</Virtualhost>
In /etc/hosts I have
127.0.0.1 localhost
127.0.0.1 rix.localhost

For troubleshooting purposes, try swapping the VirtualHost declarations, confirm that the file is the correct one, and restart Apache.
They're all simple things, but best to check there first.

Related

Apache Virtual Host doesn't work [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I'm trying to get Apache Virtual Host to work but it wont catch the domains and goes out on the internet instead.
I've enabled the Virtual Host in the Config file:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
My httpd-vhosts.conf file looks like this:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "//nas/Web Design/Sites"
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#fdn.dk
DocumentRoot "//nas/Web Design/Sites/Fdn"
ServerName fdn.dk
ServerAlias www.fdn.dk
ErrorLog "logs/fdn/error.log"
CustomLog "logs/fdn/access.log" common
</VirtualHost>
http://Localhost works fine but when i type fdn.dk or www.fdn.dk the browser tries to find the site on the internet instead of looking at my local folder.
What is wrong...??
I tried to find a solution on the internet but without luck.
Do I need to change something in the host file ???
Kind Regards
Flemming
Yes, you need to add that domain name to /etc/hosts file if you are using an operating system that has it.
Or to C:\WINDOWS\system32\drivers\etc\hosts if you are using Windows.
Example of record:
127.0.0.1 www.fdn.dk

Can't link URL with virtual host [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am really new to servers and apache however I've been struggling for a while now and maybe somebody can help me.
So I have set up an apache server that works (if I use the IP address I can reach the website and it works properly). I have linked the url with the nameservers and my virtual host file looks like (located in /etc/apache2/sites-available/mysite)
<VirtualHost 12.34.56.78:80>
ServerAdmin admin#mysite1.com
ServerName mysite1.com
ServerAlias www.mysite1.com
DocumentRoot /srv/www/mysite1.com/public_html/
ErrorLog /srv/www/mysite1.com/logs/error.log
CustomLog /srv/www/mysite1.com/logs/access.log combined
</VirtualHost>
The weirdest thing is it worked yesterday and in the meantime I only installed an FTP server ... Any ideas of what I might have done wrong?
Thank you
If this is on Debian, you also need to link your config file in /etc/apache2/sites-available to /etc/apache2/sites-enabled, to let the config scripts know that the file is not only available, but also enabled.
Another thing might want to check is NameVirtualHost 12.34.56.78:80 directive somewhere in Apache config (or, optionally NameVirtualHost *:80).

How to remove port number from http://localhost:8123 to use as http://localhost? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I had to change my default apache port number 80 to 8123 (just random number)
I changed the following files ..
httpd.conf
Listen 8123
ServerName localhost:8123
httpd-vhosts.conf
NameVirtualHost *:8123
<VirtualHost *:8123>
ServerName localhost
DocumentRoot "C:/xampp/htdocs"
DirectoryIndex index.php
</VirtualHost>
Windows Hosts file
127.0.0.1:8123 localhost
::1:8123 localhost
I am using Windows 7.
After making all these changes, I restarted apache but I am still unable to access http://localhost .... however http://localhost:8123 works fine ... can someone help me find what I am doing wrong here? thanks
The only way to do this is to change back to 80, or to install a listener on port 80 (like a proxy) that redirects all your traffic to port 8123.
When you enter a server name without a port, port 80 is assumed by default. AFAIK, there is no way to change this behaviour without changing your browser's source code.
The hosts file does not support the kind of redirection you are trying to do. The rules simply fail.
Edit: ah, it might be possible to change the default port in some browsers. Here's an article in MozillaZine for Firefox.
You can remove it with proxyPass and proxyPassReverse
<VirtualHost *>
ServerName localhost
ProxyPass / http://127.0.0.1:8123/
ProxyPassReverse / http://127.0.0.1:8123/
</VirtualHost>

Server name for apache virtual host isn't working properly [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I'm trying to create a virtual host in apache so I can access a local site via localhost but using a different port than the default :80, what I want is that http://localhost:8080 loads my site directly in the folder I specify, I have the following set up in my httpd-vhosts.conf file which is working partially:
Listen 8080
NameVirtualHost *:8080
<VirtualHost 127.0.0.1:8080>
DocumentRoot "c:\wamp\www\trend\public"
ServerName local.trend
</VirtualHost>
If I go to http://localhost:8080 the page loads fine but if I go to http://local.trend then it just shows me the same as if I go to http://localhost is there any way to change it so it works with the server name as well?
Should I edit my hosts file? I currently have:
127.0.0.1 localhost local.trend
Your hosts file is correct as it stands now.
If you want http://local.trend to go to the same target as http://local.trend:8080 (which is what you have configured above), you'll need to add a separate VirtualHost for that host on port 80:
<VirtualHost 127.0.0.1:80>
DocumentRoot "c:\wamp\www\trend\public"
ServerName local.trend
</VirtualHost>

Apache on localhost: give virtual hosts specific servers name [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Ok, I ask my question first and below are details of what I have so far trying to solve the thing:
On Apache running on localhost, I want to have different virtual hosts that would be accessible through url:
http://name-of-the-virtual-host.name-of-the-machine/
Details:
So I have Apache running on port 8080 of my laptop. Linux Mint, so Debian distro. Everything is in local for testing purposes, so no DNS involved! The IP address I use is 127.0.1.1 which has the domain of my computer, called fabjoa. On the file /etc/apache2/apache2.conf, I've put:
ServerName fabjoa
In the file /etc/hosts, there is indeed the line
127.0.1.1 fabjoa
In the file /etc/apache2/ports.conf
NameVirtualHost *:8080
Listen 8080
Now, the conf file of my virtual host. The file is called is goyahkla and is located on /etc/apache2/sites-available/ and has a symbolic link in /etc/apache2/sites-enabled. On this file, I have the following:
<VirtualHost *:8080>
ServerName goyakhla.fabjoa
ServerAdmin webmaster#localhost
DocumentRoot /var/sites/goyahkla
....
<Directory /var/sites/goyahkla/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
...
</VirtualHost>
Running apache2ctl configtest gives me Syntax OK. Now, on browser, opening http://fabjoa:8080/ does point to the Virtual Host goyahkla (beacause that's the only one I have), but http://goyahkla.fabjoa:8080 is not found. Other debugging:
telnet goyahkla.fabjoa:8080
telnet: could not resolve goyahkla.fabjoa:8080/telnet: Name or service not known
lynx goyahkla.fabjoa:8080
Looking up 'goyahkla.fabjoa' first
Looking up 'www.goyahkla.fabjoa.com', guessing...
Looking up goyahkla.fabjoa first
Looking up www.goyahkla.fabjoa.com, guessing...
Looking up www.goyahkla.fabjoa.com:8080
Making HTTP connection to www.goyahkla.fabjoa.com:8080
Alert!: Unable to connect to remote host.
lynx: Can't access startfile http://www.goyahkla.fabjoa.com:8080/
Any idea on how purpose could be achieved?
Thank you
Don't you need to specify full hostname un hosts file? Like "goyahkla.fabjoa" instead of "fabjoa"?
Anyway, this is not programming question and should be asked on serverfault.com