Can anyone shed some light on ideal test server config?

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Can anyone shed some light on ideal test server config?

Postby G64 » 06. November 2008 09:12

Hi, I'm new to this forum, quite unexperienced with XAMPP and not really technically strong.

I've installed XAMPP portable on a key and it works like a bliss. I used it to test and develop surveys with LimeSurvey (much faster locally).

Now I want to use my local XAMPP server as my test/dev server to integrate my work with LimeSurvey to my website.

I run two sites on different IP addresses:
1- www.mysite.com
and
2- secure.mysite.com, an SSL site running on a separate IP for members area and payment processing

On my machine I have local versions of both sites and I would like to be able to access them with the local XAMPP version in a way that I can use XAMPP to test my developments before taking them live.

So I copied my two local versions to my USB XAMPP portable, in F:\xampp\htdocs as follows:
F:\xampp\htdocs\mysite.com
F:\xampp\htdocs\mysite.com.secure

and tried to call some pages:
http://localhost/mysite.com
or
https://localhost/mysite.com.secure/hello_world.php
I get 500 server errors.

Then I removed the .htaccess (this is not ideal because I use modRewrite for some URLs) When I do so, all my PHP inclutes fail because the paths are wrong:

Apache is looking for my include here:
F:/xampp/htdocs/inc/footer.inc.php
instead of:
F:/xampp/htdocs/www.mysite.com/inc/footer.inc.php

So I think I'm missing some Apache config details. I looked into the Apache doc, and I am confused because I'm only trying to setup a local test server, not a live www server.

the httpd.conf file is huge and complex for my relatively low level of technical knowledge, let alone the Apache doc which I don't really understand.

Can anyone tell what config settings I should add so to be able to:

- keep my local copies where they are (F:\Documents) instead of copying them to F:\xampp\htdocs?
- keep my .htaccess the way it is working on my live site (or close enough)
- browse and test locally?

Also can anyone suggest what those local URLs should look like? for example:
http://test.mysite.com
https://securetest.mysite.com

Thanks in advance for your suggestions!

G64
G64
 
Posts: 5
Joined: 06. November 2008 08:10

Postby Sharley » 06. November 2008 11:04

Virtual host is what I believe you need to set up in the .\xampp\apache\conf\extra\httpd-vhosts.conf file.

Before you start setting up a vhost it would pay you to revert your httpd.conf file to the defaults that came with XAMPP when you installed it.

Configuring the httpd-vhosts.conf file will permit you to retain the XAMPP localhost admin pages and allow you to do what you want with as many domain names as you wish.

First off do some research by searching these English forums for keyword vhost and because you want to use a folder outside the localhost htdocs folder you will need to configure each vhost container with overriding permissions that are set to be restrictive in the httpd.conf file for any folder outside the htdocs folder for obvious reasons - you don't want those script kiddies roaming just where they please via your apache server.

Just to try and give you a clue for one of your domains, I put together this httpd-vhosts.conf example just to get you started with understanding what it is all about - tip is to create one at a time and get that domain running smoothly then add another and get that working and so on for as many as you need (I have 17 domains and sub-domains up and running both local and from the Internet).

Drop the use of test in your domain names as it can give issues and so I have not used it in this example.
http://mysite.com
https://secure.mysite.com
Would be suitable names but of course mysite is only an example.
Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot "F:/xampp/htdocs"
</VirtualHost>

<VirtualHost *:80>
ServerName mysite.com
ServerAlias www.mysite.com
DocumentRoot "F:/Documents/mysite"
<Directory "F:/Documents/mysite" >
Options Indexes +FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ "F:/Documents/mysite/cgi-bin/"
ServerAdmin serveradmin@mysite.com
CustomLog logs/mysite.log combined
ErrorLog logs/mysite.log
LogLevel error
</VirtualHost>

You also have to add some values to your HOSTS file.
.\WINDOWS\system32\drivers\etc\HOSTS
Drag the file into yout text editor and add these if they are not included.

Top line:
127.0.0.1 localhost
127.0.0.1 mysite.com
(plus you add any more you create in the httpd_vhosts.conf file.

The above example will also allow your .htaccess file in the root web folder (mysite) of your domain mysite.com - I prefer not to use .com in a folder name of my domains but simply to use the domain name only.

Apache server is case sensitive and if possible try and keep folders (Documents to documents) and file names all lower case to eliminate confusion and the inevitable error - Windows couldn't care less but Apache does.

Keep the httpd.conf file defaults and do your configurations for your domains in the httpd-vhosts.conf file - make sure your XAMPP installations works on http://localhost and goes to the XAMPP Admin pages then proceed to configure the httpd_vhosts.conf file.

There are plenty of examples in the search results I mentioned above for you to get your teeth into.

Now it's up to you to have a go and see how it pans out - there is always help on these forums if you get hopelessly bogged down.

Good luck.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Postby G64 » 06. November 2008 12:04

Thank you so much Sharley, the information sheds a lot of light indeed and like you said, I'm going to see how it pants out.

Just before I dive in though, if I may, I'm still not clear on how this will turn out:

After implementing your suggested configuration, if I want to load a test page from my local XAMPP install, I should then type in my browser:
http://www.mysite.com/page1.php (using the server Alias) is that right?

So then what about if I want to load the same page from the live server?
Do I type the same?

How will my browser make the difference? Or how do I specify which server I want, local test server or www live server?

Somewhere I seem to be missing something... Do you know how to do it?

Thanks, G64
G64
 
Posts: 5
Joined: 06. November 2008 08:10

Postby Sharley » 06. November 2008 13:10

G64 wrote:After implementing your suggested configuration, if I want to load a test page from my local XAMPP install, I should then type in my browser:
http://www.mysite.com/page1.php (using the server Alias) is that right?

So then what about if I want to load the same page from the live server?
Do I type the same?

How will my browser make the difference? Or how do I specify which server I want, local test server or www live server?

Use a local domain name for local testing for example mysitelocal.com
as if you're connected to the Internet then your browser will for sure go to your hosted mysite.com because of DNS - mysite.com at your registrar will point to your mysite.com IP at your hosting service which is what you want it to do.

ServerName mysitelocal.com
or
ServerName local.mysite.com

Hosts file
127.0.0.1 mylocalsite.com
or
127.0.0.1 local.mysite.com

You could use an alias for example:
ServerName mysite.com
ServerAlias local.mysite.com

Then type in your browser with XAMPP running and connected to the Internet
http://mysite.com will go to the Internet
http://local.mysite.com would go to your local XAMPP hosted site.

In the hosts file you would use
127.0.0.1 local.mysite.com
not
127.0.0.1 mysite.com

It's a case of understanding what the ServerName is and what the DNS system is.

If your hosting service is on the Internet then your browser will send the request for a page through your ISP's DNS servers to look for the IP related to the domain name in the request that is registered at your domain name registrar, after first not finding it in your HOSTS file - mysite.com relates to 123.123.123.123 (or whatever the IP is)

If your hosting on your Localhost then your browser will look in the HOSTS file for an IP and related domain name then looks for a server configured with a ServerName related to that domain name usually on port 80 and request the server for the page - 127.0.0.1 local.mysite.com (or any domain name of your choosing associated with ip 127.0.0.1 which is Localhost).

Sounds complicated but once you are engrossed in it I am sure it will become much clearer.

Hope this helps a tad.

My advise now is to get into it and have a go using say local.mysite.com or mysitelocal.com as the ServerName - you could even just use mysite without the .com as the ServerName of your local site (I have a vhost configured in my httpd-vhosts.conf file just using mysite as the ServerName which I use for a live server in DreamWeaver.

Always backup conf files and ini files before making any changes so that if you make any typos or errors then it a simple job to revert to a known working configuration thats lets you start over again.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Postby G64 » 06. November 2008 15:38

Ok, after jumping into it, I'm getting some progress but I'm not quite there yet...

Here is the current config:
.\xampp\apache\conf\httpd.conf is left as is by default
.\WINDOWS\system32\drivers\etc\HOSTS has now two lines:
127.0.0.1 localhost
127.0.0.1 local.mysite.com
.\xampp\apache\conf\extra\httpd-vhosts.conf has been backed up and I now have the following appended at the end of the file:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot "F:/xampp/htdocs"
</VirtualHost>

<VirtualHost *:80>
ServerName mysite.com
ServerAlias local.mysite.com
DocumentRoot "F:/Documents/mysite.local"
<Directory "F:/Documents/mysite.local" >
Options Indexes +FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ "F:/Documents/mysite.local"
ServerAdmin serveradmin@mysite.com
CustomLog logs/mysite.log combined
ErrorLog logs/mysite.log
LogLevel error
</VirtualHost>

It doesn't work completely:
When I type: http://local.mysite.com/
I end up automatically redirected to: http://local.mysite.com/xampp/
Wixh is the welcome XAMPP page. Somehow, it doesn't fing my mysite.local folder. Did I miss something?
G64
 
Posts: 5
Joined: 06. November 2008 08:10

Postby G64 » 06. November 2008 15:57

I just worked out I needed to restart the Apache server to take into account the new vhost. So that's fixed.

I'm able to display a simple hello world page without problem, but with my test site, I'm getting 500 errors. I'm going to investigate further and I will document the outcome.
G64
 
Posts: 5
Joined: 06. November 2008 08:10

Postby G64 » 06. November 2008 16:16

Problem solved!

rewriteEngine didn't work in my .htaccess

The reason was that I needed to load the mod_rewrite module in httpd.conf then restart Apache.

It works perfectly now!

Thanks Sharley for your help and encouragement!
G64
 
Posts: 5
Joined: 06. November 2008 08:10


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 32 guests