Error: "VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results" - windows

I'm running WAMP v2.0 on WindowsXP and I've got a bunch of virtual hosts setup in the http-vhosts.conf file.
This was working, but in the last week whenever I try & start WAMP I get this error in the event logs:
VirtualHost *:80 -- mixing * ports and
non-* ports with a NameVirtualHost
address is not supported, proceeding
with undefined results.
and the server won't start. I can't think of what's changed.
I've copied the conf file below.
NameVirtualHost *
<VirtualHost *:80>
ServerName dev.blog.slaven.net.au
ServerAlias dev.blog.slaven.net.au
ServerAdmin user#host.com
DocumentRoot "c:/Project Data/OtherProjects/slaven.net.au/blog/"
ErrorLog "logs/blog.slaven.localhost-error.log"
CustomLog "logs/blog.slaven.localhost-access.log" common
<Directory "c:/Project Data/OtherProjects/slaven.net.au/blog/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
EDIT: I meant to add, if I change the NameVirtualHosts directive to specify a port, i.e
NameVirtualHost *:80
I get this error:
Only one usage of each socket address (protocol/network address/port) is normally permitted. : make_sock: could not bind to address 0.0.0.0:80

NameVirtualHost *:80
I get this error:
Only one usage of each socket address (protocol/network address/port) is normally >permitted. : make_sock: could not bind to address 0.0.0.0:80
I think this might be because you have somthing else listening to port 80. Do you have any other servers (or for example Skype) running?
(If it was Skype: untick "Tools > Options > Advanced > Connection > Use port 80 and 443 as alternatives for incoming connections")

Well, it seems the problem there is the way (and order) in which you assign the ports.
Basically, *:80 means "use port 80 for all hosts in this configuration". When you do this, Apache tries to bind that host to 0.0.0.0:80, which means that host will receive every single packet coming to the machine through port 80, regardless of what virtual host it was intended to go to. That's something you should use only once, and only if you have one host in that configuration.
Thus, if you have the same *:80 directive on two hosts in the configuration file, the server won't load because it will try to bind 0.0.0.0:80 twice, failing on the second try. (which explains the "Only one usage of each socket address (protocol/network address/port) is normally permitted. : make_sock: could not bind to address 0.0.0.0:80" message).

Related

How to set up virtual hosts when changed the default port(80) to 8080?

I'm using MAMP on windows 10 and I couldn't start Apache server because of my default port(80) is used by System. So I changed the default port to 8080. But now I can't access my previously set up virtual host sites. Please help me
I already tried this :
1) MAMP\bin\apache\conf\httpd.conf
Listen 8080
2) MAMP\bin\apache\conf\extra\httpd-ssl.conf
<VirtualHost _default_:8080>
Listen 8080
3)hosts file
127.0.0.1:8080 mygym.test
4) MAMP\bin\apache\conf\extra\httpd-vhosts.conf
NameVirtualHost *:8080
<VirtualHost *:8080>
DocumentRoot "E:/MAMP/htdocs/mygym/system"
ServerName mygym.test
</VirtualHost>
now when I typed as mygym.test in the URL tab It comes a 404 error
No webpage was found for the web address: http://mygym.test/
You are doing it wrong.
3)hosts file
127.0.0.1:8080 mygym.test
The hosts file is for host name resolution only. You cannot put port numbers in there. the browser is what selects the port to choose.
Instead try 127.0.0.1 mygym.test in hosts file and try http://mygym.test:8080 in browser.

How to make a service on apache2 respond to request on multiple ports

I have a website that I have hosted in /var/www/html. I was able to access it using my.ip.add.res. Now I want to be able to access it from multiple ports. I mean all three URLs, my.ip.add.res:80, my.ip.add.res:8000 and my.ip.add.res:8950, in the browser should lead to the same website.
What I tried:
Step 1: In /etc/apache2/ports.conf file, Listen 80 was already there. I added Listen 8000 and Listen 8950. The file looks like:
Listen 80
Listen 8000
Listen 8950
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
Step 2: In /etc/apache2/sites-available directory, there was a file 000-default.conf. I copied it to two files: myservice1.conf and myservice2.conf. I changed the first statement, VirtualHost *:80> to VirtualHost *:8000> and VirtualHost *:8950> in myservice1.conf and myservice2.conf files, respectively.
Step 3: I established symbolic links of these files to the corresponding files in /etc/apache2/sites-enabled. This is what I mean:
root#virtual-machine:/etc/apache2/sites-enabled# ls -l
total 0
lrwxrwxrwx 1 root root 35 Jul 7 09:18 000-default.conf -> ../sites-available/000-default.conf
lrwxrwxrwx 1 root root 46 Aug 22 11:45 loginservice.conf -> /etc/apache2/sites-available/loginservice.conf
lrwxrwxrwx 1 root root 44 Aug 22 11:44 scfservice.conf -> /etc/apache2/sites-available/scfservice.conf
Step 4: Then I restarted the Apache2 server
root#virtual-machine:/etc/apache2/sites-enabled# /etc/init.d/apache2 restart
[ ok ] Restarting apache2 (via systemctl): apache2.service.
The result is:
my.ip.add.res : leads to correct website
my.ip.add.res:80 : leads to correct website
my.ip.add.res:8000 : Unable to Connect
my.ip.add.res:8950 : No such resource (even if I stop the server ... surprising)
What is it that I am doing wrong or missing?
Edit1: As suggested by jedifans, I tried apachectl -S. below is the output.
root#virtual-machine:/etc/apache2/sites-available# apachectl -S
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
*:8950 127.0.1.1 (/etc/apache2/sites-enabled/loginservice.conf:1)
*:8000 127.0.1.1 (/etc/apache2/sites-enabled/scfservice.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
Edit 2:
root#virtual-machine:/etc/apache2/sites-available# telnet 127.0.0.1 8000
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
root#virtual-machine:/etc/apache2/sites-available# telnet 127.0.0.1 8950
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
# gets stuck here. I have to ctrl + C to come out.
Listen 80
Listen 8000
Listen 8950
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot "/var/www/html"
</VirtualHost>
<VirtualHost *:8000>
ServerName www.example.com
DocumentRoot "/var/www/html"
</VirtualHost>
<VirtualHost *:8950>
ServerName www.example.org
DocumentRoot "/var/www/html"
</VirtualHost>
Make sure to use Document root to /var/www/html and also if you are adding this line at end of http.conf then their is no need to add in two separate files if you wish to keep in two separate files see to it that you have a
Include sites-available/*.conf
The above Include is true if you have ServerRoot as /etc/apache2/ inn your case
However a simpler way would be just add above configuration to end of http.conf file
The figured out what the problem was. All my steps were absolutely correct. However, there were already two services running on ports 8000 and 8950. I was able to get every port other than these two working.

How to point HostGator domain to EC2 AWS

We have an existing domain name
(ex. webdev.com)
located in hostgator and we have a server in AWS. We wanted to use the domain name that we bought from hostgator
(webdev.com)
in our AWS server.
What we did was, in hostgator we created a DNS (project1.webdev.com) and the address is pointing to our AWS server(ex 150.12.1.0). In our AWS, we deploy the project1 under port 4000.
Now if we access the
project1.webdev.com
we end up to the default apache page. How could we route it to our port 4000 so that everytime we access project1.webdev.com it pointed to our
150.12.1.0:4000
project.
here is our virtual host config:
<VirtualHost *:4000>
ServerName project1.webdev.com
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "/var/www/html/project1/web"
<Directory "/var/www/html/project1/web">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/4000-error_log
CustomLog ${APACHE_LOG_DIR}/4000-access_log common
We have looked for several information but we did not find any possible solution. Looking forward for your help.
Thanks
You're confusing DNS, which has to do with IP addressing, with ports, which have nothing to do with DNS. DNS only deals with converting between human-readable names and IP addresses. DNS does not provide any sort of provision to perform a task like "when a user wants to make an HTTP request use port 4000 instead of port 80".
If your service is listening on port 4000 but you're using the HTTP protocol (which always uses port 80 by default) then you will need to deal with this in one of the following ways:
Require all URL's to explicitly specify port 4000, for example: http://project1.webdev.com:4000
Change your VirtualHost definition to listen on port 80 instead of 4000
Add a new VirtualHost definition in Apache for port 80 that proxies all requests to port 4000
Sharing you the solution we made. Thanks to #Bruce for helping us out. As what he suggested in the comments above, we will create a virtual host porting to 80(which is the default of apache). Then we will route the port 80 to our specific project.
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerName project1.webdev.com
ServerAdmin webmaster#localhost
DocumentRoot "/var/www/html/project1/web"
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/project1-error.log
CustomLog ${APACHE_LOG_DIR}/project1-access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
If you have multiple DNS just create another instance of port 80 and route to the project.
Make sure that the Domain name in HostGator matches with the ServerName you created in the virtual host.

I cann't call my localhost by ip address

I am trying to call my xampp localhost from another computer's browser, I have changed host file at C:\Windows\System32\Drivers\etc by appending (192.168.1.105 localhost) at the end this file and save it and then restart computer, but I could not call my localhost from another computer.
Thanks
You need to access port forwarding in your router and forward port 80 only as TCP. Also, the host file code should look something like YOUR IP YOUR IP and not YOUR IP localhost. Furthermore, you need to edit httpd-vhosts.conf from apache folder in xampp instalation with something like that
<VirtualHost *:80>
ServerAdmin whatever#whatever.com
DocumentRoot "PATH TO YOUR FOLDER"
ServerName YOUR IP
ServerAlias YOUR IP
</VirtualHost>
After that you must restart apache in XAMPP control panel (MySQL not necessary)
THE SOLUTION ABOVE WILL LET YOU SEE YOUR CONTENT FROM ANYWHERE AS LONG AS YOUR LOCAL PC IS TURNED ON AND HAVE INTERNET CONNECTION. THE SOLUTION BELOW (I DIDN'T TEST IT, BUT I GUESS IT WILL WORK) WILL LET YOU ACCESS YOUR CONTENT FROM LOCAL NETWORK ONLY.
edit your httpd-xampp.conf file as following and after that you should probably need to perform a browser cache cleaning
# New XAMPP security concept
#
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
Order deny,allow
#Deny from all
#Allow from 127.0.0.0/8
Allow from all
ErrorDocument 403 /error/HTTP_XAMPP_FORBIDDEN.html.var
</LocationMatch>
When you add 192.168.1.105 localhost on the other PC (the one you want to use to view your website), it will look for a website on the same machine. Delete the entry from the hosts file and enter the IP address in your browser and it should work if the webserver is running.

VirtualHosts does not work on Mac OS 10.7

I want to create VirtualHosts on Mac OS 10.7 and therefore I edited the /etc/apache2/httpd.conf. I uncommented the line "Include /private/etc/apache2/extra/httpd-vhosts.conf" to include the virtual hosts. In the file /private/etc/apache2/extra/httpd-vhosts.conf I wrote the following:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/var/www"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/var/www/someFolder"
ServerName myApplication.dev
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/var/www/someOhterFolder"
ServerName myApplication2.dev
</VirtualHost>
There were two example virtual hosts before which I deleted. In my /etc/hosts file I added the following:
127.0.0.1 myApplication.dev
127.0.0.1 myApplication2.dev
I restarted my Apache and typed myApplication.dev and myApplication2.dev in the browser but I get an error "server not found" and it makes www.myApplication.dev in the browser (the same for myApplication2.dev).
Did I forget something to configure? I activated PHP in httpd.conf, mysql is installed also, but that has nothing to do with virtual hosts, I think.
Thanks for your help!
apachectl has an option -S to check vhost.conf file syntax. You can find these lines in vhosts.conf file.
> # You may use the command line option '-S' to verify your virtual host
> # configuration.
So, when you run
sh-3.2# apachectl -S
if you get Syntax OK result it means that there is no problem in your vhosts.conf file.
httpd: VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server zz.xxxx.com (/private/etc/apache2/extra/httpd-vhosts.conf:27)
port 80 namevhost zz.xxxx.com (/private/etc/apache2/extra/httpd-vhosts.conf:27)
port 80 namevhost yy.xxxx.com (/private/etc/apache2/extra/httpd-vhosts.conf:35)
Syntax OK
If conf file has any problem it will tell you error line(s) like
sh-3.2# apachectl -S
Syntax error on line 33 of /private/etc/apache2/extra/httpd-vhosts.conf:
CustomLog takes two or three arguments, a file name, a custom log format string or format name, and an optional "env=" clause (see docs)
make sure that your vhosts.conf file has true configuration.
I had the exact same problem using OS X Lion. I fixed it by adding "::1 myhost.dev" to /etc/hosts:
127.0.0.1 myhost.dev
::1 myhost.dev
Incidentally, the ::1 also fixes a bug that makes page loading very slow on virtual hosts served from the Mac.
Are you using an HTTP proxy? If so, make an exception for myApplication.dev and myApplication2.dev.
What I meant was that the problem "server mot found" means that your browser cannot find the ip adresses of the hosts "myapplication.dev". This may be because you're using an http proxy, possibly one configured by your hosting company. In any case, you don't even reach the server, so you never get to try the virtual host configuration at all.
To just try the virtual host configuration, you can use telnet in a Terminal window and talk HTTP directly to the server, like this:
yourmacbox:~ yourname$ telnet 127.0.0.1 80
You should see the following text:
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Then you type
GET / HTTP/1.0
Host: myApplication.dev
Now, hopefully you should see some response from your web server. This shows that once you can connect to it, the virtual hosts things works.
I had the same problem, and noticed that the ServerRoot "/usr" was set as shown and incorrectly after the 10.7 upgrade. The httpd.conf file was still under /etc/apache2, but this setting in it was pointing to the wrong place. Once I had fixed that by changing to ServerRoot "/etc/apache2", all my previous virtual host configuration got picked up properly.
I also had to re-enable virtual hosts by uncommenting line 477 as mentioned here http://brettterpstra.com/fixing-virtual-hosts-and-web-sharing-in-mountain-lion/ That didn't quite kick in until I had fixed the path issue above.

Resources