Virtualhost on macos mamp ERR_CONNECTION_REFUSED - apache

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.

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).

Virtual host will NOT work in MAMP but works on localhost:8888

Created a new Laravel project in htdocs in MAMP. Followed all the steps, added virtual hosts, changed conf file, etc/hosts, restarted mamp and my pc several times but I just can't get my virtual host to run.
however, when I am in the MAMP Dashboard I can navigate to my website -> website -> public and the default Laravel boilerplate page appears.
Has anyone had this issues with MAMP before? I gave up with XAMPP and Valet so it's my last chance here..
Specs
High Sierra 10.13.5 on 2015 MBP,
Composer version 1.6.5,
php 7.2.7
httpd.conf
# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
httpd-vhosts
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "Applications/MAMP/htdocs/website/public"
ServerName website.dev
</VirtualHost>
etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
#255.255.255.255 broadcasthost
#::1 localhost
127.0.0.1 website.dev
website.dev is technically a public url, so the browser is looking for it on the internet I guess. I was trapped once in this dreadful situation. changing the name to something like website.local should solve your issue. It did 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.

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.

Set up Virtual Host, can no longer access 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'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