Accessing local Wordpress site within the network

2019-06-07 04:08发布

问题:

Allright this driving me nuts! I have spent couple of hours trying to find a solution of how to access my Wordpress site from outside my network, when no easy solution was found I'm OK with just being able to accessing it from another device within my network. It turned out to be a tricky part as well. I just don't know how to configure this.

I run virtual hosts using WAMP likeso:

In httpd-vhosts.conf:

<VirtualHost *:80>
    DocumentRoot "I:\web_dev\wordpress"
    ServerAlias wordpress.local
    ServerName wordpress.local
    <Directory "I:\web_dev\wordpress">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
        Require local
    </Directory> 
</VirtualHost> 

My httpd.conf file is set to port 80:

ServerName localhost:80

Hostsfile:

127.0.0.1 wordpress.local

If I now want to access this from another computer or my mobile that are in my network, how do I achieve this?

回答1:

Allow local traffic in httpd.conf, then use your actual IP as the WP URL.

In WAMP's httpd.conf file, I added the Allow from 192.168 line.

# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from 192.168

Then in the WP General settings, I changed the Wordpress Address and Site Address to the site's actual IP. You can get this site's IP4 address via ipconfig in the command console.

Then you're done.

If you don't want people on your local network snooping around the rest of your WAMP setup, create a new .htaccess file in the servers root (the www folder) with this:

Order Deny,Allow
Deny from all
Allow from 127.0.0.1

Then add this above whatever is in WP's default .htaccess

Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from 192.168


回答2:

You'll need to change your Listen directive to listen to the network IP or 0.0.0.0 rather than localhost if that is not yet done. Then on the other computer edit the hosts (usually C:\windows\system32\drivers\etc\hosts or /etc/hosts) file to include the IP of the webserver computer mapped to wordpress.local

192.168.2.54 wordpress.local


回答3:

Couple of good tutorials on getting these setup:

  1. View MAMP Virtual Hosts On Your iPad and iPhone Over The Local Network - BenjaminRojas.net http://goo.gl/6hM4Aa
  2. How to access MAMP sites across a network - CodeBoxers http://goo.gl/qCXMQK (scroll down to the xip.io portion)

"The solution is to create a local proxy server on the machine that has MAMP installed, and then configure the client to use that proxy to browse the web. The client configuration only takes a few seconds, and is easy to disable once you’re done." - Dalton Rooney (from the first link)