Add Virtual Host in Apache Windows 10 - windows

I am trying to add Virtual Hosts with SSL certificates to Apache on a Windows 10 environment.
It is my first time using Apache (total newb!), and have done my basic setup using online tutorials and blogs. My Apache service is running, and I am able to get the correct response when typing localhost in the browser. However, when I add my new Virtual Host, and try to restart the Apache service, it fails (Error 1067: The process terminated unexpectedly).
The problem seems to be with my SSL certificates in the setup. When I delete the certificate lines in the code below, the Apache service restarts with no problem. However the new Virtual Host does not open/resolve. I think this is due to the required certificates(?).
Here is my code:
In my httpd-vhosts.conf
<VirtualHost *:443>
ServerAdmin name#domain.co.za
ServerName odyssey.rain.network
ServerAlias odyssey.rain.network
DocumentRoot c:/Apache24/htdocs/odyssey.rain.network
SSLEngine on
SSLCertificateFile c:/Apache24/ssl/network/server.crt
SSLCertificateKeyFile c:/Apache24/ssl/network/rain.key
SSLCertificateChainFile c:/Apache24/ssl/network/ca.crt
ErrorLog logs/odyssey.rain.network-error.log
CustomLog logs/odyssey.rain.network-access.log combined
<Directory c:/Apache24/htdocs/odyssey.rain.network>
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin name#domain.co.za
ServerName odyssey.rain.network
Redirect / https://odyssey.rain.network
</VirtualHost>
I have also updated my hosts file with: 127.0.0.1 odyssey.rain.network
Thank you in advance!

Related

Cannot access MapServer when using Let's Encrypt HTTPS on Apache2

I have recently built a website using MapServer for an academic course. The course is finished, but I wanted to continue developing it. The website is using Apache/2.4.53 (Debian), running on Debian 11, set up as a Virtual Host.
I have recently installed https using Let's Encrypt.
The website works when using either http (http://kina3.net/) or https (https://kina3.net/), so I know that https is working.
I can serve up a example file through MapServer when using: http://kina3.net/cgi-bin/mapserv?map=bluemarble&mode=map
However when I try using https://kina3.net/cgi-bin/mapserv?map=bluemarble&mode=map it generates the following error:
msLoadMap(): Regular expression error. MS_DEFAULT_MAPFILE_PATTERN validation failed.
My research (MS_DEFAULT_MAPFILE_PATTERN validation failed) suggests that problem is because "The map location is missing or wrongly formatted".
However in the apache2 VirtualHosts config file both references point to the same mapfile. See extract from site configuration file below:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName kina3.net
ServerAlias www.kina3.net
# Redirect permanent / https://kina3.net
DocumentRoot /var/www/kina3.net
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SetEnv bluemarble "/var/www/map/bluemarble.map"
</VirtualHost>
### ERROR LOGS IN /var/log/apache2/access.log ###
<VirtualHost *:443>
ServerAdmin webmaster#localhost
ServerName kina3.net
ServerAlias www.kina3.net
DocumentRoot /var/www/kina3.net
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /****
SSLCertificateKeyFile /****
Include /****
SetEnv bluemarble "/var/www/map/bluemarble.map"
</VirtualHost>
What am i missing?
I managed to fix this problem ... and it's not glorious. Turns out that I had two VirtualHosts files running, with the other one taking precedence. So whatever changes I made in the VH example above would have no effect as the other took precedence.
So if you find yourself with a similar problem to me, try running:
sudo apachectl -S
and see what the VirtualHost configuration: is pointing to.
Also, once you post a link to your own website on StackOverflow, expect regular visits from web scrapers plus various shady IP addresses.

after installing ssl getting wired error DNS_PROBE_FINISHED_NXDOMAIN

after installing paid ssl certification the web site sometime give some visitors this wired error
i'm using laravel 6 the host is aws light sail Ubuntu 18
my laravel conifg in Apache2
<VirtualHost *:80>
Redirect permanent "/" https://www.sitename.com/
</virtualHost>
<VirtualHost *:443>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/star-flight/public
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/server.crt
SSLCertificateKeyFile /etc/apache2/ssl/example.key
SSLCertificateChainFile /etc/apache2/ssl/chain.crt
<Directory /var/www/html/star-flight/public >
AllowOverride All
Allow from all
Options Indexes FollowSymLinks MultiViews
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
That error message is a DNS error which indicates that the IP address for the domain cannot be found. It is not related to SSL, as browser has not connected to the site to begin SSL negotiation.
If the site opens fine for some and not others, then it could be a DNS propagation issue.
Review your DNS settings. You also can check DNS propagation at https://dnschecker.org/

Laravel Setup Issue even after setting up Virtual Host and its all dependencies

I have installed Laravel Project with all its dependencies. Also, Setup Virtual Hosts for the same. But, When I hit the url like say "dev.laravelProject.com" it immediately opening Xampp Dashboard.
I don't know why is that happened.
Any Help Appreciated
First, change your /etc/hosts file to have a mapping of your desired website name(s) (www.example.com), and target IP address (127.0.0.1). I used my local IP address.
IPAddress Hostname Alias
----------- -------------------------- ------------------
127.0.0.1 www.librarymodule.com librarymodule.com
127.0.0.1 www.dev.librarymodule.com dev.librarymodule.com
So, you can set only one domain
<VirtualHost *:80>
DocumentRoot "/var/www/html/LibraryProject/public"
ServerName librarymodule.com
ServerAlias *.librarymodule.com
<Directory "/var/www/html/LibraryProject/public">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
or add first the main one and then the subdomain:
<VirtualHost *:80>
DocumentRoot "/var/www/html/LibraryProject/public"
ServerName www.librarymodule.com
ServerAlias librarymodule.com
</VirtualHost>
<VirtualHost *:80>
ServerName www.dev.librarymodule.com
ServerAlias dev.librarymodule.com
DocumentRoot "/var/www/html/LibraryProject/public"
</VirtualHost>
As a final step, you may need to add the websites to Apache by issuing the below commands:
# a2ensite librarymodule.com
# a2ensite dev.librarymodule.com
- Reload apache.

How to setup virtual host in zend apache2.4 and window 7?

I am setting virtual host in my local but not success. pls help me check.
Server local info.
Zend apache2.4
system: window 7.
my config:
the content of file httpd.conf:
....
include extra/httpd-vhost.conf
....
file httpd-vhost.conf:
<VirtualHost *:80>
ServerAdmin girl.test
DocumentRoot "C:\localhost\source"
ServerName girl.test
ServerAlias www.girl.test
ErrorLog "logs\girl-error.log"
CustomLog "logs\girl-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin boy.test
DocumentRoot "C:\localhost\source"
ServerName boy.test
ErrorLog "logs\boy-error.log"
CustomLog "logs\boy-access.log" common
</VirtualHost>
File: etc/hosts I add two line
127.0.0.1/source girl.test
127.0.0.1/source boy.test
After I restart service and go to:
girl.test get message
This site can’t be reached girl.test’s server IP address could not be
found.
127.0.0.1/source is work.
pls help me check, Many thanks.
I have fixed this issue when change file etc/hosts to 127.0.0.1 girl.test 127.0.0.1 boy.test

Setting up more Virtual Hosts on Webmin

i bought VPS and i installed 3 websites. All websites are loading files from one directory( but i set the different while i was creating ).
After putting DNS without making Virtual Hosts, site already loads default web site(first one), after creating virtual host, still the same.
<VirtualHost *>
DocumentRoot /home/svezatebe-online.com/www/
ServerName svezatebe-online.com
<Directory "/home/svezatebe-online.com/www/">
allow from all
Options FollowSymLinks
</Directory>
ServerAlias www.svezatebe-online.com
</VirtualHost>
<VirtualHost *>
ServerName wasdlife.com
<Directory /home/wasdlife.com/www>
allow from all
Options None
</Directory>
ServerAlias www.wasdlife.com
</VirtualHost>
<VirtualHost *>
DocumentRoot /home/online-vesti.net/www
ServerName online-vesti.net
<Directory "/home/online-vesti.net/www">
allow from all
Options None
</Directory>
</VirtualHost>
I would consider some examples from: https://httpd.apache.org/docs/2.4/vhosts/examples.html especialy try to adjust your config according to example below:
# Ensure that Apache listens on port 80
Listen 80
<VirtualHost *:80>
DocumentRoot "/www/example1"
ServerName www.example.com
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/www/example2"
ServerName www.example.org
# Other directives here
</VirtualHost>
For testing you can try to do a quick changes in your hosts file to try localy instead of having to do a DNS changes like mentioned at the link above:
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.

Resources