Difference between revisions of "USB self-contained server"

From The Uniform Server Wiki
Jump to navigation Jump to search
(New page: <span id="top"></span> {| cellpadding="2" |__TOC__||'''USB self-contained server''' |} '''Introduction''' With the release of Uniform Server V4.0-Mona thought I would revisit a self-conta...)
 
Line 1: Line 1:
<span id="top"></span>
+
=[http://ocavyle.co.cc This Page Is Currently Under Construction And Will Be Available Shortly, Please Visit Reserve Copy Page]=
{| cellpadding="2"
+
&lt;span id=&quot;top&quot;&gt;&lt;/span&gt;
 +
{| cellpadding=&quot;2&quot;
 
|__TOC__||'''USB self-contained server'''
 
|__TOC__||'''USB self-contained server'''
 
|}
 
|}
Line 15: Line 16:
 
* Portable Firefox
 
* Portable Firefox
 
* A PAC file
 
* A PAC file
* A domain name I will use this address '''<nowiki>http://center.uniformserver.com</nowiki>'''
+
* A domain name I will use this address '''&lt;nowiki&gt;http://center.uniformserver.com&lt;/nowiki&gt;'''
  
 
== Installation ==
 
== Installation ==
Line 27: Line 28:
 
'''''Install Firefox Portable'''''
 
'''''Install Firefox Portable'''''
  
# Download the latest version of Firefox Portable from: [http://portableapps.com/apps/internet/firefox_portable Portable Apps] save to any folder<br>(File '''Firefox_Portable_3.0.6_en-us.paf.exe)'''
+
# Download the latest version of Firefox Portable from: [http://portableapps.com/apps/internet/firefox_portable Portable Apps] save to any folder&lt;br&gt;(File '''Firefox_Portable_3.0.6_en-us.paf.exe)'''
 
# On your memory stick at the top level create a new folder named '''fx3''' (choose any name you like)
 
# On your memory stick at the top level create a new folder named '''fx3''' (choose any name you like)
 
# Double-click on the file downloaded '''Firefox_Portable_3.0.6_en-us.paf.exe'''. When prompted select the folder '''fx3''' on your memory stick and click OK. A '''FirefoxPortable''' folder will be created and all the necessary files installed.
 
# Double-click on the file downloaded '''Firefox_Portable_3.0.6_en-us.paf.exe'''. When prompted select the folder '''fx3''' on your memory stick and click OK. A '''FirefoxPortable''' folder will be created and all the necessary files installed.
Line 40: Line 41:
  
 
Navigate to the end of this file and just under the default host (localhost:80) add the new host section:
 
Navigate to the end of this file and just under the default host (localhost:80) add the new host section:
<pre>
+
&lt;pre&gt;
 
NameVirtualHost *
 
NameVirtualHost *
<VirtualHost *>
+
&lt;VirtualHost *&gt;
 
ServerName localhost:80
 
ServerName localhost:80
 
DocumentRoot /www
 
DocumentRoot /www
</VirtualHost>
+
&lt;/VirtualHost&gt;
  
 
##########VIRTUAL HOST SETUP##########
 
##########VIRTUAL HOST SETUP##########
 
# CENTER.UNIFORMSERVER.COM
 
# CENTER.UNIFORMSERVER.COM
<VirtualHost *>
+
&lt;VirtualHost *&gt;
 
ServerName center.uniformserver.com
 
ServerName center.uniformserver.com
 
DocumentRoot /www/center
 
DocumentRoot /www/center
</VirtualHost>
+
&lt;/VirtualHost&gt;
</pre>
+
&lt;/pre&gt;
  
 
I am using ServerName '''center.uniformserver.com''' and DocumentRoot '''/www/center''' use your real domain and create the appropriate folder in '''L:\www''' (again your drive letter may be different)  
 
I am using ServerName '''center.uniformserver.com''' and DocumentRoot '''/www/center''' use your real domain and create the appropriate folder in '''L:\www''' (again your drive letter may be different)  
Line 60: Line 61:
 
== Create PAC file ==
 
== Create PAC file ==
 
Create the following file and save as '''test.pac''' to root folder '''L:\www'''  
 
Create the following file and save as '''test.pac''' to root folder '''L:\www'''  
{| cellpadding="4" cellspacing="1" style="background:#000000;"
+
{| cellpadding=&quot;4&quot; cellspacing=&quot;1&quot; style=&quot;background:#000000;&quot;
|- style="background:#e8e8e8;"
+
|- style=&quot;background:#e8e8e8;&quot;
 
!test.pac File
 
!test.pac File
|- style="background:#f5f5f5;"
+
|- style=&quot;background:#f5f5f5;&quot;
 
|
 
|
<pre style="border:none">
+
&lt;pre style=&quot;border:none&quot;&gt;
 
function FindProxyForURL(url, host)
 
function FindProxyForURL(url, host)
 
{
 
{
   if (shExpMatch(url,"http://center.uniformserver.com/*")) return "PROXY 127.0.0.1";
+
   if (shExpMatch(url,&quot;http://center.uniformserver.com/*&quot;)) return &quot;PROXY 127.0.0.1&quot;;
   return "";
+
   return &quot;&quot;;
 
}  
 
}  
</pre>
+
&lt;/pre&gt;
 
|}
 
|}
  
Line 77: Line 78:
 
=== Install PAC file ===
 
=== Install PAC file ===
 
# Run Firefox by double clicking on file '''FirefoxPortable.exe''' located L:\fx3\FirefoxPortable\FirefoxPortable.exe
 
# Run Firefox by double clicking on file '''FirefoxPortable.exe''' located L:\fx3\FirefoxPortable\FirefoxPortable.exe
# Select Tools > '''Options'''
+
# Select Tools &gt; '''Options'''
 
# Select '''Advanced''' Icon
 
# Select '''Advanced''' Icon
 
# Select '''Network''' Tab
 
# Select '''Network''' Tab
 
# Click '''Settings button'''
 
# Click '''Settings button'''
 
# Check '''Automatic proxy configuration URL''' radio button
 
# Check '''Automatic proxy configuration URL''' radio button
# Type-in '''<nowiki>http://localhost/test.pac</nowiki>'''
+
# Type-in '''&lt;nowiki&gt;http://localhost/test.pac&lt;/nowiki&gt;'''
 
# Click '''OK twice''' to close both dialogs.
 
# Click '''OK twice''' to close both dialogs.
 
# Close Firefox.
 
# Close Firefox.
Line 91: Line 92:
 
# Start Uniform Server (Double click on unicontroller.exe) and start servers.
 
# Start Uniform Server (Double click on unicontroller.exe) and start servers.
 
# Run Firefox by double clicking on file '''FirefoxPortable.exe''' located L:\fx3\FirefoxPortable\FirefoxPortable.exe
 
# Run Firefox by double clicking on file '''FirefoxPortable.exe''' located L:\fx3\FirefoxPortable\FirefoxPortable.exe
# Type the following into browser address bar: '''<nowiki>http://localhost/test.pac</nowiki>'''
+
# Type the following into browser address bar: '''&lt;nowiki&gt;http://localhost/test.pac&lt;/nowiki&gt;'''
 
# Contents of folder '''www/center''' displayed.
 
# Contents of folder '''www/center''' displayed.
  
Line 102: Line 103:
 
Create a new batch file ff_pac.bat and save to USB root
 
Create a new batch file ff_pac.bat and save to USB root
  
{| cellpadding="2" cellspacing="1" style="background:#000000;"
+
{| cellpadding=&quot;2&quot; cellspacing=&quot;1&quot; style=&quot;background:#000000;&quot;
|- style="background:#e8e8e8;"
+
|- style=&quot;background:#e8e8e8;&quot;
 
!ff_pac.bat
 
!ff_pac.bat
|- style="background:#f5f5f5;"
+
|- style=&quot;background:#f5f5f5;&quot;
 
|
 
|
<pre style="border:none;padding:2px">
+
&lt;pre style=&quot;border:none;padding:2px&quot;&gt;
 
TITLE UNIFORM SERVER - PAC
 
TITLE UNIFORM SERVER - PAC
 
COLOR B0
 
COLOR B0
Line 139: Line 140:
 
:next1
 
:next1
 
set /a cnt+=1
 
set /a cnt+=1
if "%cnt%"=="60" goto :TIMEDOUT
+
if &quot;%cnt%&quot;==&quot;60&quot; goto :TIMEDOUT
 
home\admin\program\unidelay.exe
 
home\admin\program\unidelay.exe
home\admin\program\pskill.exe FirefoxPortable.exe > nul
+
home\admin\program\pskill.exe FirefoxPortable.exe &gt; nul
 
IF ERRORLEVEL 1 goto :next1
 
IF ERRORLEVEL 1 goto :next1
  
Line 156: Line 157:
 
rem restore original working directory
 
rem restore original working directory
 
popd
 
popd
</pre>
+
&lt;/pre&gt;
 
|}
 
|}
  
Line 164: Line 165:
 
Now create a file named '''autorun.inf''' and save to USB root. The one I used for testing is shown below:
 
Now create a file named '''autorun.inf''' and save to USB root. The one I used for testing is shown below:
  
{| cellpadding="2" cellspacing="1" style="background:#000000;"
+
{| cellpadding=&quot;2&quot; cellspacing=&quot;1&quot; style=&quot;background:#000000;&quot;
|- style="background:#e8e8e8;"
+
|- style=&quot;background:#e8e8e8;&quot;
 
!autorun.inf
 
!autorun.inf
|- style="background:#f5f5f5;"
+
|- style=&quot;background:#f5f5f5;&quot;
 
|
 
|
<pre style="border:none;padding:2px">
+
&lt;pre style=&quot;border:none;padding:2px&quot;&gt;
 
[autorun]
 
[autorun]
 
open=ff_pac.bat
 
open=ff_pac.bat
 
action=Run FF UniController
 
action=Run FF UniController
 
icon=docs\SRC\uslogo.ico
 
icon=docs\SRC\uslogo.ico
</pre>
+
&lt;/pre&gt;
 
|}
 
|}
  

Revision as of 01:12, 24 November 2010

This Page Is Currently Under Construction And Will Be Available Shortly, Please Visit Reserve Copy Page

<span id="top"></span>

USB self-contained server

Introduction

With the release of Uniform Server V4.0-Mona thought I would revisit a self-contained server on a USB memory stick. This includes portable Firefox and a PAC file simulating a portable DNS server.

This really is intended as a teaching and development server. A PAC file avoids using the hosts file. On Vista this can be a pain before it can be edited requires administrator privileges.

Components required

The following components are required:

Installation

Install Uniform Server

  1. Extract Uniform Server V4.0-Mona to any folder.
  2. Copy the entire content of folder udrive to USB root (top-level).
  3. From folder UniServer copy UniController.exe to USB root.

Install Firefox Portable

  1. Download the latest version of Firefox Portable from: Portable Apps save to any folder<br>(File Firefox_Portable_3.0.6_en-us.paf.exe)
  2. On your memory stick at the top level create a new folder named fx3 (choose any name you like)
  3. Double-click on the file downloaded Firefox_Portable_3.0.6_en-us.paf.exe. When prompted select the folder fx3 on your memory stick and click OK. A FirefoxPortable folder will be created and all the necessary files installed.

Note: To run double click on FirefoxPortable.exe (located in folder *\fx3\FirefoxPortable)

Top

Create Virtual Host

The easiest way to create a virtual host is to use Apanel however this writes to the hosts file. To avoid this edit Apache's config file and add the virtual host(s) manually.

Edit file: L:\usr\local\apache2\conf\httpd.conf (Note your drive letter may be different)

Navigate to the end of this file and just under the default host (localhost:80) add the new host section: <pre> NameVirtualHost * <VirtualHost *> ServerName localhost:80 DocumentRoot /www </VirtualHost>

                    1. VIRTUAL HOST SETUP##########
  1. CENTER.UNIFORMSERVER.COM

<VirtualHost *> ServerName center.uniformserver.com DocumentRoot /www/center </VirtualHost> </pre>

I am using ServerName center.uniformserver.com and DocumentRoot /www/center use your real domain and create the appropriate folder in L:\www (again your drive letter may be different)

Top

Create PAC file

Create the following file and save as test.pac to root folder L:\www

test.pac File

<pre style="border:none"> function FindProxyForURL(url, host) {

 if (shExpMatch(url,"http://center.uniformserver.com/*%22)) return "PROXY 127.0.0.1";
 return "";

} </pre>

Top

Install PAC file

  1. Run Firefox by double clicking on file FirefoxPortable.exe located L:\fx3\FirefoxPortable\FirefoxPortable.exe
  2. Select Tools > Options
  3. Select Advanced Icon
  4. Select Network Tab
  5. Click Settings button
  6. Check Automatic proxy configuration URL radio button
  7. Type-in <nowiki>http://localhost/test.pac</nowiki>
  8. Click OK twice to close both dialogs.
  9. Close Firefox.

Top

Test

  1. Start Uniform Server (Double click on unicontroller.exe) and start servers.
  2. Run Firefox by double clicking on file FirefoxPortable.exe located L:\fx3\FirefoxPortable\FirefoxPortable.exe
  3. Type the following into browser address bar: <nowiki>http://localhost/test.pac</nowiki>
  4. Contents of folder www/center displayed.

Automate

When the USB stick is plugged in we need to start Firefox and UniController.

It is possible that a version of Firefox is already running, this will prevent our portable version running hence first kill any running Firefox. Then start UniController, since there are several commands these are placed in a batch file which is run by autorun.

New batch files

Create a new batch file ff_pac.bat and save to USB root

ff_pac.bat

<pre style="border:none;padding:2px"> TITLE UNIFORM SERVER - PAC COLOR B0 mode con:cols=60 lines=20 @echo off cls rem ################################################### rem # Name: ff_pac.bat rem # Location: root of USB stic rem # Edited Last By: MPG (ric) rem # V 1.0 7-2-2009 rem ################################################## echo.

rem working directory current folder pushd %~dp0

rem ### kill running FF home\admin\program\pskill.exe firefox.exe c home\admin\program\pskill.exe FirefoxPortable.exe c

rem ### start USB Firefox start fx3\FirefoxPortable\FirefoxPortable.exe

rem ### Before starting UniController wait for FF to start rem ### Safety loop counter cnt give up after 60 seconds echo Starting FF ...............

echo. set /a cnt=0

next1

set /a cnt+=1 if "%cnt%"=="60" goto :TIMEDOUT home\admin\program\unidelay.exe home\admin\program\pskill.exe FirefoxPortable.exe > nul IF ERRORLEVEL 1 goto :next1

rem ### start UniController home\admin\program\unidelay.exe 4 start unicontroller.exe goto :END

TIMEDOUT

echo Unable to start FF pause

END

rem restore original working directory popd </pre>

Auto Run

First check you can start Firefox and UniController using the batch file.

Now create a file named autorun.inf and save to USB root. The one I used for testing is shown below:

autorun.inf

<pre style="border:none;padding:2px"> [autorun] open=ff_pac.bat action=Run FF UniController icon=docs\SRC\uslogo.ico </pre>

When your memory stick is plugged in you will receive the following message just click OK:

Launch FF UniformServer using the program provided on the device

Top

Summary

The above was not intended to be a definitive guide it provides a working example that you can expand for your own applications.

Instead of using UniController you can use batch files. This is covered on the following pages Virtual Hosting, although written for 3.5 the material is transferable to 4.0-Mona.

Top