XAMPP Apache site-root-relative links work locally, fail when accessing dev site via remote machine over LAN - apache

Am trying to set up multiple site development areas on a single server machine, then work on content from other computers over LAN. (Excuse the general wording of my questions, the site keeps preventing me from entering example URLs, etc.)
When I work directly on the server machine, entering
my-virtual-host-name:port#
as the URL everything works beautifully. It correctly resolves all links, image references, etc, as being relative to the site root.
When I connect from a different machine, over our Lan, entering
server-ip-address:port#
I get automatically redirected to a default XAMPP welcome page (So I am at least connecting to the server)
I figured how to setup an Alias statement, so that, for example something like
server-computer-ip-address:port#/alias-for-file-path
gets me to the home page for my site. But subsequently when I click on links, for example
/products-services
which I would want to go to
server-ip-address/alias-for-file-path/products-services
it instead resolves to
server-ip-address/products-services
Relevant settings on the computer running the Apache server
IP Address: 192.168.22.12
In Windows Host file: 127.0.0.1 localhost mySiteName
In httpd-vhosts.conf:
NameVirtualHost *
<VirtualHost *>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "D:\companysites\newproducts\mysite"
ServerName mySiteName
<Directory "D:\companysites\newproducts\mysite">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
In httpd.conf (assigning alternate port to Apache, since 80 is otherwise used):
Listen 3399
Have tried a bunch of things not detailed here, trying to figure out how to correctly define some combination of server machine and remote machine virtual host definitions and url settings, as well as much web searching and zero luck so far!

At present you've set it up so all Virtual Hosts are listening for the same connection. Same ip from all ports. *

I figured it out, finally! Hopefully this will be useful and clear to someone else! (I am new to this, so may be obvious to others - there were some basic things I didn't understand and now do...)
In httpd-vhosts.conf file, you can:
Create any number of "Listen" statements, each with a unique port number. So, for example.
Listen 8885
Listen 8886
Listen 8887
Then you can create any number of VirtualHost definition sections, associating one of the above ports with each, for example:
NameVirtualHost *
<VirtualHost 192.168.22.11:3399>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost 192.168.22.11:3388>
DocumentRoot "file-system/path"
ServerName mySiteName
<Directory "file-system/path">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
When connecting to the server from a remote computer, it is not possible to use any combination of alias server names and/or alias file path names (at least, didn't work for me - if there is a way, I'd be interested to know). Instead, always enter ip-address:port#, for example, enter, as the URL to one of the defined sub-domains on the server machine:
192.168.22.11:3399

Related

WAMP Server cannot be accessed through local network [duplicate]

So I set up a few virtual hosts with unique urls and they work just fine on the desktop. However, when I connect a mobile device on the network, it can't seem to access anything properly but the default localhost virtualhost and that's only when it's the only virtualhost I have up.
My setup and coding is pretty much this except with a different site title
wamp server 3.0 virtual host on another device
and while that solution redirects me to my unique url, it has a lack of images on a default wordpress website.
Has anyone managed to get mobile devices fully accessing links other than on localhost?
Since I posted the answer you referenced, I have decided upon a simpler solution.
What the actual problem is
Because we cannot fiddle with the configuration of a phone like we can with a PC, the phone can never find the domain name we create in our Virtual Host definition on the Server machine, because it does not exist in any DNS Server for it to locate the IP Address in, and a DNS Server is the only place a phone can look, unless it is jail broke.
If you wanted to access one of your Virtual Hosts domains from another PC you could just add a line like this into the HOSTS file on the other PC like this.
192.168.0.10 example.local
But you cannot do that on a phone/tablet.
What Apache expects to be able to asssociate a request to a Vhost
When we create an Apache Virtual Host, we are actually telling Apache to look at the domain name on the incoming connection and match that domain name to a ServerName that exists in one of our multiple Virtual Hosts definitions.
But if we use for example example.local as our virtually hosted domain when we attempt to connect to that from our phone, the phone does a DNS Lookup and does not find that domain and therefore cannot get its ip address.
The simplest way to get round this is:
Assuming we do not have access to adding record to a DNS Server we have to come up with a different solution.
The simplest of these is to use the IP Address of the PC running the WAMPServer(Apache) server and a specific port number. So thats a different port number for each of our sites we want to use from a phone.
So how do we do this
Add the new listening port to httpd.conf like so after the 2 existing Listen statements
WAMPServer 3: Do this using the menus, not by doing a manual edit on httpd.conf
right click wampmanager-> Tools -> Add listen port for Apache
#Listen 12.34.56.78:80
Listen 0.0.0.0:80
Listen [::0]:80
Listen 0.0.0.0:8000
Listen [::0]:8000
Suggested httpd-vhosts.conf file
#
# Virtual Hosts
#
# Always keep localhost, and always first in the list
# this way a ramdom look at your IP address from an external IP
# maybe a hack, will get told access denied
<VirtualHost *:80>
ServerName localhost
DocumentRoot c:/wamp/www
<Directory "c:/wamp/www/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
# The normal Vhost definition for one of our sites
<VirtualHost *:80>
ServerName example.local
DocumentRoot "c:/websrc/example/www"
<Directory "d:/websrc/example/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
# Access example.dev from phone for testing
<VirtualHost *:8000>
ServerName example.local
DocumentRoot "c:/websrc/example/www"
<Directory "d:/websrc/example/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
# assuming yoursubnet is 192.168.0.?
# allow any ip on your WIFI access
Require ip 192.168.0
</Directory>
</VirtualHost>
Restart Apache from wampmanager after completing these edits.
Now you test this from the WAMPServer PC by using the ServerName i.e example.dev and from the phone using the ip of the PC running WAMPServer with the port number i.e. 192.168.0.10:8000
Apache will find the correct code to serve from both requests.
If you want more than one Virtual Host to be accessible from your phone you just duplicate this idea and change the port number for each new site, lets say you would use 8001,8002,8003 etc. For as many sites as you want to access.
You may also have to amend your firewall to allow access on http on port 8000, or whatever port you pick to use

WAMP - World Wide Access

I have installed WAMP on my computer running Windows 7. The Apache is running on port 80. I am searching here and there and everybody has its own solution. None of it fulfil the requirement.
Information:
Local IP: 192.168.15.52
External IP: 139.190.233.170 (Collected from whatsmyip.org)
Changed httpd.conf file:
ServerName 139.190.233.170:80
DocumentRoot "c:/wamp/www"
<Directory "c:/wamp/www">
Options Indexes FollowSymLinks
AllowOverride All
Order Deny,Allow
Allow from all
</Directory>
I have also added some rule for port 80 in Windows Firewall and also forward port for my LAN IP. Here is the pic:
Nothing happens after all that. Clicking "Put Online" and watching it to go green, nothing happens. I can access www directory by either localhost IP address (127.0.0.1) or my LAN IP address (192.168.15.152).
Questions:
Is it really possible to put WAMP for world wide access?
If it is possible, then how?
I have been searching around but none of them works. I have also searched SO:
Unable to access wamp server from outside my computer
How can i put my WAMP online for someone to access?
e.t.c
Some external sites:
http://www.computerforums.org/forums/server-administration/wamp-server-wont-work-outside-lan-help-207071.html
http://answers.yahoo.com/question/index?qid=20091005091249AAQrHxR
http://wordpress.org/support/topic/problem-accessing-wp-externally-using-wamp
http://wordpress.org/support/topic/self-hosted-wp-wamp-server-not-connecting-externally
http://webhosting.bigresource.com/WAMP-Access-Website-with-my-WAN-IP-pg1Bh4bJ.html
http://guides.jlbn.net/setaccess/setaccess1.html
It is possible, yes.
I would suggest momentarily disabling the firewalls, trying the connection and seeing if it works. If it does, you know it's firewall - turn windows one on and the other one by one to eliminate them. If it doesn't, you know you have issues.
Remember to run httpd -t from the command prompt to verify that your config is free of errors and of course make sure you restart apache and the W is green in the task bar. Make sure it actually is restarting, too - as some times things like mail servers (hMailServer I am particularly aware of) can stop it happening. In this case you need to restart the wampapache service from the services control panel (Start > services.msc).
Here's some extra info though, as you might be better setting up dynamic DNS. I use DynDNS and have the following vhosts conf:
<VirtualHost *:80>
ServerName mysite.dyndns.org
DirectoryIndex index.html index.php
DocumentRoot /home/mysite/
<Directory /home/mysite/>
AllowOverride All
Allow from All
</Directory>
# some logging stuff I cut out here
</VirtualHost>
Put that in mysite.conf inside c:/wamp/bin/apache/Apache2.2.21/conf/virtual. The mysite.dyndns.org is the host I have set up at dyndns. Finally, to make virtual hosts work, add this to your httpd.conf:
NameVirtualHost *:80
Include "c:/wamp/bin/apache/Apache2.2.21/conf/virtual/*.conf"
Now, if it still doesn't work you you probably have other issues. Can you telnet on port 80 to that above address? See above firewall issues.

XAMPP apache server not using the ports I desire, not certain why

So, I've been setting up this HTTP server for a school project that has to be able to maintain multiple domains through virtual hosts. Using XAMPP I have my server set up, I thought I'd done it properly but perhaps not.
I had heaps of issues with not being able to listen to a port, to solve this I used (in httpd.conf under apache/conf/)
Listen 0.0.0.0:8080
ServerName localhost:8080
If I used 80/81/8080/321/any combination that did not have the prefix 0.0.0.0 it told me the port could not be listened or whatever (sorry, a little rusty with my syntax).
I set up my first virtual host up like so (under apache/conf/extra/httpd-vhosts.conf):
NameVirtualHost *:8080
<VirtualHost *:8080>
DocumentRoot "H:/xampp2/xampp/htdocs"
ServerName localhost:8080
<Directory "H:/xampp2/xampp/htdocs">
Option Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I thought this seemed all good and well and I don't believe I've modified anything else. To me, I would expect that this means my Apache server would use port 8080 for the server? However, when I start Apache in XAMPP it states quite clearly
Apache started [Port 80]
Why would this be port 80?
In conjunction, localhost:8080 doesn't navigate me to the documents, but localhost:80 or localhost do. I presume that this just means it's still on port 80. I've tried resetting my computer and XAMPP.
If you need any more information, please let me know. I tried following guides such as this one: http://ailoo.net/2008/07/set-up-multiple-virtual-hosts-on-xampp-for-windows/
Cheers.
Oh, I also edited my Windows HOSTS file; it looks like so:
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
::1 localhost
127.0.0.1 localhost:8080
Edit: New error... Now getting this when I init, doesn't seem to be affecting it though:
ERROR: Status Check Failure [3]
This program must be run from your XAMPP root directory.
It is being run from teh root directory as far as I can tell.
Ok Im not advanced in this area either. However after much playing around with XAMPP and following a few different guides I got mine working.
The Host under drivers seems abit weird. I declared mine as:
127.0.0.1:8080 test.localhost.com
127.0.0.1:8080 test2.localhost.com
Back up you Xampp, then extract a clean install to C: - Just because that Status check failure sounds like bad news.
!Remember to run setup_xampp.bat from the xampp directory and install the apache service!
Then under you httpd.conf add:
ServerRoot C:\xampp\apache
Listen 7070
Listen 8080
Listen 9090
Apache might not like that at first but meh.
The ServerRoot may already be declared above the Listen spot so just double check.
After that head to C:\xampp\apache\conf\extra.
Edit the httpd-vhosts.conf.
Under the section Name-based virtual hosting add:
NameVirtualHost *:7070
NameVirtualHost *:8080
NameVirtualHost *:9090
There will be a couple of examples of virtual hosts below that. Add:
<VirtualHost *:7070>
DocumentRoot "C:/xampp/www/YOURWEBSITEDIR1"
ServerName test.localhost.com
<Directory "C://xampp/www/YOURWEBSITEDIR1">
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:9090>
DocumentRoot "C:/xampp/www/YOURWEBSITEDIR2"
ServerName test2.localhost.com
<Directory "C://xampp/www/YOURWEBSITEDIR2">
Allow from all
</Directory>
</VirtualHost>
Not the double slash in the Directory tag. Now ensure there is an index.html under each of those directories. Restart the apache (Stop, start).
I cant navigate to the test.localhost.com URLs, probably due to the fact they are terribly wrong in the HOSTs config. Though I can connect to 127.0.0.1:7070, 127.0.0.1:9090 and access the webpages from there.
Also 127.0.0.1:8080 connects me to the xampp welcome panel that localhost used to connect you too.
Hope this helps and good luck!
I'm pretty sure that saying 'listening on port 80' is hard-coded into XAMPP, regardless of the port you use. Thus, your code should work fine.
In my .conf file, it just says "listen 80" instead of Listen 0.0.0.0:8080
Cheers.

How to use xip.io with several virtualhosts and server names? (local dev)

Is it possible to use xip.io to access local website when using virtualhosts with different server names? (I'm on linux, fedora).
For instance, let's say I have 3 websites I can access locally like so:
- http://localsite1
- http://localsite2
- http://localsite3
I would like to access them with other devices via xip.io:
- http://localsite1.192.168.0.15.xip.io
- http://localsite2.192.168.0.15.xip.io
- http://localsite3.192.168.0.15.xip.io
I can't figure out how to make this work, is it even possible?
Yes, it should be possible. I think you can have as many localsite domains as you want to manage. Check your hosts and httpd-vhosts.conf files.
A server alias in my /etc/apache2/extra/httpd-vhosts.conf works for me. I use a * instead of the current IP in my Network Preferences.
Remember to restart the Apache server after you make a change.
For example, my current local IP from the Mac OS System Preferences > Network says: Wi-Fi is connected to Workalicious2011 and has the IP address 10.0.1.118.
So my /etc/apache2/extra/httpd-vhosts.conf file has the following:
# Ensure that Apache listens on port 80
Listen 80
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/Users/davekaplan/Sites/workalicious.com"
ServerName dev.workalicious.com
ServerAlias dev.workalicious.com.*.xip.io
ErrorLog "/private/var/log/apache2/dev.workalicious.com-error_log"
CustomLog "/private/var/log/apache2/dev.workalicious.com-access_log" common
</VirtualHost>
And my /etc/hosts file has:
##
Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 dev.workalicious.com
On my local network I am able to browse to the following and see my local development site:
http://dev.workalicious.com.10.0.1.118.xip.io/
I have a similar problem where I'm working on one mac and want to test on computers and other devices. Using .xip.io works great when you don't have access to a hosts file, on say a tablet.
If you have access to your hosts file on the computer you can add the IP of the local development host computer and just browse to the same url. It's great for PCs or other Macs. For example, I would add 100.0.1.118 dev.workalicious.com to the testing computer's hosts file and as long as I'm on the local network I can browse to dev.workalicious.com on that testing computer and see the site hosted over on the development computer.
Another approach that I used before .xip.io is Charles, it works great and there are some good blog posts out there on how to setup. It's currently $50 for a 1-4 Users.
( I'm working on try to figure out how to use Pow and Apache for a similar approach, but I don't think it works outside the local development machine. )
for me, server alias work.
ex:
<VirtualHost *:80>
<Directory "/home/michelangelo/www/mysite">
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
</Directory>
ServerAdmin michelangelo#mystie.com
DocumentRoot /home/michelangelo/www/mysite
ServerName mysite.local
ServerAlias mysite.local.192.168.0.6.xip.io
ErrorLog /home/michelangelo/public_html/logs/mysite_error_log
CustomLog /home/michelangelo/public_html/logs/mysite_access_log common
</VirtualHost>
tested on lubuntu
I was working on my project today and got stuck for a while but I've found a really easy setup which works like a charm.
You setup your virtualhost as you used to (do not have to use the alias xip.io at all tried it today)
Here comes the interesting part, when you edit host hosts file, enter your assigned local IP number before your domain name, e.g. 192.168.10.110 myawesomewebsite.com - which you can access at myawesomewebsite.com.192.168.10.110.xip.io

How to I point multiple URLs to the right directory?

I have a VPS running CentOS 5. I want to point multiple domains at the same VPS (point them at the same IP), but serve up distinct websites for each domain.
So, the setup I want is like this:
site1.com ----> 127.0.0.1 ----> /var/www/html/site1.com/
site2.com ----> 127.0.0.1 ----> /var/www/html/site2.com/
I've tried setting up virtual hosts through the CentOS GUI for Apache, but they don't seem to be working. Only the first virtual host added will work (i.e. If I add site1.com first, both domains direct to that site. If I add site2.com first, both domains direct to that site.)
What might I be doing wrong? Is there an effective step-by-step tutorial for newcomers to get me started?
Update
Please remember, I have little to no experience working with CentOS and Linux ... but I'm learning.
To those who asked to see the directives I'm using, here's what CentOS added to the bottom of /etc/httpd/conf/httpd.conf when I used the built-in Apache GUI:
<VirtualHost skylarkapp.com:80>
DocumentRoot /var/www/html/skylarkapp.com
<Directory "/var/www/html/skylarkapp.com">
allow from all
Options +Indexes
</Directory>
ServerName skylarkapp.com
</VirtualHost>
<VirtualHost eamann.com:80>
DocumentRoot /var/www/html/eamann
<Directory "/var/www/html/eamann">
allow from all
Options +Indexes
</Directory>
ServerName eamann.com
</VirtualHost>
At the moment, all traffic to both skylarkapp.com and eamann.com on this system direct to the content of /var/www/html/skylarkapp.com.
Also, I'm using my Windows hosts file to manually point eamann.com to this server (204.92.23.6) because I'm in the process of migrating a live site. I want to get things working on the server before I actually move things from one box to another.
Name-based virtual hosts must be turned on explicitly with NameVirtualHost *:80. See http://httpd.apache.org/docs/2.2/vhosts/name-based.html
This line:
<VirtualHost eamann.com:80>
won't work since eamann.com won't resolve to your CentOS server's IP address (only your Windows machine resolves eamann.com to 204.92.23.6). Try making apache listed on any IP by replacing with:
<VirtualHost *:80>
You probably also want:
ServerAlias www.eamann.com
to allow visitors to www.eamann.com to see the site as well. Restart apache after making these changes:
service httpd restart