Vhost issue?
Posted by: SilkenMonkey (80.252.211.---)
Date: January 10, 2018 09:26AM

1 - Windows 10 pro - 64bit
2 - Version WampServer 3.1.0 64bit
3 - Apache Version 2.4.27
4 - PHP Version 5.6.31
5 - MySQL Version 5.7.19
5a - MariaDB version if applicable 10.2.8

Perhaps a basic question, i've been trying to understand by reading guides but i do not quite understand vhosts.

Problem: I have a wordpress installation where when i use my ip address i get site topic and site icon showing as intended in the tab, but when i try using the dns (http://www.xxxxxx.nu) they vanish, just showing the dns address and no icon. I tried getting support from Wordpress but they said that wordpress was not installed. Apparently my index.html is strange looking. (I get different index.html based on if i use ip or dns in browser. As the noob that i am, i do not understand why)

After some reading up, i understand that this might be due to no vhost installed on my system other than localhost. Can this be the reason for my problem? Thanks in advance.



Edited 2 time(s). Last edit at 01/11/2018 02:22PM by SilkenMonkey.

Re: Vhost issue?
Posted by: RiggsFolly (Moderator)
Date: January 11, 2018 10:07AM

Hi,


To use a url like `www.xxx.nu` and for that to serve from your local WAMPServer then you must have a Virtual Host setup in WAMPServer(Apache) and a reference to that url in your HOSTS file. As `www.rosanders.nu` actually exists (I looked at it) when you use that domain name you get your hosted site from the internet.


The normal way to do things:

On your local PC you create the WP site under a different domain name, for example `www.rosanders.test`.
Create a Virtual Host with that domain name, see the link on the WAMPServer homepage and almost everything is automated for you.
Add the domain name to the HOSTS file.
Install WordPress using that domain name i.e. `www.xxx.nu/wp-admin/install.php`


Now things should work.

The thing to remember with WP is that it stored the domain name in its database at install time i.e. the domain name you used on this line `www.xxx.nu/wp-admin/install.php`
........ ^^^^^^^^

So now if you want to move a site you created on `www.xxx.nu` to your local PC you should follow these instructions

Moving a wordpress site

This will tell you how to amend the restored database on the local PC so it points to your new test/development site name of `www.xxx.test`
Now you will be serving from the WAMPServer (local PC) and not the live site.



Example HOSTS file `C:\windows\system32\drivers\etc\hosts`

Add
127.0.0.1 xxx.test
::1 xxx.test

---------------------------------------------------------------------------------------------
(Windows 7 Pro 32bit) (Wampserver 3.1.3 32bit & 64bit)
<Apache 2.4.29/2.2.31> <PHP 7.2/7.1/7.0/5.6/5.5/5.4> <MySQL 5.7.19/5.6.39/5.5.28>
<MariaDB 10.2.14> <phpMyAdmin4.8.1> <MySQL Workbench 6.3.10>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your MySQL databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-



Edited 3 time(s). Last edit at 01/12/2018 11:37AM by RiggsFolly.

Re: Vhost issue?
Posted by: SilkenMonkey (80.252.211.---)
Date: January 11, 2018 11:09AM

Wow, gorgeous and comprehensive answer. I think i am starting to understand things. Big thank you for your time and support! I will give this a go this evening. I have no need of moving the installation, the plan is to create a live installment of a webpage that will only be online for a few months on my basement server.



Edited 1 time(s). Last edit at 01/11/2018 11:10AM by SilkenMonkey.

Re: Vhost issue?
Posted by: SilkenMonkey (80.252.211.---)
Date: January 11, 2018 11:40AM

Please correct me if i have misunderstood how this works. (this seems to be the point i am unsure of at this moment)

I redirect a given dns; www.abc.com to my ip via for example one.com
The request is forwarded to my server that holds wamp-installation.
is it the vhosts file where servername (www.abc.com) that redirects this request to the proper folder & website?
If i had another url (www.123.com) pointed at the same ip address, with the corresponding servername in vhosts, this is how the wamp-server would know where to forward the requests?

(i am not looking for using multiple installations, it's just for the sake of understanding)

example:
<VirtualHost *:80>
ServerName www.abc.com
DocumentRoot c:/projects/abc
require all granted
(etc.)



Thank you



Edited 1 time(s). Last edit at 01/11/2018 11:45AM by SilkenMonkey.

Re: Vhost issue?
Posted by: RiggsFolly (Moderator)
Date: January 11, 2018 02:02PM

Hi,

I redirect a given dns; www.abc.com to my ip via for example one.com
The request is forwarded to my server that holds wamp-installation.
is it the vhosts file where servername (www.abc.com) that redirects this request to the proper folder & website?


Yes


If i had another url (www.123.com) pointed at the same ip address, with the corresponding servername in vhosts, this is how the wamp-server would know where to forward the requests?


Also YES



However there are a few things I think I should add:

1. You will have to set up "port forwarding" for port 80 on your router.

This allows unsolicited connections to pass through your routers NAT (Network Address Translation) and for these connections to be "forwarded" to a specific PC (ip address) inside your private network i.e. the PC running WAMPServer(Apache)
Without the forwarding on the router unsolicited connections are blocked by NAT, you can consider it a hardware firewall, and opening port 80 will add an attack vector to your network, which you would be surprised at how quickly will be found by the bad guys.
So you have been warned and you are then responsible for taking any and all additional steps to secure your network/Apache/mysql/etc


2. Using a Windows Desktop OS i.e. not a Windows Server OS will also limit the usefulness of hosting your site on your local PC and also means you have to leave it on all the time.

This is fine for showing a few friends or demoing a site to a client BUT...

Windows Desktop OS's have a limit to the number of external connections they will allow at any one time. Windows 10 = 30
Bearing in mind that Windows itself permanatly uses some of these 30 connection lets say the limit is reduced to 20 external connections.
This will make your site react very poorly to multiple simultaneous connection giving a very bad user experience.
Also consider that one user connection i.e. one browser, will attempt to make use of at least 2 connections and maybe more, to quickly attempt to download page artifacts like CSS/Javascripts/Images as it comes across them in your HTML you are limited to no more than 7-10 users of your sote at any one time.

---------------------------------------------------------------------------------------------
(Windows 7 Pro 32bit) (Wampserver 3.1.3 32bit & 64bit)
<Apache 2.4.29/2.2.31> <PHP 7.2/7.1/7.0/5.6/5.5/5.4> <MySQL 5.7.19/5.6.39/5.5.28>
<MariaDB 10.2.14> <phpMyAdmin4.8.1> <MySQL Workbench 6.3.10>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your MySQL databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-



Edited 1 time(s). Last edit at 01/11/2018 02:04PM by RiggsFolly.

Re: Vhost issue?
Posted by: SilkenMonkey (80.252.211.---)
Date: January 11, 2018 02:22PM

Great, big thank you for your help. Port forwarding is already complete, i am better at that part than the webhosting part. smiling smiley

The website is only a temporary one, but i found a learning experience in doing this way rather than using an online solution. I am going over my budget and might very well purchase a proper dedicated server for the future. Not many people will access this website over the upcoming months. I will edit away the url above in my posts, perhaps you can do the same to avoid these bad guys. Thank you once again!

Re: Vhost issue?
Posted by: RiggsFolly (Moderator)
Date: January 12, 2018 11:40AM

Hi

Edited as requested.

However they will find you by probing all the usual ports on your WAN IP address. Soon as they see a open port 80 they will be back to see if they can exercise any of their exploits.

Keep an eye on your apacge error log for odd attempts to access non existant pages, thats the most obvious way of seeing these probes.

---------------------------------------------------------------------------------------------
(Windows 7 Pro 32bit) (Wampserver 3.1.3 32bit & 64bit)
<Apache 2.4.29/2.2.31> <PHP 7.2/7.1/7.0/5.6/5.5/5.4> <MySQL 5.7.19/5.6.39/5.5.28>
<MariaDB 10.2.14> <phpMyAdmin4.8.1> <MySQL Workbench 6.3.10>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your MySQL databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Sorry, only registered users may post in this forum.