Run Apache, Php and MySQL off a USB Stick

From Redbrick Wiki
Jump to navigation Jump to search

If you are starting to get into web development you may find it starts to get annoying to build a site on RedBrick while using Dreamweaver and Photoshop etc.

The answer to this problem is to run Apache, PHP and MySQL off a USB stick! Maintaining your site on a USB stick allows you to easily plug it into a lab machine and work away and then bring it home and continue right from where you left off.

You will need to own a USB stick of at least 256MB (or 64MB if you can do without MySQL).

  • Format your USB Stick.
  • Create a directory called 'pdrive' in the usb root directory - this is where everything will be run from.
  • Create a file called 'start.bat' in the usb root directory also, and have it contain the following :
  /pdrive/php-X.X.X/php.exe -c /pdrive/php.ini -f /pdrive/start.php

Where php-X.X.X refers to the version of PHP you will install (i.e. php-5.2.2).

  • Create a directory sess in pdrive/ for php to save the session data to.
  • Install Apache to pdrive/apache-X.X.X
  • Download this httpd.conf to pdrive/apache-X.X.X/conf/
  • Create a directory www in prdive/ - this will be where you develope your site.
  • Install MySQL to pdrive/mysql
  • Unzip PHP to pdrive/php-X.X.X
  • Download this PHP.ini to pdrive/
  • Finally download start.php to pdrive/ This will be run when you double click start.bat to start up the MySQL and Apache Services as well as open to your USB website, http://localhost:85.
  • You will need to update the pages to download to reflect your versions of Apache and PHP.

Configuration Files


; Language Options ;
engine = On
short_open_tag = On
asp_tags = Off
precision    =  12
y2k_compliance = On
output_buffering = Off
;output_handler =
zlib.output_compression = Off
;zlib.output_handler =
implicit_flush = Off
serialize_precision = 100
allow_call_time_pass_reference = On

; Safe Mode
safe_mode = Off
safe_mode_gid = Off
safe_mode_include_dir =
safe_mode_exec_dir =
safe_mode_allowed_env_vars = PHP_
safe_mode_protected_env_vars = LD_LIBRARY_PATH

;open_basedir =
disable_functions =
disable_classes =
expose_php = On

; Resource Limits ;

max_execution_time = 30     ; Maximum execution time of each script, in seconds
max_input_time = 60	; Maximum amount of time each script may spend parsing request data
memory_limit = 8M      ; Maximum amount of memory a script may consume (8MB)

; Error handling and logging ;
error_reporting  =  E_ALL & ~E_NOTICE
display_errors = On
display_startup_errors = Off
log_errors = Off
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off
;html_errors = Off

;docref_root = "/phpmanual/"
;docref_ext = .html
;error_prepend_string = "<font color=ff0000>"
;error_append_string = "</font>"

;error_log = filename
;error_log = syslog

; Data Handling ;
;arg_separator.output = "&"
;arg_separator.input = ";&"
variables_order = "EGPCS"
register_globals = Off
register_argc_argv = On
post_max_size = 8M
gpc_order = "GPC"
magic_quotes_gpc = On
magic_quotes_runtime = Off    
magic_quotes_sybase = Off
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
;default_charset = "iso-8859-1"
;always_populate_raw_post_data = On

; Paths and Directories ;
doc_root =
user_dir =
enable_dl = On
; cgi.force_redirect = 1
; cgi.nph = 1
; cgi.redirect_status_env = ;
; cgi.fix_pathinfo=0
; fastcgi.impersonate = 1;
;cgi.rfc2616_headers = 0 

; File Uploads ;

file_uploads = On
;upload_tmp_dir =
upload_max_filesize = 2M

; Fopen wrappers ;
allow_url_fopen = On
; user_agent="PHP"
default_socket_timeout = 60
; auto_detect_line_endings = Off

; Dynamic Extensions ;

; Module Settings ;

define_syslog_variables  = Off

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
;sendmail_from =
; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =

;java.class.path = .\php_java.jar
;java.home = c:\jdk
;java.library = c:\jdk\jre\bin\hotspot\jvm.dll 
;java.library.path = .\

sql.safe_mode = Off

;odbc.default_db    =  Not yet implemented
;odbc.default_user  =  Not yet implemented
;odbc.default_pw    =  Not yet implemented
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1  
odbc.defaultlrl = 4096  
odbc.defaultbinmode = 1  

mysql.allow_persistent = On
mysql.max_persistent = -1
mysql.max_links = -1

; Default port number for mysql_connect().  If unset, mysql_connect() will use
; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
; compile-time value defined MYSQL_PORT (in that order).  Win32 will only look
mysql.default_port = 3307
mysql.default_socket =
mysql.default_host = localhost
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off

dbx.colnames_case = "unchanged"

bcmath.scale = 0

;browscap = extra/browscap.ini

; Handler used to store/retrieve data.
session.save_handler = files
session.save_path = "\\pdrive\\sess"
session.use_cookies = 1
; session.use_only_cookies = 1 = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor     = 100
session.gc_maxlifetime = 1440
session.bug_compat_42 = 1
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 0
session.entropy_file =
;session.entropy_length = 16
;session.entropy_file = /dev/urandom
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset="

mssql.allow_persistent = On
mssql.max_persistent = -1
mssql.max_links = -1
mssql.min_error_severity = 10
mssql.min_message_severity = 10
mssql.compatability_mode = Off
;mssql.connect_timeout = 5
;mssql.timeout = 60
;mssql.textlimit = 4096
;mssql.textsize = 4096
;mssql.batchsize = 0
;mssql.datetimeconvert = On
mssql.secure_connection = Off
;mssql.max_procs = 25

; = On
;assert.warning = On
;assert.bail = Off
;assert.callback = 0
;assert.quiet_eval = 0

sockets.use_system_read = On

;com.typelib_file = 
;com.allow_dcom = true
;com.autoregister_typelib = true
;com.autoregister_casesensitive = false
;com.autoregister_verbose = true

;printer.default_printer = ""

;mbstring.language = Japanese
;mbstring.internal_encoding = EUC-JP
;mbstring.http_input = auto
;mbstring.http_output = SJIS
;mbstring.encoding_translation = Off
;mbstring.detect_order = auto
;mbstring.substitute_character = none;
;mbstring.func_overload = 0

; crack.default_dictionary = "c:\php\lib\cracklib_dict" 


ServerRoot "\\pdrive\\apache-2.2.4"

PidFile logs/
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15

<IfModule mpm_winnt.c>
ThreadsPerChild 250
MaxRequestsPerChild  0

Listen 85

LoadModule actions_module modules/
LoadModule alias_module modules/
LoadModule asis_module modules/
LoadModule auth_basic_module modules/
#LoadModule auth_digest_module modules/
#LoadModule authn_anon_module modules/
#LoadModule authn_dbm_module modules/
LoadModule authn_default_module modules/
LoadModule authn_file_module modules/
#LoadModule authz_dbm_module modules/
LoadModule authz_default_module modules/
LoadModule authz_groupfile_module modules/
LoadModule authz_host_module modules/
LoadModule authz_user_module modules/
LoadModule autoindex_module modules/
#LoadModule cern_meta_module modules/
LoadModule cgi_module modules/
#LoadModule dav_module modules/
#LoadModule dav_fs_module modules/
#LoadModule deflate_module modules/
LoadModule dir_module modules/
LoadModule env_module modules/
#LoadModule expires_module modules/
#LoadModule file_cache_module modules/
#LoadModule headers_module modules/
LoadModule imagemap_module modules/
LoadModule include_module modules/
#LoadModule info_module modules/
LoadModule isapi_module modules/
LoadModule log_config_module modules/
LoadModule mime_module modules/
#LoadModule mime_magic_module modules/
#LoadModule proxy_module modules/
#LoadModule proxy_ajp_module modules/
#LoadModule proxy_balancer_module modules/
#LoadModule proxy_connect_module modules/
#LoadModule proxy_http_module modules/
#LoadModule proxy_ftp_module modules/
LoadModule negotiation_module modules/
#LoadModule rewrite_module modules/
LoadModule setenvif_module modules/
#LoadModule speling_module modules/
#LoadModule status_module modules/
#LoadModule unique_id_module modules/
LoadModule userdir_module modules/
#LoadModule usertrack_module modules/
#LoadModule vhost_alias_module modules/
#LoadModule ssl_module modules/

LoadModule php5_module "\\pdrive\\php-5.2.2\\php5apache2_2.dll"
addtype application/x-httpd-php .php .php4 .php5 .php3 .htm .inc .fire
PHPIniDir "\\pdrive\\php.ini" 

#ExtendedStatus On
ServerAdmin admin@localhost
ServerName localhost:85
UseCanonicalName Off
DocumentRoot "\\pdrive\\www"

<Directory />
    Options FollowSymLinks
    AllowOverride None
<Directory "\\pdrive\\www">
    Options Includes Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all

<IfModule dir_module>
    DirectoryIndex index.html index.html.var

<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all

TypesConfig conf/mime.types
DefaultType text/plain
<IfModule mod_mime_magic.c>
    MIMEMagicFile conf/magic

HostnameLookups Off
ErrorLog logs/error.log
LogLevel warn

<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

ServerTokens Full
ServerSignature On

<IfModule alias_module>
Alias /icons/ "/icons/"

<Directory "/icons">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all

ScriptAlias /cgi-bin/ "/cgi-bin/"

<Directory "/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all

DefaultType text/plain

IndexOptions FancyIndexing VersionSort

AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip

AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*

AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core

AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^

DefaultIcon /icons/unknown.gif
ReadmeName README.html
HeaderName HEADER.html
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t

AddLanguage ca .ca
AddLanguage cs .cz .cs
AddLanguage da .dk
AddLanguage de .de
AddLanguage el .el
AddLanguage en .en
AddLanguage eo .eo
AddLanguage es .es
AddLanguage et .et
AddLanguage fr .fr
AddLanguage he .he
AddLanguage hr .hr
AddLanguage it .it
AddLanguage ja .ja
AddLanguage ko .ko
AddLanguage ltz .ltz
AddLanguage nl .nl
AddLanguage nn .nn
AddLanguage no .no
AddLanguage pl .po
AddLanguage pt .pt
AddLanguage pt-BR .pt-br
AddLanguage ru .ru
AddLanguage sv .sv
AddLanguage zh-CN .zh-cn
AddLanguage zh-TW .zh-tw

LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW
ForceLanguagePriority Prefer Fallback

AddDefaultCharset ISO-8859-1

AddCharset ISO-8859-1  .iso8859-1 .latin1
AddCharset ISO-8859-2  .iso8859-2 .latin2 .cen
AddCharset ISO-8859-3  .iso8859-3 .latin3
AddCharset ISO-8859-4  .iso8859-4 .latin4
AddCharset ISO-8859-5  .iso8859-5 .latin5 .cyr .iso-ru
AddCharset ISO-8859-6  .iso8859-6 .latin6 .arb
AddCharset ISO-8859-7  .iso8859-7 .latin7 .grk
AddCharset ISO-8859-8  .iso8859-8 .latin8 .heb
AddCharset ISO-8859-9  .iso8859-9 .latin9 .trk
AddCharset ISO-2022-JP .iso2022-jp .jis
AddCharset ISO-2022-KR .iso2022-kr .kis
AddCharset ISO-2022-CN .iso2022-cn .cis
AddCharset Big5        .Big5       .big5
# For russian, more than one charset is used (depends on client, mostly):
AddCharset WINDOWS-1251 .cp-1251   .win-1251
AddCharset CP866       .cp866
AddCharset KOI8-r      .koi8-r .koi8-ru
AddCharset KOI8-ru     .koi8-uk .ua
AddCharset ISO-10646-UCS-2 .ucs2
AddCharset ISO-10646-UCS-4 .ucs4
AddCharset UTF-8       .utf8

AddCharset GB2312      .gb2312 .gb 
AddCharset utf-7       .utf7
AddCharset utf-8       .utf8
AddCharset big5        .big5 .b5
AddCharset EUC-TW      .euc-tw
AddCharset EUC-JP      .euc-jp
AddCharset EUC-KR      .euc-kr
AddCharset shift_jis   .sjis

AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddHandler cgi-script .cgi

AddHandler type-map var

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0

BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
BrowserMatch "^WebDrive" redirect-carefully
BrowserMatch "^WebDAVFS/1.[012]" redirect-carefully
BrowserMatch "^gnome-vfs" redirect-carefully

<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from

<Location /server-info>
    SetHandler server-info
    Order deny,allow
    Deny from all
    Allow from

<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin


echo "starting MySQL ....\n";
        'start pdrive\\mysql\\bin\\mysqld-nt.exe --basedir=/pdrive/mysql --datadir=/pdrive/mysql/data --port=3307 --console --standalone'
        ,'r' )
echo "starting apache....\n";
pclose(popen('start pdrive\\apache-2.2.4\\bin\\httpd.exe','r'));
echo 'opening localhost';
exec( 'start http://localhost:85');