The BIG Question
Posted by: thebigquestion (---.20-162-184.mc.videotron.ca)
Date: August 25, 2014 09:23AM

I'm new to all this and after reading and trying different setups for over a week now, I'm totally lost and need help.

This is what I'm trying to do :


I purchased a domain name, say www.examples.com from Godaddy

at Godaddy I set it to be forwarded to my "myIPaddress:8080" as my ISP blocks port 80... ( IPaddress found from googling"what's my IP)

so now my ISP allows it through on port8080 and it enters my house where I have another dlink router set to
port forward to the pc with my server on it ( 192.168.0.101 ) on port 80
( in on my googled IPaddress port 8080 out on 192.168.0.101 port 80.

My home pc with the server on it is:

windows7 ultimate
with wamp2.5 32 bit installed

it is a fresh, completely stock install with the following changed :

after reading for a week allover the place...

I've created a folder named "examples" in my C:/wamp/www directory ( so C:/wamp/www/examples ) where I've placed my files for my website

I've added a rootpassword to my phpmyadmin database ( C:/wamp/apps/phpmyadmin4.1.14/config.inc.php
excerpt (password x'd out obviously) :
$cfg['Servers'][$i]['verbose'] = 'mysql wampserver';
//$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'XXXXXXXX';
/* Server parameters */
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysql if your server does not have mysqli */
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

My windows vhosts file is as followssad smileyc:/windows/system32/drivers/ect/vhosts)
excerpt:

# 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
127.0.0.1 examples

::1 localhost
::1 examples

>> Should they be examples.com or www.examples.com ????






I've commented out the "#" from the front of the "Include" in my "C/wamp/bin/apache/apache2.4.9/conf/httpd.conf" file :

excerpt :

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

My ""C/wamp/bin/apache/apache2.4.9/conf/extra/httpd-vhosts.conf" file is:

#
# Use name-based virtual hosting.
# This next line is not required if you are using Apache 2.4.x and should be deleted
NameVirtualHost *:80

## should be first so the wamp menu page loads and is the default site
## should also never be changed from only allowing access from the local machine
## for a bit of extra security from casual ip address probing
<VirtualHost *:80>
DocumentRoot "C:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "C:/wamp/www">
AllowOverride All

<IfDefine APACHE24>
Require local
</IfDefine>

<IfDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
</IfDefine>
</Directory>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "C:/wamp/www/examples"
ServerName examples
ServerAlias examples
<Directory "C:/wamp/www/examples">
AllowOverride All

<IfDefine APACHE24>
Require all granted
</IfDefine>

<IfDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from all
</IfDefine>

</Directory>
</VirtualHost>

>>> should they be examples.com or www.examples.com ???


If I type "localhost" in my browser that my server is on I get the phpmyadmin welcome page

if I type localhost/examples I get a HTTP 44 error page cannot be found ( I have an index,php file in the C:/wamp/www/examples Directory)

obviously I cant access from the internet at all with www.localhost.examples.com, www.examples.com or any other configuration of it....




I want to set this up so it can be accessed from the internet
( I belong to a group of about 25 people and many have IP addresses that change frequently, as well others may join the group so I guess complete internet access)

so how do I fix this big mess I created and where am I going wrong ??

Thank you.

Re: The BIG Question
Posted by: RiggsFolly (---.dynamic.dsl.as9105.com)
Date: August 26, 2014 10:35AM

Ok your port forwarding sound like it is correct, now you need to tell Apache that your site is called whatever the real domainname is that you purchased and people will be using to access it, so apache can see that name and forward access to the right folder.

I also suggest you create a .dev version of the site, so you can fiddle with it without damaging the live site, then copy changes from .dev to .com when they are tested.


Try this in your httpd.vhost.conf file :-

#
# Use name-based virtual hosting.
# This next line is not required if you are using Apache 2.4.x and should be deleted
#NameVirtualHost *:80

## should be first so the wamp menu page loads and is the default site
## should also never be changed from only allowing access from the local machine
## for a bit of extra security from casual ip address probing
<VirtualHost *:80>
	DocumentRoot "C:/wamp/www"
	ServerName localhost
	ServerAlias localhost
	<Directory "C:/wamp/www">
		AllowOverride All

		<IfDefine APACHE24>
			Require local
		</IfDefine>
		
		<IfDefine !APACHE24>
			Order Deny,Allow
			Deny from all
			Allow from 127.0.0.1 localhost ::1
		</IfDefine>
	</Directory>
</VirtualHost>

#Externally accessible site
<VirtualHost *:80>
	DocumentRoot "C:/wamp/www/examples"
	ServerName examples.com
	ServerAlias www.examples.com
	<Directory "C:/wamp/www/examples">
		AllowOverride All

		<IfDefine APACHE24>
			Require all granted
		</IfDefine>
		
		<IfDefine !APACHE24>
		Order Allow,Deny
			Allow from all
		</IfDefine>
	</Directory>
</VirtualHost>

#My internally accessible development version of example.com
<VirtualHost *:80>
	DocumentRoot "C:/wamp/www/examples_dev"
	ServerName examples.dev
	ServerAlias www.examples.dev
	<Directory "C:/wamp/www/examples_dev">
		AllowOverride All

		<IfDefine APACHE24>
			Require local
		</IfDefine>
		
		<IfDefine !APACHE24>
		Order Deny,Allow
			Deny from all
			Allow from 127.0.0.1 ::1 localhost
		</IfDefine>
	</Directory>
</VirtualHost>


Now that Apache knows about `examples.com` when an access comes in from the internet it knows where to get the pages from for that domain.

Also having a development site in a seperate folder i.e. example.dev living in \wamp\www\example_dev allows you to develop the site without effecting the LIVE site. This site is only accessible from your PC and not the internet.





The C:\windows\system32\drivers\etc\hosts file then needs to look like this :-

127.0.0.1 localhost
127.0.0.1 examples.com examples.dev

::1 localhost
::1 examples.com examples.dev

This file only effects the PC that the file lives on and has nothing to do with access from the internet, it just seeds the Windows DNSCACHE on that one PC and will allow you to access both sites from the server PC by using the specific domain name i.e.

    'http://example.com'
OR
    'http://example.dev'

without the quotes of course

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

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 databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Re: The BIG Question
Posted by: thebigquestion (---.20-162-184.mc.videotron.ca)
Date: August 27, 2014 10:19AM

Thank you, you've been very helpful and I've made a lot of headway at wrapping my head around all this, it's still very new to me and trying to understand the different interpretations of what one thing means to another in the different files is a little confusing still.

I've done what you described above with one exception , I've changed the internally accessible development version of example.com to :

...

"DocumentRoot "C:/wamp/www/examples.dev"


"<Directory "C:/wamp/www/examples.dev">"

As I think the underscore in there was a typo and if I'm understanding the reasoning behind your excellent explanation, it has to match the directory folder of examples.dev for apache to find it... I think I understand better how apache associates these now.


With that said I still need some help as It all works locally but I have no access from the web.

I've gone to some port testing sites that will ping for open ports and they've all confirmed that when wamp is "online" my port 8080 is open , and when I switch wamp "offline" my port becomes closed. I've also checked on a site that verifies if a website is up or down and that came back as down whether wamp is online or offline. I take this as the data is getting through to my home server pc OK and therefore the problem has to be in the httpd.conf file mismatching something I've messed up.


in my httpd.conf file I have :

excerpts of the important places :

Listen 0.0.0.0:80
Listen [::0]:80

ServerName www.examples.com:80

HostnameLookups Off

DocumentRoot "c:/wamp/www/"

<Directory />
AllowOverride none
Require local
</Directory>

<Directory "c:/wamp/www/">

Options Indexes FollowSymLinks

AllowOverride all

Require all granted

# onlineoffline tag - don't remove
Require all granted
</Directory>


# Virtual hosts
Include conf/extra/httpd-vhosts.conf


Now if I've understood and learned from you I think my mistake is at the "ServerName" which really should be :

"ServerName examples.com:80" ... so it matches the win host file and apache can relate all the files and directories to it.


If I'm getting it at all I should also be able to remove any reference to the "C:/wamp/www" directory as anything in my httpd-vhosts file overrides the info in the httpd.conf file anyway.

So I supposed I'm asking if I'm correct in that the servername should be examples.com and all the rest is correct in that file , although the wamp directory part could be removed but wont do anything if left there ?

Thanks

Re: The BIG Question
Posted by: RiggsFolly (---.dynamic.dsl.as9105.com)
Date: August 27, 2014 11:30AM


I've done what you described above with one exception , I've changed the internally accessible development version of example.com to :

DocumentRoot "C:/wamp/www/examples.dev"
<Directory "<Directory "C:/wamp/www/examples.dev">">


Actually it was not a typo, DocumentRoot should point to a folder that exists and contains your site root folder, it could have been DocumentRoot "C:/wamp/www/fred" as long as it matched <Directory "C:/wamp/www/fred">

However your new folder name will work just fine as long as you have a folder called 'C:/wamp/www/examples.dev' on disk.

=================================================

Now to make the site visible to the internet, leave httpd.conf as it was, no changes required here.

We have already told Apache that it can accept connections from the universe for the one site that should be available on the internet

#Externally accessible site
<VirtualHost *:80>
    DocumentRoot "C:/wamp/www/examples"
    ServerName examples.com
    ServerAlias www.examples.com
    <Directory "C:/wamp/www/examples">
        AllowOverride All

        <IfDefine APACHE24>
            Require all granted      <<<<<< says anyone can connect in Apache 2.4 speak
        </IfDefine>
		
        <IfDefine !APACHE24>
            Order Allow,Deny
            Allow from all             <<<<<< says anyone can connect in Apache 2.2 speak
        </IfDefine>
    </Directory>
</VirtualHost>


Now what may be the problem is that you have to use the correct domain name i.e. example.com and not just a ipaddress. When apache see's the correct domain name it can start serving pages from the correct folder.
If you are sing just an ip address it will default to the FIRST definition in the list of Virtual Hosts which in this case should be localhost. But because localhost is configured to only accept connections from local ip address's it will return an error code.


One way of testing this is to change the order of the definitions in the httpd-vhost.conf file. Make the example.com site the first site in the list of 3 sites and that will become the default. You will then know that you are getting to your PC and the Apache running on it and what the site looks like. However it should not be left in thsi order, as having localhost first in the list provides a bit of security. As its first in the list of VHOSTS it is the default site, and because it can only accept connections from the local machine it will reject any casual, drive-by attempts to access your Apache server,



So first make sure that domain is forwarding to your ip address

Second make sure you are using the PROPER url/domain name for your site (example.com) so Apache can server the site from the correct folder.

Third make sure you are testing this internet access from outside your local network, as most routers wont understand an attempt to access example.com when that address gets pointed back to its own router.

Forth, if all else fails, move example.com to be the first (default) site in your list of Virtual Hosts.




If you would like me to test if I can access your site from here, send me a Private Message with the real domain name and I will try to get access from here.

Alternatively, install TeamViewer and send me a Private Message containing the ID and PASSWORD so I can connect to your PC and we can try and trouble shoot this into submission.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

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 databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-



Edited 1 time(s). Last edit at 08/27/2014 11:30AM by RiggsFolly.

Re: The BIG Question
Posted by: thebigquestion (---.169-130-66.mc.videotron.ca)
Date: August 27, 2014 06:17PM

I've done as you suggested and discovered that it does work from the internet (www) if I do as you suggest and make the external accessible virtual host the first one in the httpd-vhosts file.

I don't fully understand or grasp the concept of using the correct domain name instead of an IP, or where this is supposed to go.

my win hosts file is simply to make my machine that it resides on be identified, ie I type in a number I type in a name next to it and if I then type that name into my browser on that machine it says " oh that's me"....the win hosts file has nothing to do with the internet so my problems not there.

The ServerName in my httpd.conf file is

ServerName examples.com:80

...This matches the win hosts file so I think that's right.

So I'm at the httpd-vhosts file and the virtual hosts settings which for the external one are :

#Externally accessible site
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/examples"
ServerName examples.com
ServerAlias www.examples.com
<Directory "C:/wamp/www/examples">
AllowOverride All

<IfDefine APACHE24>
Require all granted
</IfDefine>

<IfDefine !APACHE24>
Order Allow,Deny
Allow from all
</IfDefine>
</Directory>
</VirtualHost>

the DocumentRoot is correct , in my C:/wamp/www directory I have a folder names examples with an index page in it.

ServerName matches to my httpd.conf file and the win hosts file.

ServerAlias I don't quite understand what this is but its name matches my registered domain name and I assume when a request comes in from the web to apache its used to say www.examples.com is the server examples.com and therefore should be OK.

The rest of the file just grants access to all IP's from anywhere to the aforementioned virtualhost.


So I'd really like to understand this but I'm mystified as to why it doesn't work, It's throwing an error or cant find it and when placed as the first virtualhost becomes the default that's given and then works...

How do I find out where the error is exactly ?

I've read and read and used the command console to do a "-t" and a "-A" and the "-t" returns as syntax OK but that's just syntax, if I'm redirecting wrong it wont show....

The "-a" returns the virtual hosts but I'm not really quite sure what its saying exactly, so I cant be sure if its right...

I guess I need to better understand the relationships between the domainname and IP address when it comes to apache but there's so many to me... I have

My web browsers IP that when you google "whats my IP" shows up
eg : 123.456.78.910

then I have my router assigned IP for the PC that the server is on which is 192.168.0.101 ( which I've fixed to remain assigned to that pc on the network )

I'm not sure which IP is being refered to here ?... I'm assuming the router assigned one?... or where to place it in the vhosts file.

Thanks

Re: The BIG Question
Posted by: thebigquestion (---.169-130-66.mc.videotron.ca)
Date: August 27, 2014 06:24PM

Do you mean "<VirtualHost *:80>"

should be changed to :

" <VirtualHost 192.168.0.101:80> "

for the externally accessible site in my httpd-vhosts file ?

Re: The BIG Question
Posted by: thebigquestion (---.169-130-66.mc.videotron.ca)
Date: August 27, 2014 06:38PM

Okay, yes, yes you do !!!!!

( forgot to mention above , I put the virtualhost for "local" back in the first spot and the external in the second, changing it to the IP# )

Thank you !, Thank you !, Thank you !, Thank you !, Thank you !, Thank you !, for your time and in depth explanantions, I don't like to simply copy and paste things, I try to understand how and why they work and are that way.

Now thanks to you, I have a much better understanding how they all relate to one another !

I know you're busy and there's a lot of other people with problems but if you have the time and the inclination, I'd really like to know why it required the actual IP address in there and the *:80 didn't work.

I thought *.80 meant that any IP address assigned to the pc which holds the apache software would be given the virtualhost definition defined below it, communicating on port 80 ?

is there any usual reason why it didn't work ?

but like I said, only if you have the time...

Thank you !!, once again for ALL your help.



Edited 1 time(s). Last edit at 08/27/2014 06:41PM by thebigquestion.

Re: The BIG Question
Posted by: RiggsFolly (---.dynamic.dsl.as9105.com)
Date: August 28, 2014 12:45AM

I don't fully understand or grasp the concept of using the correct domain name instead of an IP, or where this is supposed to go.

In your first post you said you had purchased a domain name from godaddy, you used www.example.com as an example of it.
You also said that you had configured your godaddy account to point that domain towards your routers WAN ip address.

So if you use that domain name AND NOT the wan ip address of your router, Apache will see the domain name and search all your Virtual Hosts for that name. If it finds that domain name it will serve the site from the DocumentRoot of that Virtual Host.

If you use just the ip address in a browser it does not see a domain name and can only search for a VH with the ip address you used, if it does not find one, it uses the first Virtual Host as the default and serves whatever site is pointed to by the first VH's DocumentRoot.

So as you were using an IP address and not a domainname your change to the VH definition to use an ip address would now work.

So use the proper domain name and put the VH definition back to *:80

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

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 databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Re: The BIG Question
Posted by: thebigquestion (---.169-130-66.mc.videotron.ca)
Date: August 28, 2014 05:20AM

I must be retarded because now I'm totally lost again....

The only way I can get it to work seems to be if I have the router assigned IP address for the homeserver entered into the httpd-vhosts file.

excerpt :

#Externally accessible site

#Externally accessible site
<VirtualHost 192.168.0.101:80>
DocumentRoot "C:/wamp/www/examples"
ServerName examples.com
ServerAlias www.examples.com
<Directory "C:/wamp/www/examples">
AllowOverride All

<IfDefine APACHE24>
Require all granted
</IfDefine>

<IfDefine !APACHE24>
Order Allow,Deny
Allow from all
</IfDefine>
</Directory>
</VirtualHost>

However if I place an <a href> tag to another subfolder in the examples directory ( C:/wamp/www/examples/subfolder/index.php ) it works only locally (WAN) but the browser doesn't change the url, it remains www.examples.com and the refresh button when clicked will return you to the www.examples.com, which has the link on it. Over a LAN(www) the main page shows but when the link is clicked stating that the webpage is not available and telling you the webpage at "[localhost] is not available... I'm not sure why it has the localhost in it and why the examples folder isn't following the link correctly.

If I use <VirtualHost www.examples.com:80> I get a Forbidden, you're not allowed acces to "/"
on this server and then it lists my googled IP address:8080

The servername in my httpd file is listed as "examples.com"

I'm not sure where I'm going wrong or where the domain name is supposed to be entered... and by domainname do you mean "www.examples.com" or simply "examples.com"... This isn't my regular line of work so a pretty stupid and basic question I guess...



Edited 1 time(s). Last edit at 08/28/2014 05:41AM by thebigquestion.

Re: The BIG Question
Posted by: thebigquestion (---.169-130-66.mc.videotron.ca)
Date: August 28, 2014 05:54AM

In addition to the above problem, I'd really like to understand the , for lack of the proper term, "routing" the data takes exactly or a link to something I can read to better understand what's taking place overall. All the guides and threads I read seem to be specific or related to one particular program or feature. I might get a better comprehension if I saw it from above....

for example :

Someone, somewhere types in my domain name, www.examples.com... it goes to godaddy who sends it to my home router on port 8080, my home router sends it to my home server pc on 192.168.0.101 port 80.... from here, what takes place....

Does the apache httpd.conf file to look at the name requested and compare it to its servername in its file then on to httpd-vhosts file for authorizations ? Where does the win hosts file come into play ?

I'm trying to draw a communication diagram in my head of how it all gets put together so I can figure out things myself with a little reading but I can't make 100% sense of it...

Re: The BIG Question
Posted by: RiggsFolly (---.dynamic.dsl.as9105.com)
Date: August 28, 2014 11:09AM

Interesting question:

You are 90% there.

I am not a networking expert, but this is my laymans understanding of the general flow when connecting to a web site.

==================================================

You buy a domain (example.com) from godaddy.

Godaddy register that domain name against an ip address ( one of theirs or yours ) in their Domain Name Server.

This eventually spreads this knowledge to all Domain Name Servers in the world about your domain name living on ip address 99.99.99.99

===================================================

I keyin www.example.com on my browser.

Browsers and networks dont actually understand domain names, so the browser asks windows to look up the ip address of example.com in its local DNSCACHE or if its not there on one of the many DNS Server out on the web.

So now we, that Windows the (DNSCACHE) and the browser knows example.com lives at ip address 99.99.99.99
Until you boot the PC windows, will always look for and find, example.com in its dns cache, saving the trip out to a DNS Server each time you click on a link.

====================================================

My broswer now asks ip address 99.99.99.99 for a web page called index.php over TCP/IP and the HTTP protocol.

====================================================

Your router gets connected to by my router on port 80 normally ( the default http protocol port number ) or in your case port 8080

Normally unsolicited connection would be ignored by your router as port 80 / 8080 would be stealthed i.e. to all intent and purpose invisible, but as you have Port Forwarded port 80 ( 8080 in your case ) the NAT software in the router says, ok I will forward this request to an ip address inside the local network I am managing, and passes the connection on to ip 192.168.0.101 and knocks on door number 80 ( port 80 ).

This is of course the first security issue you have created for yourself when you decided to run a web server locally rather than letting a Professional worry about and instigate the required security measures to protect against illegal intrusions you have now allowed.


If it gets no reply i.e. Apache is not running, it returns an error.

===========

Now :
You start Apache on the PC with ip address 192.168.0.101

It looks at the httpd.conf file and any other config files INCLUDED within httpd.conf, like the extra/httpd-vhost.conf file. and therefore knows it is supposed to :-

Listen on port 80
Has a VHOST called example.com
in other words it builds various internal tables and loads various module as per instructions in httpd.conf and included files. etc etc etc

So now Apache is running and listening for a knock on door number 80 ( port 80 )

===========

Now that Apache is running on 192.168.0.101, Apache see's the connection attempt from my PC, via my router and through your router, and decides if it can handle this request.

It see's the connection is to a domain called www.example.com it looks for and finds a VHOST with that ServerName or ServerAlias, and therefore knows that this site is served from the folder enterd in the DocumentRoot parameter of that VHOST definition.

Apache looks in C:/wamp/www/examples for a a file called index.php

If it does not find it it returns an error.

If it does find it, it sees that it has a php extension, so it reads index.php and passes it to the PHP interpreter for execution. PHP executes the part between the <?php and ?> tags and returns the result of the execution to Apache and Apache send that back to me on my PC for my browser to use to paint the web page.


==============================================

Now if I use just your ip address i.e. 99.99.99.99:8080/index.php, the command is legal and will find your router and pass the request on to Apache on 192.168.0.101:80 but the header that arrives asking for index.php to be served does not contain example.com as we didn;t use that domain name.

Therefore Apache cannot find the VHOST we defined as :-

<VirtualHost *:80>
    DocumentRoot "C:/wamp/www/examples"
    ServerName examples.com
    ServerAlias www.examples.com

Apache wil see the request, but not know what to do with it i.e. which VHOST eg DocumentRoot should I server this from.
So it defaults as per its instructions to the first VHOST in its list of VHOST's


==========

Now when you change the definitions of this VHOST to use

<VirtualHost 192.168.0.101:80>

I think you have changed from using Name-Based Virtual Hosts to using IP-Based virtual hosts and anthing that arrives from ip address 192.168.0.101 which is of course anything that arrives to this PC will be consider example.com as the target virtual host and serve pages from that DocumentRoot.




I hope this helps. It certainly made me think a little more closely about what is actually going on.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

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 databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Re: The BIG Question
Posted by: thebigquestion (---.169-130-66.mc.videotron.ca)
Date: August 28, 2014 07:06PM

I seem to be up and running with one problem...

I have one domain name and want one site but this one site will have forums, galleries, bulletin board so I have my folder examples ( C:/wamp/www/examples )

Ive created subfolders in it, eg:

C:/wamp/www/examples/forum
C:/wamp/www/examples/galleries
C:/wamp/www/examples/board

these aren't different different domainnames, just subfolders from the main but apache wont allow access to them externally.

I have an index.php page in C:/wamp/www/examples , in it are links to the subfolders ex:

echo "<a href="/forum/index.php"> Forum</a>

Ive even tried : echo "<a href="www.examples.com/examples/forum/index.php"> Forum</a>

they return errors saying I don't have permission to access that folder on this server...

I cant believe I have to set up a separate virtual host for every subfolder I create off the main folder of examples do I ?

I have to be missing some command line that allows access to subfolders of examples in the vhosts file but I don't know where it is or what it is

Any suggestions would be greatly appreciated
Thanks

Re: The BIG Question
Posted by: thebigquestion (---.169-130-66.mc.videotron.ca)
Date: August 28, 2014 11:43PM

Okay, this morning after being fed up of it not working correctly I uninstalled wamp, went through the registry deleting and references to it that weren't required, deleted the c:/wamp folder that stays there after an uninstall ( after saving what I needed from it elsewhere )... put my win hosts file back to normal and started completely over.

... so now wamp2.5 is re installed fresh...

gave phpmyadmin the passwords for the 3 root users , created a folder named examples.com in my c:/wamp/www directory

then:

Went in to win hosts file added my domain name, it now looks like this :

127.0.0.1 localhost
127.0.0.1 examples.com

::1 localhost

Went in to my httpd.conf file and uncommented the httpd-vhosts.conf line so its :

Include conf/extra/httpd-vhosts.conf

changed my httpd-vhosts file to this :

<VirtualHost *:80>
DocumentRoot "C:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "C:/wamp/www">
AllowOverride All

<IfDefine APACHE24>
Require local
</IfDefine>

<IfDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
</IfDefine>
</Directory>
</VirtualHost>

#Externally accessible site
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/examples.com"
ServerName examples.com
ServerAlias www.examples.com
<Directory "C:/wamp/www/examples.com">
AllowOverride All

<IfDefine APACHE24>
Require all granted
</IfDefine>

<IfDefine !APACHE24>
Order Allow,Deny
Allow from all
</IfDefine>
</Directory>
</VirtualHost>


From my understanding of all your explanations it should be working, but it doesn't...

the page gives me this when using localhost in the browser :

Forbidden
You don't have permission to access / on this server.
Apache/2.4.9 (Win32) PHP/5.5.12 Server at localhost Port 80

and gives me this if I enter www.examples.com in the browser :

Forbidden
You don't have permission to access / on this server.
Apache/2.4.9 (Win32) PHP/5.5.12 Server at (Googled whats my IP address)Port 8080

I didn't change anything in my httpd.conf file except the "#" to include the virtual host file... I can't seem to figure out why its being denied permission and trying to access the "/" directory ?

Re: The BIG Question
Posted by: thebigquestion (---.169-130-66.mc.videotron.ca)
Date: August 29, 2014 12:25AM

okay, got those figured out and they work when you put in "localhost" or "examples.com" in the browser

when wamp is "online" and I type in www.examples.com I got the following :


This page can’t be displayed

Make sure the web address []( googled whats my IP address:8080) is correct

It's like something isn't matching the IP address as relating to my home pc server, but the Vhost file seems correct ????

Vhosts excerpt :

#Externally accessible site
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/examples.com" ( <-- yes, have folder c:/wamp/www/examples.com with index file in )
ServerName examples.com ( <--- Yes have entry 127.0.0.1 examples.com in win host file )
ServerAlias www.examples.com ( <--- Yes, have registered domain name )
<Directory "C:/wamp/www/examples.com"> ( Yes, have the folder with index.php in it )
AllowOverride All
<IfDefine APACHE24>
Require all granted
</IfDefine>

<IfDefine !APACHE24>
Order Allow,Deny
Allow from all
</IfDefine>
</Directory>
</VirtualHost>


When wamp is put "online" the world should have access to this folder but doesn't... I'm stumped as to why....

I think there's a problem with it relating that 127.0.0.1 examples.com is actually my home server at 192.168.0.101 when put online but I don't know how to fix this, it doesn't seem to be able to relate theyre one in the same...

Re: The BIG Question
Posted by: RiggsFolly (---.dynamic.dsl.as9105.com)
Date: August 29, 2014 01:54AM

Ok,

Never has one menu item caused so much confusion!

Basically now you are using Virtual Hosts you should forget about the 'Put Online/Offline' menu.

Set it to Offline.

Controlling extenal access should now be done from the httpd-vhosts.conf file manually. You set Apaches access rights specifically for each VHOST now from this file, using the 'Require all granted' or 'Require local' syntax.


The Put Online/Offline menu actually runs a little script that edits the httpd.conf file and changes this section of httpd.conf
<Directory "c:/wamp/www/">

 ...

 ...


#   onlineoffline tag - don't remove
    Require local

Which actually only controls the access to the c:/wamp/www/' folder, so it is basically defunct now you are using VHOSTS and shoudl be, for security reasons' left offline.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

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 databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Re: The BIG Question
Posted by: thebigquestion (---.169-130-66.mc.videotron.ca)
Date: August 29, 2014 03:08AM

okay, ...

The site still only works locally and not when you type www.examples.com into the browser.......and I still cant find out why

Re: The BIG Question
Posted by: RiggsFolly (---.dynamic.dsl.as9105.com)
Date: August 29, 2014 03:18AM

Do you mean you are typing www.example.com into the browser on a PC running inside your local network?

If yes this can be a problem. Most home/office routers dont have the feature required to loopback when the domain addressed is inside the local network.

Try testing external access from outside your local network, go next door or use your phone as long as its not connected to the routers wifi.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

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 databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Re: The BIG Question
Posted by: thebigquestion (---.169-130-66.mc.videotron.ca)
Date: August 29, 2014 06:24AM

Yes, externally using a pc in another location...when you type in the browser...www.examples.com

the only way I can get it to work externally is if I ....

in the win hosts file do this :

# localhost name resolution is handle within DNS itself.

# 127.0.0.1 localhost
192.168.0.101 examples.com

# ::1 localhost

change my httpd.conf to :

#Listen 12.34.56.78:80
Listen 192.168.0.101:80
Listen [::0]:80
Listen 127.0.0.1:80


ServerName examples.com:80


and my virtual hosts in httpd-vhosts are :

<VirtualHost *:80>
DocumentRoot "C:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "C:/wamp/www">
AllowOverride All

<IfDefine APACHE24>
Require local
</IfDefine>

<IfDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
</IfDefine>
</Directory>
</VirtualHost>

#Externally accessible site
<VirtualHost 192.168.0.101:80>
DocumentRoot "C:/wamp/www/examples.com"
ServerName examples.com
ServerAlias www.examples.com
<Directory "C:/wamp/www/examples.com">
AllowOverride All


Require all granted


</Directory>
</VirtualHost>


Then it works externally but when you click links to go into subfolders the address in the browser doesn't change ( page switches) ... in the browsers url it still says www.examples.com

if you refresh the browser page it returns you to the main page that's in the browser address bar

if you hit the back or forward buttons in the browser, they work but the url never changes from www.examples.com

these are my tags in the index.php that's in C:/wamp/www/examples.com :
</php
?>
<html>
<a href="/chat/index.php">www.examples.com's...CHAT</a>
<a href="/forum/index.php">www.examples.com's...FORUM</a>
<a href="/gallery/index.php">www.examples.com's...GALLERY</a>
</html>

The tags seem fine and should work, nothing funny in them, I've tried putting in "www.examples.com/chat/index.php" in the tag and it returns the url (googledIP address:8080/www.examples.com/chat/index.php" when you hoover over the link.



There seems to be a problem in associating that 127.0.0.1 and 192.168.0.101 are one in the same or its not understanding the ServerAlias or picking it up properly... but I haven't a clue why ???



Edited 3 time(s). Last edit at 08/29/2014 06:40AM by thebigquestion.

Re: The BIG Question
Posted by: thebigquestion (---.212-202-24.mc.videotron.ca)
Date: August 29, 2014 06:28PM

I've reconfigured and reconfigured trying all different ways, started from zero and there's just no way it will work the way its supposed to, read apache speek until I only saw 1's and 0's on the screen.....

it seems its being forwarded on my googled IP address port 8080 , comes in my ISP router which sends it along to my dlink router who takes it and sends it to my home server on 192.168.0.101 port 80...apache cant seem to connect this all up and realize that that the googled ip address port 8080 is 192.168.0.101 port 80 and reply correctly.

I don't know enough to know what to do or fix this and any help/suggestions would be appreciated.

Re: The BIG Question
Posted by: RiggsFolly (---.dynamic.dsl.as9105.com)
Date: August 29, 2014 07:03PM

Like I said, lets try a TeamViewer Session later today, I will be free in about 2.5 hours 20:30 UK

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

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