Setting up more Virtual Hosts on Webmin - vps

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.

Related

Add Virtual Host in Apache Windows 10

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!

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.

Laravel 5.2 site on localhost/Wamp

I am trying to learn Laravel.
I created a project on c:/sites where I develop all my sites. I called it larabasic.dev
I cannot open the site in my browser, it keeps switching to www.larabasic.dev and tells me server not found.
I set up a virtual host like I did to all my other sites that works well.
I tried:
1. Changing server.php to index.php and copied the public/htaccess file to the root folder
2. Going to http://larabasic.dev/public
3. Going to http://larabasic.dev/public/index.php
4. Changing vhosts file to:
<VirtualHost *:80>
ServerName larabasic.dev
ServerAlias larabasic.dev
DocumentRoot "c:/sites/larabasic.dev/public"
<directory "c:/sites/larabasic.dev/public">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</directory>
</VirtualHost>
Instead of:
<VirtualHost *:80>
ServerName larabasic.dev
ServerAlias larabasic.dev
DocumentRoot "c:/sites/larabasic.dev"
<directory "c:/sites/larabasic.dev">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</directory>
</VirtualHost>
My hosts file has these 2 entries:
127.0.0.1 larabasic.dev And
::1 larabasic.dev
Nothing helps. Again, any other sites I have developed with plain php work fine.
What am I missing?
Thank you
I've encountered the same problem and I've fixed this by giving 127.0.0.2 to my laravel application.
First, in the hosts file, you need to redirect larabasic.dev to 127.0.0.2:
127.0.0.2 larabasic.dev
Second, you need to bind the virtual host to that IP:
<VirtualHost 127.0.0.2:80>
DocumentRoot "C:/sites/larabasic.dev/public"
ServerAdmin admin#localhost
ServerName larabasic.dev
ServerAlias www.larabasic.dev
<Directory "C:/sites/larabasic.dev/public">
AllowOverride All
Options Indexes FollowSymLinks
Require local
# if you want access from other pc's on your local network
#Require ip 192.168.1
# Only if you want the world to see your site
#Require all granted
</Directory>
</VirtualHost>
This is my working configuration on my local machine.

How to point two website in windows wamp server with same ip

I have two websites www.test1.com and www.test2.com.I hosted both sites in windows wampp server with same IP called xx.xxx.xx.xx .But while opening both sites www.test1.com is comming.Here www.test1.com files are in 'test1' folder and www.test2.com are in 'test2' folder.
I Tried virtual host in wampp...but its not working...
This is my \wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf file
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/test1"
ServerName test1
ServerAlias test1.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/test2"
ServerName localhost
ServerAlias test2.com
<Directory "c:/wamp/www/test2">
AllowOverride All
Require local
Require all granted
Allow from all
</Directory>
</VirtualHost>
This is my C:\Windows\System32\drivers\etc\hosts file
127.0.0.1 localhost
127.0.0.1 test1.com
127.0.0.1 test2.com
Both your domain names are going to the site defined first in the httpd-vhost.conf file because that is the default behaviour when Apache cannot find a site requested in the host definitions. It normally means you have done something wrong in the defining of your VHOSTS.
Your host definitions are a little wrong, and you are mixing Apache 2.2 and 2.4 security syntax which often causes problems, try these
# Should be the first VHOST definition so that it is the default virtual host
# Also access rights should remain restricted to the local PC and the local network
# So that any random ip address attack will recieve an error code and not gain access
<VirtualHost *:80>
DocumentRoot "C:/wamp/www"
ServerName localhost
<Directory "C:/wamp/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/test1"
ServerName test1.com
ServerAlias www.test1.com
<Directory "c:/wamp/www/test1">
AllowOverride All
Require local
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/test2"
ServerName test2.com
ServerAlias www.test2.com
<Directory "c:/wamp/www/test2">
AllowOverride All
Require local
Require all granted
</Directory>
</VirtualHost>
Now so that you can see the sites locally on the WAMPServer PC the hosts file should look like this. Remember, these entries only effect the PC containing the HOSTS file, and have no effect on internet access or the ability of a remote user to use these domain name.
# IPV4 loopback
127.0.0.1 localhost
127.0.0.1 test1.com
127.0.0.1 test2.com
# IPV6 loopback
::1 localhost
::1 test1.com
::1 test2.com
The first line needs to be
NameVirtualHost *:80

Wampserver can't get Named Virtual hosts to work

Using wampserver I can't get named virtual hosts to work. I've edited the httpd.conf to use the
Include conf/extra/httpd-vhosts.conf
I've added the domain to my system32/driver/etc/hosts file. I've edited the httpd-vhosts.conf file and everything seems to work except now localhost is unavailable. The domain I setup (test123.com) works fine, hitting 127.0.0.1 works fine, but hitting localhost hangs. There is nothing relevant in the error logs and no mention of it in the access logs. Here is how I have edited httpd-vhosts.conf:
#
# Virtual Hosts
#
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
# Tells Apache to serve the default WAMP Server page to "localhost"
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/wamp/www"
<Directory "C:/wamp/www">
Options FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
DirectoryIndex index.php
</VirtualHost>
<VirtualHost *:80>
ServerName test123.com
ServerAlias *.test123
# Folder where the files live
DocumentRoot "D:/Projects/html/test123"
# A few helpful settings...
<Directory "D:/Projects/html/test123">
Options FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
DirectoryIndex index.php
</VirtualHost>
What am I doing wrong?
Finally figured it out. In httpd.conf I had to change
Listen 80
to
Listen *:80

Resources