Set up Virtual Host, can no longer access http://localhost [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 10 years ago.
Improve this question
I've set up a virtualhost on WAMP. The address is http://privatesite (which works)
However, now that I have set up this virtual host, the default localhost does not work and I'm not sure how to rectify it.
My hosts file looks like this:
# 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 localhost
127.0.0.1 privatesite
My Apache httpd-vhosts.conf file looks like this:
#
# 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 *:80
#
# 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 *:80>
DocumentRoot "c:/wamp/www/privatesite/trunk/"
ServerName privatesite
ServerAlias privatesite
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/"
ServerName localhost
ServerAlias localhost
</VirtualHost>
As you can see, I have tried to "resetup" the localhost, however, it all seems to point to my "privatesite" folder now it seems.

VirtualHost *:80 is like a catch all. You will need to either name your "privatesite" something else or add NameVirtualHost entries for localhost or 127.0.0.1.
http://httpd.apache.org/docs/2.2/vhosts/examples.html

Related

How do I point a folder with an express app to my apache 000-default.conf file on Ubuntu?

I currently have a domain, and want to point my folder to my apache config file, to then use certbot, but I dont know how to exactly point it. So far I've done:
<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 mydomain.org
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/bfia
#..other stuff
</VirtualHost>
Where /var/www/html/bfia is the directory of the express app and the rest of the needed files. As of right now, the only page that appears is the default apache page.
You have to allow or deny access to that directory using the "Directoiry" module (https://httpd.apache.org/docs/2.4/sections.html). You also need to configure the directoryIndex to define which file read and present to the client (https://httpd.apache.org/docs/2.4/mod/mod_dir.html#directoryindex).

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.

Can't access apache2 virtualhost from another computer [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 2 years ago.
Improve this question
I am running an apache2 webserver from my computer and when I access the site from my computer,
it works just fine, but when I try to access it from another machine(that runs windows), the browser outputs, that the site can't be reached.
Here is my site config file:
<VirtualHost 192.168.1.96>
# 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/example
ServerName www.example.com
# 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>
Here is my /etc/hosts file
127.0.0.1 localhost
127.0.1.1 puter
127.0.1.1 noreply.com
192.168.1.96 www.vk1.com
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
I have tried restarting apache and disabling and enabling the site, but that didn't work.
Has anyone encountered such problems before?
The /etc/hosts file provides host to IP address mappings for the computer it lives on.
Your Windows computer is not going to read the data from your Linux computer's /etc/hosts file in order to know that it needs to make requests to 192.168.1.96 when it is asked to make a request to www.vk1.com.
You need to either:
Configure that mapping in the DNS server for your LAN
Put that information in the hosts file on the Windows computer

WAMP server name not found for virtual host in 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.

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.