Can't access my virtual host from mobile
Posted by: LeeH (---.plus.com)
Date: August 05, 2017 04:16PM

Hi everyone

I am very new to wamp, and I am having problems accessing a simple php test page from my virtual host from Android (from my android browser I put: machine ip/test/testpage.php). This is works fine in Windows. For testing only I copied my testpage to www folder and temporarily changed Wamp's default localhost setting from 'Require local' to 'Require all granted' in httpd-vhosts.config, and after restarting Wamp was able to access the test page in my android browser. But if I do the same thing to my added virtual host then restart I get: forbidden error.

I have also tried adding 'Require ip 192.168.1' to my test vhost but no change. After that I temporarily edited my httpd.conf file with adding:

Listen 0.0.0.0:81
Listen [::0]:81

then setting my test vhost port to 81 but still get forbidden error (after I set httpd.conf back)

I also tried to create an inbound rule in my windows firewall but that did not work either. I have searched many posts on the net but nothing is working. I use:

Windows 10 64 bit
Wamp 3.0.6 64 bit
Apache 2.4.23
PHP 5.6.25 and 7.0.10
MYSQL 5.7.14


The wamp icon is green
No errors at bottom of any page
I have access to phpmyadmin
I use total security for antivirus
the path of my installation is C:\wamp64\www

my httpd-vhosts.config:

# Virtual Hosts
#

<VirtualHost *:80>
ServerName localhost
DocumentRoot c:/wamp64/www
<Directory "c:/wamp64/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>

#
<VirtualHost *:80>
ServerName test
DocumentRoot "c:/wamp64/www/test"
<Directory "c:/wamp64/www/test/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
Require ip 192.168.1
</Directory>
</VirtualHost>


I am really stuck here, so thanks for any help



Edited 4 time(s). Last edit at 08/06/2017 04:21PM by LeeH.

Options: ReplyQuote
Re: Can't access my virtual host from mobile
Posted by: RiggsFolly (Moderator)
Date: August 07, 2017 01:18PM

Hi,

First of all please upgrade to the latest WAMPServer
You can download the update From the backup repo it is easier to navigate then SourceForge and then download and install the V3.0.9 update or whatever the latest version of WAMPServer at the time you read this.
This will only amend WAMPServers own code and NOT the versions of Apache/MySQL/PHP/etc that you are using.

This is the method I use to allow access to a Virtual Host from a Phone/Tablet and WHY!

The normal way to run a Virtual Hosts defined site is to setup a VH and then place the domain name into the HOSTS file on our WAMPServer PC.
This seeds the DNS Cache with the knowledge that `example.com` lives on a PC with the ip address `127.0.0.1` or `::1` i.e. Our local PC.
This just stops the browser going out to a DNS Server and looking for our VH's domain name i.e. `example.com` and of course failing to find it.

Now on a Phone/Tablet we cannot access the HOSTS file, and therefore cannot tell the phones browser that `example.com` lives on ip address `192.168.1.10` (EXAMPLE ONLY our WAMPServer PC's ip address )

Because the phone's browser will attempt to find the domain name used in the browser address bar with a DNS Server, we need another way of forcing the Phone's Browser to go to the correct ip address to find our Virtual Hosts defined site.

We can do this by entering the IP Address of the PC running WAMPServer instead of our Virtual Hosts domain name. This gets around the first problem.
Now we need to define our Virtual Host a little differently so that it is the site that gets picked up by Apache as the correct site. We do this by adding a specific port number to each Virtually Hosted site we want to access from a Phone/Tablet.

So :

1. Add another Listening port to WAMPServer (Apache) using the WAMPServer menus.

- right-click on wampmanager -> Tools -> Add a Listen port to Apache
- - In the dialog box enter the port number you want to use EG 8000
- - Please dont use the same port number more than once

2. Edit the httpd-vhosts.conf file, using the wampmanager menus
- left-click wampmanager -> Apache -> httpd-vhosts.conf
- - Add the new Virtual Host Definition AFTER the existing `localhost` [Never remove the localhost definition]

## Access Site from the WAMPServer PC
<VirtualHost *:80>
    ServerName example.dev
    DocumentRoot "c:/wamp64/www/example/www"
    <Directory "c:/wamp64/www/example/www/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

## Access Site from Phone/Tablet
<VirtualHost *:8000>
    ServerName example.phone
    DocumentRoot "c:/wamp64/www/example/www"
    <Directory "c:/wamp64/www/example/www/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require ip 192.168.1
    </Directory>
</VirtualHost>

- - Note I have used that same port number i.e. 8000 as I used in step 1, if you picked a different port also use that different port on the `<VirtualHost *:8000>` line

---------------------------------------------------------------------------------------------
(Windows 7 Pro 32bit) (Wampserver 3.0.6 32bit)
<Apache 2.4.23/2.2.31> <PHP 7.1.2/7.0.16/5.6.28/5.5.38/5.4.45/5.3.29> <MySQL 5.7.10/5.6.17/5.5.28>
<MariaDB 10.1.21> <phpMyAdmin4.6.5.2> <MySQL Workbench 6.3.6.511>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin -- WAMPServer alternate Repo
-?-?-?- Backup your MySQL databases regularly Here is How dont regret it later! Yes even when developing -?-?-?-

Options: ReplyQuote
Re: Can't access my virtual host from mobile
Posted by: Laxmikanth (157.48.23.---)
Date: August 15, 2017 12:57PM

Hi ..

I have a question to ask you.

Please say how to make our local host website make visible publicily.I've seen a lot of videos and they all mentioned about portforwarding but i dont know how to do that .So please help me some way to make my website public so that others can see my website.

Thank you!

Options: ReplyQuote
Re: Can't access my virtual host from mobile
Posted by: RiggsFolly (Moderator)
Date: August 15, 2017 03:51PM

Please look at portforwarding.com.

As this process is nothing to do with WAMPServer directly we do not support this process. Afterall there are thousands of routers and we cannot know all of them

---------------------------------------------------------------------------------------------
(Windows 7 Pro 32bit) (Wampserver 3.0.6 32bit)
<Apache 2.4.23/2.2.31> <PHP 7.1.2/7.0.16/5.6.28/5.5.38/5.4.45/5.3.29> <MySQL 5.7.10/5.6.17/5.5.28>
<MariaDB 10.1.21> <phpMyAdmin4.6.5.2> <MySQL Workbench 6.3.6.511>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin -- WAMPServer alternate Repo
-?-?-?- Backup your MySQL databases regularly Here is How dont regret it later! Yes even when developing -?-?-?-

Options: ReplyQuote


Sorry, only registered users may post in this forum.