I have already installed XAMPP in my local computer and also a wordpress website. Is there any way to see the default page of my wordpress website (only the page, not the administration) from an another PC in the same network (home network)?
Having a URL such as http://example.dev/index.php instead of http://localhost/example/index.php is much clearer, works better with some website "extensions" involving paths and routing, and stored passwords are much easier to manage in browsers. Let's face it, it's just better all around.
EDIT: Since you've asked for external access (two PCs), I've changed this from my original configuration example, which is isolated from access except through the loopback interface. This example assumes your LAN is properly secured. Either firewall your LAN or change configuration as noted in commented portions of the configuration file to be more specific about access.
There are a few steps to get it working, but once you get used to the two files you'll work with, it's quite easy to set up a new project later.
Activate Modules in httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule log_config_module modules/mod_log_config.so
Activate Virtual Host Settings in httpd.conf
#Listen 12.34.56.78:80
Listen 80
<VirtualHost *:80>
Comment out directory information
#DocumentRoot "E:/xampp/htdocs"
#<Directory "E:/xampp/htdocs">
...
Be sure to close the VirtualHost directive before the file includes:
</VirtualHost>
Configure Virtual Hosts Configuration File
After making the previous changes to Apache’s base-level conf file, you can work with the vhost extra conf file (%xampp%/apache/conf/extra/httpd-vhosts.conf).
<VirtualHost *:80>
ServerAdmin webmaster#myexamplesite.dev
DocumentRoot "C:\Users\JHaas\Documents\Projects\MyExampleSite"
ServerName myexamplesite.dev
ServerAlias myexamplesite.dev
ErrorLog "logs/myexamplesite.dev-error.log"
CustomLog "logs/myexamplesite.dev-access.log" common
<Directory "C:\Users\JHaas\Documents\Projects\MyExampleSite">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from none
Allow from all
#Allows a specific IP to access your VHost
#Allow from 10.0.0.24
</Directory>
DirectoryIndex index.html index.php
</VirtualHost>
Editing /etc/hosts
Finally, you edit the /etc/hosts file. This file is helps your system bypass the need for a DNS query, allowing you to create your own TLD (top-level domain) suffix such as *.dev, or anything that isn’t going to collide with current new top-level domain suffixes (*.me used to be quite popular until that suffix itself became a TLD suffix).
The localhost entry is not always required (depending on platform), and from my experience has actually caused problems if uncommented, so leave it commented out if it is already. If you see that localhost is not commented out (again, depending on your platform), be sure to leave it so. Changing the localhost entry from default can cause issues for many network services if it’s changed.
Also note that chrome has an issue with using *.local, so it’s probably best to avoid using this TLD suffix.
Host computer:
127.0.0.1 localhost
127.0.0.1 myexamplesite.dev
On the other computer, modify the /etc/hosts file to have an entry for your computer.
10.0.0.27 myexamplesite.dev
You can test your changes to the configuration files via command line using apache/bin/httpd.exe -t. This runs a syntax check on your configuration files.
Lets assume the ip of the pc running xampp is 192.168.0.198 and you are using the standard xampp setting regarding ports and the wordpress sites folder (testproject) sits in the xampp htdocs folder then you could access the site within the local network via:
http://192.168.0.198:8888/testproject/
Hope that helps. Best regards Ralf
Related
This was working for years until I did something that has now jacked this up....
Searching on this topic landed me in several places that basically said: You need to check the Wordpress URL and the site URL in the general settings in Wordpress. I have done so and they are both: http://www.petesworkshop.com/blog_wp . Yet, when I hit that URL I am redirected to my internal IP and get a error http://10.0.10.206/blog_wp (yep, that would be wrong!
Interestingly enough, I can get to the admin page just fine and it is just a subfolder of blog_wp. So, somehow things directed to /blog_wp return the IP but everything else is OK. Wierd.
Wordpress sits behind an Apache proxy which has this directive for the virtual host:
<VirtualHost *:80>
ServerName www.petesworkshop.com
ServerAlias petesworkshop.com
ProxyPass / http://10.0.10.206:5080/
ProxyPassReverse / http://10.0.10.206:5080/
</VirtualHost>
The server running the website behind the proxy has this:
DocumentRoot "/www/petes/htdocs/petesworkshop/"
ServerName www.petesworkshop.com
ServerAlias petesworkshop.com
DirectoryIndex index.html index.php index.htm
ErrorLog logs/petesworkshop.log
Options FollowSymLinks
Alias /blog_wp /www/petes/htdocs/petesworkshop/blog_wp
<Directory /www/petes/htdocs/petesworkshop/blog_wp >
Order Allow,Deny
Allow From all
</Directory>
<Directory /www/petes/htdocs/petesworkshop >
Order Allow,Deny
Allow From all
</Directory>
I am not sure how I jacked this up...it is probably something that I did to the Apache configuration but I can't be sure since everything else behind the proxy works fine. I even tried adding specific ProxyPass entries for /blog_wp but that didn't make any difference.
Stumped...
Check your wp-config.php for correct urls
like below
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
This one turned out to be an Apache proxy issue. What I needed was to add 'ProxyPreserveHost On' to the configuration, which I thought I had in there originally but I either removed it in an edit or had it placed in the wrong virtual host. In any case, adding the ProxyPreserveHost On flag, took care of the issue. Not sure why other entries in the same virtual host DID work without it but I am not going to worry about it.
I had a similar problem some time ago, whenever I wrote my domain in the browser it was solved correctly but my domain name was changed by the IP, after much research it turned out that the problem was in the hosting, not in the server, so which only change the configuration of my domain in GoDaddy since I was only doing a redirection but the correct thing was to create an A record that points to # (which represents your domain name) and everything started to work correctly. I hope it's help
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?
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
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
Couple of good tutorials on getting these setup:
View MAMP Virtual Hosts On Your iPad and iPhone Over The Local
Network - BenjaminRojas.net http://goo.gl/6hM4Aa
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)
My wordpress site works fine on my mac via localhost, using Xammp. I want to view the site on my iPhone. So I type in 192.168.0.2 and voila, it brings up my localhost directory. I then click on the site in question and the content is there but no styling or images. I realise that this is because the paths to all the resources is hardcoded into the wordpress database. So when I am accessing the url via 192.168.0.2/mywebsitename on my iPhone, it's looking for all the resources using a base url of localhost/mywebsitename. Localhost path doesn't exist on my iPhone, only 192.168.0.2 does.
So has anyone found a solution to this little issue? How can I see a wordpress installation by ip address and by localhost access?
For this exact issue, before developing a website. You must create a domain(VirtualHost in apache)
Add the following contents in the file httpd-vhosts.conf, make sure it is included in Apache Configuration. This line ( Include conf/extra/httpd-vhosts.conf ) should be present in httpd.conf
Contents of httpd-vhosts.conf:
NameVirtualHost 192.168.1.26:80
<VirtualHost 192.168.1.26:80>
<Directory "e:/program files/ampps/www/mywebsite">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
allow from All
</Directory>
ServerName 192.168.1.26
ServerAlias 192.168.1.26
ScriptAlias /cgi-bin/ "e:/program files/ampps/www/mywebsite/cgi-bin/"
DocumentRoot "e:/program files/ampps/www/mywebsite"
ErrorLog "E:/Program Files/ampps/apache/logs/192.168.1.26.err"
CustomLog "E:/Program Files/ampps/apache/logs/192.168.1.26.log" combined
</VirtualHost>
(Change the path, ip, etc according to your need). Now after adding the contents. Restart Apache. Now when you access 192.168.1.26 (in my case) from other machine in your network or your same machine. You should see the contents of mywebsite folder directly(or contents index.php if it has any). Now install wordpress using the ip you specified(browser should have that ip in the address bar), in my case 192.168.1.26.
Well I use AMPPS to avoid this headache. It allows me to create domains locally. Also if I have bought a domain say mywebsite.com and i want to add a customized wordpress site on, I create a the domain in the AMPPS with the same name. So the URL of my live website and the local are same. :) Then I simply put the files directly on my server via FTP and obviously import the database on my server.
EDIT: BTW, AMPPS allows to install WordPress in a single click. It has simple interface where you can specify AMPPS to install the WordPress on the created Domain.
Although I’ve found related articles on stackoverflow, I have seen various suggestions which I’ve tried out but I still experience problems, so that’s the reason why I’m posting this.
I have a question which involves DNS, Debian, Apache2 and Wordpress. I’ve been struggling with this for some time now and haven’t been able to solve it. My current conclusion is that 2there is something with my dns and apache virtual host definitions”, but, as I said I’m far from sure.
This is what my config looks like:
two domains which I “own” hosted by moniker.com - let’s call them domaina and domainb
a hosted vps with Debian, apache2 and wordpress. The vps has ip x.y.z.t
each domain has three ‘A’ records defined: ‘*’, ‘#’ and ‘www’
URL rewrite enabled (a2enmod rewrite)
Wordpress installed and links created to the wordpress directory for both document directories specified in the virtualhost directives below
Both ‘domaina’ and ‘domainb’ point to my vps and this is working ok. However, what I’ve been unable to solve is to have the vps handle “multiple virtual hosts”. I thought I would be able to handle this by using virtual hosts in Apache. For that purpose I’ve defined two sites under /etc/apache2/sites-available which looks like this:
(file: /etc/apache2/sites-available/domaina.com)
<VirtualHost x.y.z.t:80>
ServerName domaina.com
ServerAdmin me#domaina.com
DocumentRoot /var/www/domaina.com
DirectoryIndex index.php
<Directory /var/www/domaina.com/>
AllowOverride all
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
(file: /etc/apache2/sites-available/domainb.com)
<VirtualHost x.y.z.t:80>
ServerName domainb.com
ServerAdmin me#domainab.com
DocumentRoot /var/www/domainb.com
DirectoryIndex index.php
<Directory /var/www/domainb.com/>
AllowOverride all
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
Now, when I try to address the sites above from a web-browser I end up at the default apache directory with the index.html file rendered in the browser instead of arriving at the two different wordpress configurations. Obviously there’s something wrong with my thinking around “VirtualHosts” and/or DNS-configurations…
I forgot to mention that I've made loads of /etc/unit.d/apache2 restarts... Sorry...
Frankly speaking I’m lost here and any help on this would be very much appreciated.
Cheers
If you did restart apache and its still not working please respond, as I have experienced similar issues with Apache, especially when getting the virtual host to work. I realise your running on Debian which is different to WAMP, but this is what I do when opening a new virtual host.
First I add the domain to the windows system 32 drivers etc hosts file, it allows for intranet
127.0.0.1 domainname and this stops the url from looking to the web.
Then I have to add the corret directories to the www/your folder.
Just inside the root folder there ought to be a directory called vhosts,
I had to make totaly empty instances of the conf files with just the filename of the virtual hosts inside it so that the changes you made to the httpd-vhosts.conf works.
So what you will need to do is find the wamp/bin/apache/Apache2.2.21/conf/extra/httpd-vhosts makes sure that you have the one from the conf/axtra and not conf/orginal.
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/**name of the folder**"
ServerName **as_inserted_in_hosts**
<directory "c:/wamp/www//**name of the folder**">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</directory>
</VirtualHost>
Save. Apache stop all services, I also have to restart the service running the intranet in windows to update the changes to the hosts file and then restart apache.
This is what I have to do so that when I open localhost from Apache it allows me to see the links appear under virtual hosts as well as the directories appearing under your projects.
Have a look at this tutorial... Explains how to set up virtual hosts
Do you have a NameVirtualHost directive in your apache2.conf anywhere? You'll need that to enable virtual hosting. It can go in apache2.conf or any file included by apache2.conf. On my server I've got it in ports.conf.
NameVirtualHost *:80
See http://httpd.apache.org/docs/2.2/vhosts/name-based.html#using
Basically what I run now on my home PC is one of these WAMP in a box applications so I can write my PHP code and use a MySQL database. That is all fine, but I run a lot of websites so now I have a folder I've called /~WEBSITES/ where I put everything making the URLs to these http://localhost/~WEBSITES/domain.com/ -- what I'd like is to be able to type http://local.domain.com/ into my address bar and have it point to my local drive, but I don't want this for everyone, just me.
Possible?
NOTE: I've running Windows XP
You'll need to setup virtual hosts with Apache, and combine that with HardCode's answer (setting your hosts file). That should do what you need.
AUTHOR EDIT: Great article, here's the quick notes on what to do (at least with the most recent version of apache2triad as your WAMP installer)
Add to C:\APACHE_INSTALL_DIRECTORY\conf\httpd.conf:
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
DocumentRoot "C:\apache2triad\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost 127.0.0.1>
DocumentRoot "C:\apache2triad\htdocs\~WEBSITES\Domain1.com"
ServerName local.domain1.com
</VirtualHost>
<VirtualHost 127.0.0.1>
DocumentRoot "C:\apache2triad\htdocs\~WEBSITES\Domain2.com"
ServerName local.domain2.com
</VirtualHost>
Add to C:\Windows\system32\drivers\etc\hosts
127.0.0.1 localhost
127.0.0.1 local.domain1.com
127.0.0.1 local.domain2.com
Modify the text file named "hosts" found in C:\Windows\system32\drivers\etc\
Suppose you want to point www.mycustomer.com to your local host. Add in:
127.0.0.1 www.mycustomer.com
You'll need to setup virtual hosts in apache (not IIS... oops), and combine that with HardCode's answer. That should do what you need.