WAMP server name not found for virtual host in apache - apache

System: Windows7 64-bit
WAMP server 32-bit version: Apache : 2.4.9 MySQL : 5.6.17 PHP : 5.5.12 PHPMyAdmin : 4.1.14 SqlBuddy : 1.3.3 XDebug : 2.2.5
My issue is that when I navigate to my project "local.blamo1.com" - via WAMP "Localhost" chrome returns: "Oops! Google Chrome could not find local.blamo1.com"
I am able to access my project folder with "localhost/local.blamo1.com" - But as I understand it, this is bad practice as it will throw off server mapping by one directory. I would like to be able to access the project with the designated server alias. I have implemented the following...
httpd-vhosts.conf
Location: "C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.config"
# Virtual Hosts
#
# Required modules: mod_log_config
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
<VirtualHost *:80>
DocumentRoot "c:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "c:/wamp/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/local.blamo1.com"
ServerName local.blamo1.com
ServerAlias local.blamo1.com
<Directory "c:/wamp/www/local.blamo1.com">
AllowOverride All
Require local
</Directory>
</VirtualHost>
hosts file
Location: "C:\Windows\System32\drivers\etc\hosts"
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
127.0.0.1 localhost
127.0.0.1 local.blamo1.com
#::1 localhost
#::1 local.blamo1.com
httpd.conf
Location: "C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf
I have un-commented these lines
Include conf/extra/httpd-vhosts.conf
LoadModule vhost_alias_module modules/mod_vhost_alias.so
Current Diagnosis
Apache httpd -t return: "Syntax OK"
I think this has something to do with my DNS or ports, or whatev - as I do not have enough experience with this level or how the DNS is not able to resolve the domain:
after I tried to ping the project:
ping local.blamo1.com
"Ping request could not find host local.blamo.com. Please check the name and try again.
Please help me understand why I am getting this issue. I have been working on this for a day and a half. Apologies if there is not adequate information for your to make a diagnosis of the problem. I will provide more information as necessary.
All my best.

I was able to solve this issue - props to this post: http://www.tweaksforgeeks.com/windows7/2011/02/windows-7-hosts-file-ignored
The issue appeared to be a corrupted "hosts" files - all I know for sure was that the solution was to delete the hosts file and create a new one with raw text from the old. The causality is inexplicable.

This solve my problem. After hours of making it work. Turns out I was careless about the host file. Saving as txt and then just removing the extension to replace the original file.

Related

Virtualhost on macos mamp ERR_CONNECTION_REFUSED

I have a Mac under MacOS Big Sur (when I had Catalina, the problem was also present) with MAMP
I would like to create a virtual host
Here is what I did:
in Application/MAMP/conf/apache/httpd.conf, I uncommented the line
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
in /private/etc/hosts I added
127.0.0.1 test.deva
127.0.0.1 test.localhost
here is my Application/MAMP/conf/apache/httpd-vhosts.conf file
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
NameVirtualHost *
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:8888>
DocumentRoot /Aplications/MAMP/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:8888>
DocumentRoot "/Applications/MAMP/htdocs/testhost"
ServerName test.deva
ServerAlias www.test.deva
</VirtualHost>
In the parameters of MAMP I checked, I have the port 8888
In htdocs/testhost I just have an index.html file
i tried a lot of things i saw here on posts where the problem was the same
But I still have an ERR_CONNECTION_REFUSED error
How to do it please?
I faced the same issue on macOS Big Sur with a Docker setup for local web development.
It turned out the problem was that port 80.
Changing the configuration to listen on port 8080 solved the issue for me.

Apache Server Unable to host multiple domain on single Public IP Error : "Not Found The requested URL / was not found on this server."

Apache Server Unable to host multiple domain on single Public IP running on Windows Server 2016
Error:"Not Found The requested URL / was not found on this server." 404 Not Found
Progress so far :
1)Edited Windows hosts file "C:\Windows\System32\drivers\etc\hosts": to below
127.0.0.1 localhost
::1 localhost
127.0.0.1 koffeeroasters.com
2)Changes made in the httpd.conf file of apache is below
changed
#Include conf/extra/httpd-vhosts.conf
to
Include conf/extra/httpd-vhosts.conf
also changed
#LoadModule rewrite_module modules/mod_rewrite.so
to
LoadModule rewrite_module modules/mod_rewrite.so
and added to the end of the file the following
# Tells Apache to identify which site by name
NameVirtualHost *:80
# Tells Apache to serve the default WAMP Server page to "localhost"
<VirtualHost 127.0.0.1>
ServerName localhost
DocumentRoot "C:/wampstack/apache2/htdocs"
</VirtualHost>
# Tells Apache to serve Client 1's pages to "client1.localhost"
# Duplicate and modify this block to add another client
<VirtualHost 127.0.0.1>
# The name to respond to
ServerName koffeeroasters.com
ServerAlias www.koffeeroasters.com
# Folder where the files live
DocumentRoot "C:/wampstack/apache2/htdocs/koffeeroasters.com/"
# A few helpful settings...
<Directory "C:/wampstack/apache2/htdocs/koffeeroasters.com/">
Order Allow,Deny
Allow from all
# Enables .htaccess files for this site
AllowOverride All
</Directory>
# Apache will look for these two files, in this order, if no file is specified in the URL
DirectoryIndex index.html index.php
</VirtualHost>
Other details
I am using apache server on bitnami wampstack.
Site is available when typed the address "koffeeroasters.com" from the servers browser.
A reason for it which I know no solution of (refered from apache docs "https://httpd.apache.org/docs/2.4/vhosts/examples.html") :
Note :
Creating virtual host configurations on your Apache server does not magically cause DNS entries to be created for those host names. You must have the names in DNS, resolving to your IP address, or nobody else will be able to see your web site. You can put entries in your hosts file for local testing, but that will work only from the machine with those hosts entries.
Thanks a bunch. All help appreciated.
Try changing this:
<VirtualHost 127.0.0.1>
to
<VirtualHost *:80>
This means allow any other IPs connect on port 80, which should get you going. Trying to match the localhost is doing more than you probably need, unless you are public facing server, in which case you will not want to do this.

Write DNS instead of IP?

I'm working on a project and I would like to make some things in order to be able to handle easier my distant server.
I have a server on which one I installed an API (dolibarr - ERP/CRM software).
This server uses Ubuntu 14.04 and Apache2.
When I want to connect to my software from the net, I open Firefox for example, I write http://172.30.10.XX and I am going to the application login page.
But I would like to create a DNS and domain name in order to connect it easier.
For example :
http://shopmoriba.datasystems.fr instead to write the IP address.
My question is : How I can do that ?
I know that I need to modify some files : /etc/apache2/sites-available/000-default.conf or /etc/hosts but what I need to write exactly ?
My /etc/hosts file looks like :
127.0.0.1 localhost
//127.0.1.1 dolibarr
172.30.10.69 shopmoriba.datasystems.fr
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
My /etc/apache2/sites-available/000-default.conf looks like :
<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
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/
# 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}/error.log
CustomLog ${APACHE_LOG_DIR}/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>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Thank you by advance
There should be no need to touch the /etc/hosts on your server.
The important thing to make this work is to make the name known to all clients that want to access your application. To do this you basically have two possibiliies:
Add an entry to all /etc/hosts (on windows this is C:\Windows\System32\drivers\etc/hosts) on all clients that are meant to access your application. Doing it this way is not recommended
Add a DNS-record for shopmoriba.datasystems.fr in some DNS-server that will be accessed by all clients that are meant to access the application. If this is solely for internal use go with some DNS-server on your network, perhaps there already is one. If you want to make the application publicly available there is no way around registering an official domain and publishing the hostname via the associated DNS-server.
While you only run one application on your server this will be sufficient. Once you start adding other application that you want to publish under a different hostname you will have to add more <VirtualHost>-sections and add a ServerName-line like
`ServerName shopmoriba.datasystems.fr`
to the respective VirtualHost-configuration.
I ommited the topic of using https since you did not mention you want to use it and especially on servers hosting multiple vhosts it is enough for a separate topic.
You can add the entry to /etc/hosts in the following format:
172.30.10.XX shopmoriba.datasystems.fr
Bear in mind that this will only work on the local machine where the hosts file has changed.

XAMPP gives Forbidden 403 for everything but phpmyadmin

Long story short: I installed Windows 7 on my laptop everything is fine with OS. I installed latest xampp. What i did next via help of google and stackoverflow:
system32/drivers/etc/hosts
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
::1 localhost
127.0.0.1 local.projects
httpd-xampp.conf (allow from all is commented couse it totally had no effect at all).
#
# New XAMPP security concept
#
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
Deny from all
Allow from ::1 127.0.0.0/8 \
fc00::/7 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 \
fe80::/10 169.254.0.0/16
#Allow from all
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>
And the main couse for the 403 being retrieved everywhere is i think THIS in httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot "D:/Web-Pages"
ServerName local.projects
ServerAlias local.projects
ErrorLog "logs/local.projects.log"
CustomLog "logs/local.projects.log" combined
<directory "D:/Web-Pages">
AllowOverride All
Allow from all
Require all granted
</directory>
</VirtualHost>
If there is anyhow you can point me to the right direction i would be very glad!
More info:
When i type in addressbar this "local.projects" or this "localhost" I get 403 like that:
Access forbidden!
You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
If you think this is a server error, please contact the webmaster.
Error 403
localhost
Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.6
Okay, but when i access phpmyadmin at "localhost/phpmyadmin" everything works fine. When i add pressmission to the folders via Windows- nothing changes. Suggest any ideas how to get rid of these 403's please?
Do you have any pages in D:/Web-Pages directory? If this directory has no index page then it will show you 403 error.
If you have any page like, index.htm then try to browse http://localhost/index.htm.

Windows 7 Localhost not working properly with XAMPP

Hey there I'm running XAMPP on Windows 7 Ultimate 64bit and I'm having some issues with my localhost setup, and i've been trawling the internet for ages trying to get this fixed but to no avail.
My setup is as follows:
I've got apache and mysql running on XAMPP no problem, and I've edited my hosts file no problem, ensuring i've used admin privileges in note pad etc and that its not saved as a .txt file etc. It currently looks like this:
# Copyright (c) 1993-2006 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handle within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 localhost
127.0.0.1 legendary-games.localhost
127.0.0.1 admin.legendary-games.localhost
127.0.0.1 shuuro.legendary-games.localhost
127.0.0.1 yearzero.legendary-games.localhost
127.0.0.1 chess.legendary-games.localhost
I've also made sure to make all the necessary changes to my vhosts file in apache and its all pointing to the correct address.
Now when I type localhost into my browser I get the page I'm meant to, however if I try any of the of the other addresses I get a page not found. I've tried pinging the addresses in the commandprompt and that comes back successful. I've tried many different things to try and get this working including flushing the dns, rebooting the dns, I've checked that the hosts file is being looked up properly by the services but to no avail.
Any help would be most appreciated.
Okay, here is the solution maybe this helps you.
Add this line or uncomment from file httpd.conf found on your apache folder -> conf
Include conf/extra/httpd-vhosts.conf
Edit httpd-vhosts.conf found on your apache folder -> conf -> extra
httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "your-htdocs-path/legendary-games-folder"
ServerName legendary-games.localhost
</VirtualHost>
Then, restart apache.