'WAMP 3.1.3: Allow computers on the same LAN to access web server
I have WAMP 3.1.3 and a wordpress website installed in www/wp folder. I need to access the website from computers on the same LAN. I tried several solutions but none of them worked.
After I modified httpd-vhosts.conf as follows I gained access to WAMP's default page at http://192.168.13.20:2000/ through LAN.
# Virtual Hosts
<VirtualHost *:2000>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
Require ip 192.168.13
</Directory>
</VirtualHost>
However, http://192.168.13.20:2000/wp does not work. Would someone please help me for this problem?
Solution 1:[1]
1- Access to www and subfolders:
Normally, if you want to access your web server from another computer on the same LAN you get this error:
http://192.168.13.188/
Forbidden
You don't have permission to access / on this server.
Apache/2.4.33 (Win64) PHP/5.6.35 Server at 192.168.13.188 Port 80
(192.168.13.188 is the IP of the computer running WAMP server)
Similarly, the same thing happens for the subfolders of the www root:
http://192.168.13.188/wp/
Forbidden
You don't have permission to access /wp/ on this server.
Apache/2.4.33 (Win64) PHP/5.6.35 Server at 192.168.13.188 Port 80
This issue can be simply solved by editing “httpd-vhosts.conf” file as follows:
Click WAMP icon > Apache > httpd-vhosts.conf
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
Require ip 192.168.13
</Directory>
</VirtualHost>
You have to add "Require ip 192.168.13". Note that 192.168.13 is the subnet of your LAN. This will allow all computers in the LAN to access your web server.
Do not forget to restart Apache service. Otherwise the changes will not take effect.
You can also be more specific:
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
Require ip 192.168.13.207
Require ip 192.168.13.20
</Directory>
</VirtualHost>
This will only allow computers with IP addresses 192.168.13.207 and 192.168.13.20.
2- Access to phpmyadmin:
Even after granting access to LAN computers, they won’t have access to phpmyadmin because it has been explicitly blocked in phpmyadmin’s alias configuration. Therefore, we have to edit the configuration file as follows:
Click WAMP icon > Apache > Alias directories > http://localhost/phpmyadmin/ > Edit alias
Alias /phpmyadmin "c:/wamp64/apps/phpmyadmin4.7.9/"
<Directory "c:/wamp64/apps/phpmyadmin4.7.9/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride all
<ifDefine APACHE24>
Require local
Require ip 192.168.13
</ifDefine>
<ifDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from localhost ::1 127.0.0.1
Allow from 192.168.13
</ifDefine>
# To import big file you can increase values
php_admin_value upload_max_filesize 128M
php_admin_value post_max_size 128M
php_admin_value max_execution_time 360
php_admin_value max_input_time 360
</Directory>
You have to add "Require ip 192.168.13" and "Allow from 192.168.13".
3- Access to a wordpress website:
If you try to access a wordpress website in your LAN, another problem arises. The wordpress is configured to redirect you to localhost by default. In other words, if you aim to access your site at http://192.168.13.188/wordpress/ the wordpress tends to be opened at http://localhost/wordpress/ and of course this will result in error because your website is not on the localhost of the client computer, it is on the 192.168.13.188!
If you are using Internet Explorer you won’t notice this redirection because IE does not reflect it and just shows you an error page. However, if you try to open your website in Chrome or Firefox you will see that you are being redirected to localhost. Anyway, this issue can be resolved as follows:
Login to wordpress admin panel > Settings > General
Edit ” WordPress Address” and “Site Address” fields. Change localhost to your IP address:
WordPress Address (URL): http://192.168.13.188/wordpress
Site Address (URL): http://192.168.13.188/wordpress
That’s all. If you have other suggestions to complete this answer please leave comments.
Solution 2:[2]
Anyone with this problem who is using the latest version of WampServer may find this step-by-step solution helpful.
- Add another Apache listening port.
= Right-click on the (green) WampServer icon in the taskbar. Select 'Tools'. From the big popup menu pick 'Add a listen port for Apache.' In the 'Enter the desired port number' popup, enter your chosen number. (You may be presented with "8081": delete it and type in the port number you want to add.) Press OK. Wait a good while: a series of command prompt windows will open and close.
- Create a new virtual host on WampServer, including your new port.
= (To get the address of your website on your computer, use the File Explorer to locate the folder where the website is located, then right-click in the address bar and select "Copy address as text.") Click on the WampServer icon and select localhost (or go to the bookmarked page if you have bookmarked it). Under 'Tools' select 'Add a Virtual Host.' On the form page enter the name you want your website to go by; paste the address into the path field; click on the checkbox by "Listen Port"; select the port you have just added; and (finally) click on the "Start the creation …" button.
- (A vital step) Add the first 3 numbers of your static IP address to the Virtual Host directives in httpd-vhosts.conf.
= Click on the WampServer icon, and select 'Apache', then pick the httpd-vhosts.conf file. In the set of directives setting up your new virtual host, locate the line "Require local". Immediately under that line, create a new line "Require ip N.N.N" where N.N.N. are the first 3 numbers of your static IP address (most likely: 192.168.0 or 192.168.1). Save the file and close it.
- Restart DNS.
= Right-click the WampServer icon, select 'Tools' and click on 'Restart DNS'. Wait for the icon to turn green again.
- In a browser on your device, use this formula to view your website: http://{IP Address of computer with WampServer}:{port number}. E.g., http://192.168.0.7:8001
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sys Soft |
| Solution 2 | Michael Scannell |
