How to setup name based virtual host using yast in open suse? - apache

Im trying to setup virtual host under open suse. Im in Yast->Http server, when i check "Determine Request Server by HTTP Headers" I got error message To use name-based virtual you must designate the ip adress on the server(...)
I did some googling and according to what i found i uncommmented the NameVirtualHost *:80 line in /etc/apache2/listen.conf and restarted apache but it id not help. How can i setup it propely(maybe I should do it through yast without manually editing conf files but i can't find that option)

The problem I encountered was occurring because I have NameVirtualHost *:80 in listen.conf and example.com:80 in ServerName but they must be exactly the same.
PS it's still not working as expected when I set NameVirtualHost example.com:80 and then try to add server with ServerName example.com:80 I still get mentioned error message. Of course I got example.com in my hosts file pointing to 127.0.0.1

Quite outdated question but in case someone encounters it:
1) I added
NameVirtualHost my_virtual_hostname_here.tld:80
before <VirtualHost ... section
2) changed
<VirtualHost *:80> to <VirtualHost my_virtual_hostname_here.tld>
That did the trick for me. Of course as mentioned #Lord_JABA don't forget to add 127.0.0.1 my_virtual_hostname_here.tld to /etc/hosts

Related

ServerName for local Apache2 instance

I wanted to create my own self signed SSL certificate and add it to the local Apache2 instance (i.e. changing http://localhost/ to https://localhost/). However, I'm stuck at the part on what to put under the server IP in default-ssl.conf file. I'm referring to this resource to create the SSL certificate. I tried putting "127.0.0.1", "localhost" and the private IP address (in this case it's 10.0.2.15) under the "ServerName" part. However, it's still failing with the following error.
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
(13) Permission denied: make_sock: could not bind to addres 0.0.0.0:80
no listening sockets available, shutting down
Can anyone please give some hints on what went wrong? I'm running out of ideas (or things to google) why the server name is wrong...
The first few lines of my default-ssl file:
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin temp#temp.com
ServerName localhost
Ironically the issue seems to have resolved by itself... Not too sure what happened but now I'm facing another issue (which I posted on Unable to change the document root of https://localhost/)
I kept the code as it is:
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin temp#temp.com
ServerName localhost

CentOS 6.5 + Apache Virtual Host

I have installed CentOS 6.5 on my VPS (IP 149.210.167.9). Eventually I want to serve multiple domains, but for now I only want to handle 1 domain in particular: aforismo.eu. When you surf to the IP directly it shows me an Apache test page, so that works. When I ping aforismo.eu it shows me the correct IP, so I think the DNS is setup correctly. If I'm missing something trivial, please teach me :)
What I did so far to handle this domain:
I) I've created /etc/httpd/conf.d/site-aforismo.conf
<VirtualHost *:80>
ServerAdmin webmaster#aforismo.eu
DocumentRoot /var/www/aforismo.eu/public/
ServerName aforismo.eu
ServerAlias *.aforismo.eu
ErrorLog logs/aforismo.error_log
CustomLog logs/aforismo.access_log common
</VirtualHost>
II) Modified a few bits in /etc/http/conf/httpd.conf:
Include conf.d/*.conf
NameVirtualHost *:80
III) Afterwards I've restarted apache
service httpd restart
IV) Checking httpd -S results in:
wildcard NameVirtualHosts and _default_ servers:
_default_:443 vps.vanoosten.me (/etc/httpd/conf.d/ssl.conf:74)
*:80 is a NameVirtualHost
default server aforismo.eu (/etc/httpd/conf.d/site-aforismo.conf:1)
port 80 namevhost aforismo.eu (/etc/httpd/conf.d/site-aforismo.conf:1)
wild alias *.aforismo.eu Syntax OK
But ... surfing to http://www.aforismo.eu (or http://aforismo.eu) does not work. Since it's not my everyday business, I'd sure miss something quite trivial, but I can't find out what it is. Can you help me a bit further? Much appreciated.
You may need to add Listen *:80.
You may also need to add UseCanonicalName off under <VirtualHost *:80>.
Edit:
Unless it's meant to be internal only, there is something wrong with your DNS. I can hit the IP but aforismo.eu doesn't resolve to anything.
Update: As you guys suggested, it turns out to be a DNS issue. I thought I had created an A record to the given IP. But ... in the interface of my DNS provider I had to use the #-character for the domain itself instead of to really write it down. So what I really created was an A-record for aforismo.eu.aforismo.eu. Fixed (and next time I promise to read the manual :P)

NameVirtualHost Works on IP but not for ServerName?

I am a beginner to Apache and have been trying to create virtual hosts but I come across a very odd issue. When the site is requested using the IP defined in the configuration, the virtual host works perfectly but when the name of the server is used it does not work.
Here is the configuration file which is an included file:
Listen 80
NameVirtualHost 192.168.1.5
<VirtualHost 192.168.1.5>
ServerName host1.localhost
DocumentRoot "C:/Program Files (x86)/Apache Group/Apache2/virtualHost1"
</VirtualHost>
In the browser I go to 192.168.1.5 and the index file for the Virtual Host appears but when I go to host1.localhost it doesn't work.
Any help is very appreciated, good day to all.
First you should try to see if your computer resolve host1.localhost hostname.
May be just try to ping it in your console: ping host1.localhost
If your computer is unable to resolve host1.localhost, as I suppose, then try to add it in your hosts file.
Hint: you'll find hosts file in C:\Windows\System32\drivers\etc directory
What do you mean by "it doesn't work".
1)Check your DNS settings, do you have record for host1.localhost pointing to 192.168.1.5?
2)Try using ServerAlias also
3)Check if there is another declaration for hosts1.localhost (by another ServerAlias)
I guess the most likely reason is 1)

Connection to localhost fails

I set up /etc/apache2/extra/httpd-vhosts.conf as follows:
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Library/WebServer/Documents/
</VirtualHost>
In /Library/WebServer/Documents/ is the standard index.html.en file which was shown perfectly in the browser before I included the httpd-vhosts.conf into my httpd.conf.
The connection to localhost fails using both, Chrome and Firefox. Is the setup correct? What else could go wrong?
I solved the problem. I couldn't state further information because I just didn't know where I could look for the problem. This post put me in the right way:
http://macosx.com/forums/mac-os-x-system-mac-software/299851-apache-wont-start-up.html
sudo apachectl configtest
Gave me an syntax error within the httpd.conf file. After fixing it everything worked. The important thing is the opportunity to run a configtest.

creating Subdomain in Xampp doesn't work

I made a subdomain on Localhost over Xampp with following code in httpd-vhosts.conf (guide from different sources)
NameVirtualHost *:80 (uncommented by removing #)
<VirtualHost *:80>
DocumentRoot C:/xampp/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:/xampp/htdocs/sub
ServerName sub.localhost.com
</VirtualHost>
and following code into hosts of Windows/System32/drivers/etc/
127.0.0.1 localhost
127.0.0.1 sub.localhost
now the problem is subdomains are not working. One more thing I just noticed that when I start apache service in Xampp Control Panel, it has set the port as 80,443 for Apache which is good but as soon as I hit localhost in browser it changes port to different ports like 52352 etc. I also tried to setting up code in hosts file as
127.0.0.1:80 localhost
127.0.0.1:80 sub.localhost
but not working. I tried many other things but all in vein. While a month before I created successfully in the same Xampp Installation. off course i have created sub directory in htdocs.
Make sure you have this line uncommented in httpd.conf
#Include conf/extra/httpd-vhosts.conf
Remove this line in httpd-vhosts.conf (or comment it out):
NameVirtualHost *:80
Make sure you have a blank line at the end of both httpd-vhosts.conf and hosts, and make sure you're using tabs to separate IPs with their associated domains in the hosts file.
Make sure another application is not using ports 80, 443 (Skype for example).
Ultimately, restart your Apache server.
If you want to create sub directory, *emphasized text*127.0.0.1:80 localhost*emphasized text*
the settings back to original and change only *emphasized text*DocumentRoot C:/xampp/htdocs/sub*emphasized text*