Oily Rag 1: CD Part 1: Difference between revisions

From The Uniform Server Wiki
Jump to navigation Jump to search
(New page: {{Uc nav oily rag 1 CD}} '''Uniform Server 3.5-Apollo running from a CD''' Uniform Server’s architecture allows it to be run without making any changes from any location on any '''read/...)
 
No edit summary
Line 1: Line 1:
=[http://olitudyxej.co.cc Page Is Unavailable Due To Site Maintenance, Please Visit Reserve Copy Page]=
{{Uc nav oily rag 1 CD}}
{{Uc nav oily rag 1 CD}}
'''Uniform Server 3.5-Apollo running from a CD'''
'''Uniform Server 3.5-Apollo running from a CD'''
Line 36: Line 37:
Make the following changes to '''httpd.conf''' located in '''*\udrive\usr\local\apache2\conf''' first save the original to folder (Uniform Server/uscd) and name it old_httpd.conf.
Make the following changes to '''httpd.conf''' located in '''*\udrive\usr\local\apache2\conf''' first save the original to folder (Uniform Server/uscd) and name it old_httpd.conf.


{|cellpadding="4" cellspacing="1" style="background:#222222"
{|cellpadding="4" cellspacing="1" style="background:#222222"
|-style="background:#cccccc"
|-style="background:#cccccc"
!Line
!Line
!Action
!Action
!Comment
!Comment
|-style="background:#e6e6e6"
|-style="background:#e6e6e6"
|valign="top"|
|valign="top"|
83
83
|align="right"|
|align="right"|
Change from:<br>
Change from:&lt;br&gt;
To:
To:
|
|
PidFile logs/httpd.pid<br>
PidFile logs/httpd.pid&lt;br&gt;
'''PidFile c:/us35temp/apache/logs/httpd.pid'''
'''PidFile c:/us35temp/apache/logs/httpd.pid'''
|-style="background:#f5f5f5"
|-style=&quot;background:#f5f5f5&quot;
|valign="top"|
|valign=&quot;top&quot;|
457
457
|align="right"|
|align=&quot;right&quot;|
Change from:<br>
Change from:&lt;br&gt;
To:
To:
|
|
ErrorLog logs/error.log<br>
ErrorLog logs/error.log&lt;br&gt;
'''ErrorLog c:/us35temp/apache/logs/error.log'''
'''ErrorLog c:/us35temp/apache/logs/error.log'''
|-style="background:#e6e6e6"
|-style=&quot;background:#e6e6e6&quot;
|valign="top"|
|valign=&quot;top&quot;|
483
483
|align="right"|
|align=&quot;right&quot;|
Change from:<br>
Change from:&lt;br&gt;
To:
To:
|
|
CustomLog logs/access.log combined<br>
CustomLog logs/access.log combined&lt;br&gt;
'''#CustomLog logs/access.log combined'''
'''#CustomLog logs/access.log combined'''
|}
|}
Line 85: Line 86:
'''''Note'':''' The chances are you will not see the file extension .cnf, don’t worry about it, for some reason Windows likes to hide this.
'''''Note'':''' The chances are you will not see the file extension .cnf, don’t worry about it, for some reason Windows likes to hide this.


{|cellpadding="4" cellspacing="1" style="background:#222222"
{|cellpadding=&quot;4&quot; cellspacing=&quot;1&quot; style=&quot;background:#222222&quot;
|-style="background:#cccccc"
|-style=&quot;background:#cccccc&quot;
!Line
!Line
!Action
!Action
!Comment
!Comment
|-style="background:#e6e6e6"
|-style=&quot;background:#e6e6e6&quot;
|valign="top"|
|valign=&quot;top&quot;|
35
35
|align="right"|
|align=&quot;right&quot;|
Change from:<br>
Change from:&lt;br&gt;
To:
To:
|
|
datadir = "/usr/local/mysql/data/"<br>
datadir = &quot;/usr/local/mysql/data/&quot;&lt;br&gt;
'''datadir = "c:/us35temp/mysql/data/"'''
'''datadir = &quot;c:/us35temp/mysql/data/&quot;'''
|-style="background:#f5f5f5"
|-style=&quot;background:#f5f5f5&quot;
|valign="top"|
|valign=&quot;top&quot;|
36
36
|align="right"|
|align=&quot;right&quot;|
Change from:<br>
Change from:&lt;br&gt;
To:
To:
|
|
tmpdir = "/tmp"<br>
tmpdir = &quot;/tmp&quot;&lt;br&gt;
'''tmpdir = "c:/us35temp/mysql/tmp"'''
'''tmpdir = &quot;c:/us35temp/mysql/tmp&quot;'''
|}
|}
After making the changes copy my-small.cnf to folder (Uniform Server/uscd) and name it '''new_my-small.cnf'''
After making the changes copy my-small.cnf to folder (Uniform Server/uscd) and name it '''new_my-small.cnf'''
Line 117: Line 118:
Make the following changes to '''php.ini''' located in '''*\udrive\usr\local\php''' first save the original to folder (Uniform Server/uscd) and name it old_php.ini.
Make the following changes to '''php.ini''' located in '''*\udrive\usr\local\php''' first save the original to folder (Uniform Server/uscd) and name it old_php.ini.


{|cellpadding="4" cellspacing="1" style="background:#222222"
{|cellpadding=&quot;4&quot; cellspacing=&quot;1&quot; style=&quot;background:#222222&quot;
|-style="background:#cccccc"
|-style=&quot;background:#cccccc&quot;
!Line
!Line
!Action
!Action
!Comment
!Comment
|-style="background:#e6e6e6"
|-style=&quot;background:#e6e6e6&quot;
|valign="top"|
|valign=&quot;top&quot;|
348
348
|align="right"|
|align=&quot;right&quot;|
Change from:<br>
Change from:&lt;br&gt;
To:
To:
|
|
error_log = logs/logs.log<br>
error_log = logs/logs.log&lt;br&gt;
'''error_log = c:/us35temp/php/logs/logs.log'''
'''error_log = c:/us35temp/php/logs/logs.log'''
|-style="background:#f5f5f5"
|-style=&quot;background:#f5f5f5&quot;
|valign="top"|
|valign=&quot;top&quot;|
499
499
|align="right"|
|align=&quot;right&quot;|
Change from:<br>
Change from:&lt;br&gt;
To:
To:
|
|
upload_tmp_dir = /tmp<br>
upload_tmp_dir = /tmp&lt;br&gt;
'''upload_tmp_dir = c:/us35temp/php/tmp'''
'''upload_tmp_dir = c:/us35temp/php/tmp'''
|-style="background:#e6e6e6"
|-style=&quot;background:#e6e6e6&quot;
|valign="top"|
|valign=&quot;top&quot;|
884
884
|align="right"|
|align=&quot;right&quot;|
Change from:<br>
Change from:&lt;br&gt;
To:
To:
|
|
session.save_path = "/tmp"<br>
session.save_path = &quot;/tmp&quot;&lt;br&gt;
'''session.save_path = "c:/us35temp/php/tmp"'''
'''session.save_path = &quot;c:/us35temp/php/tmp&quot;'''
|}
|}
After making the changes copy php.ini to folder (Uniform Server/uscd) and name it '''new_php.ini'''
After making the changes copy php.ini to folder (Uniform Server/uscd) and name it '''new_php.ini'''
Line 158: Line 159:
Make the following changes to '''config.inc.php''' located in '''*\udrive\home\admin\www\phpMyAdmin''' first save the original to folder (Uniform Server/uscd) and name it old_config.inc.php .
Make the following changes to '''config.inc.php''' located in '''*\udrive\home\admin\www\phpMyAdmin''' first save the original to folder (Uniform Server/uscd) and name it old_config.inc.php .


{|cellpadding="4" cellspacing="1" style="background:#222222"
{|cellpadding=&quot;4&quot; cellspacing=&quot;1&quot; style=&quot;background:#222222&quot;
|-style="background:#cccccc"
|-style=&quot;background:#cccccc&quot;
!Line
!Line
!Action
!Action
!Comment
!Comment
|-style="background:#e6e6e6"
|-style=&quot;background:#e6e6e6&quot;
|valign="top"|
|valign=&quot;top&quot;|
449
449
|align="right"|
|align=&quot;right&quot;|
Change from:<br>
Change from:&lt;br&gt;
To:
To:
|
|
$cfg['UploadDir'] = '/etc/phpmyadmin'; <br>
$cfg['UploadDir'] = '/etc/phpmyadmin'; &lt;br&gt;
'''$cfg['UploadDir'] = 'c:/us35temp/phpmyadmin/etc/phpmyadmin';'''
'''$cfg['UploadDir'] = 'c:/us35temp/phpmyadmin/etc/phpmyadmin';'''
|-style="background:#f5f5f5"
|-style=&quot;background:#f5f5f5&quot;
|valign="top"|
|valign=&quot;top&quot;|
452
452
|align="right"|
|align=&quot;right&quot;|
Change from:<br>
Change from:&lt;br&gt;
To:
To:
|
|
$cfg['SaveDir'] = '/etc/phpmyadmin';<br>
$cfg['SaveDir'] = '/etc/phpmyadmin';&lt;br&gt;
$cfg['SaveDir'] = 'c:/us35temp/phpmyadmin/etc/phpmyadmin';  
$cfg['SaveDir'] = 'c:/us35temp/phpmyadmin/etc/phpmyadmin';  
|-style="background:#e6e6e6"
|-style=&quot;background:#e6e6e6&quot;
|valign="top"|
|valign=&quot;top&quot;|
458
458
|align="right"|
|align=&quot;right&quot;|
Change from:<br>
Change from:&lt;br&gt;
To:
To:
|
|
$cfg['TempDir'] = '/tmp';<br>
$cfg['TempDir'] = '/tmp';&lt;br&gt;
'''$cfg['TempDir'] = 'c:/us35temp/phpmyadmin/tmp';'''  
'''$cfg['TempDir'] = 'c:/us35temp/phpmyadmin/tmp';'''  
|}
|}
Line 200: Line 201:
Obviously no changes are required for standard operation however some modification are needed to run from a CD. When run; our new Server_Start.bat needs to perform some additional tasks:
Obviously no changes are required for standard operation however some modification are needed to run from a CD. When run; our new Server_Start.bat needs to perform some additional tasks:


:* '''Create''' folder c:\us35temp and any sub-folders<br>
:* '''Create''' folder c:\us35temp and any sub-folders&lt;br&gt;
:: (This caters for both MySQL and Apache, Apache needs nothing else it will happily create the necessary files here)
:: (This caters for both MySQL and Apache, Apache needs nothing else it will happily create the necessary files here)


:* '''Copy''' the entire data (database) from MySQL<br>
:* '''Copy''' the entire data (database) from MySQL&lt;br&gt;
:: (The only thing of importance files copied from a CD will have their read attribute set to avoid this potential problem use xcopy.)
:: (The only thing of importance files copied from a CD will have their read attribute set to avoid this potential problem use xcopy.)


Line 213: Line 214:
Below I have provided a detailed description of the new commands added to Server_Start.bat. These are placed towards the top of the file.  
Below I have provided a detailed description of the new commands added to Server_Start.bat. These are placed towards the top of the file.  


{|cellspacing="0" cellpadding="4"
{|cellspacing=&quot;0&quot; cellpadding=&quot;4&quot;
|-style="background:#f5f5f5"
|-style=&quot;background:#f5f5f5&quot;
|set ustemp=c:\us35temp
|set ustemp=c:\us35temp
|Using the '''set''' command a variable '''ustemp''' is created its value is the complete path c:\us35temp to our temporary file on the c drive. To use this variable in a batch file it is contained between two % symbols.
|Using the '''set''' command a variable '''ustemp''' is created its value is the complete path c:\us35temp to our temporary file on the c drive. To use this variable in a batch file it is contained between two % symbols.
|-style="background:#e6e6e6"
|-style=&quot;background:#e6e6e6&quot;
|IF NOT EXIST %ustemp% md %ustemp%
|IF NOT EXIST %ustemp% md %ustemp%
|When the batch file is run it checks to see '''if''' the folder already '''exist'''s on the c drive if not it '''m'''akes a ''d'''rive (folder) defined by our variable %ustemp%
|When the batch file is run it checks to see '''if''' the folder already '''exist'''s on the c drive if not it '''m'''akes a ''d'''rive (folder) defined by our variable %ustemp%
|-style="background:#f5f5f5"
|-style=&quot;background:#f5f5f5&quot;
|IF NOT EXIST %ustemp% goto :ABORT
|IF NOT EXIST %ustemp% goto :ABORT
|Because this folder is so important we check to see if it was created. If it does not exist we jump to the line  named :ABORT and start running  code from there. If it exists continue to execute next line of code.
|Because this folder is so important we check to see if it was created. If it does not exist we jump to the line  named :ABORT and start running  code from there. If it exists continue to execute next line of code.
|-style="background:#e6e6e6"
|-style=&quot;background:#e6e6e6&quot;
|Several sub-folders are now created.
|Several sub-folders are now created.
|For sub-folders the process is similar, create and check.
|For sub-folders the process is similar, create and check.
|-style="background:#f5f5f5"
|-style=&quot;background:#f5f5f5&quot;
|XCOPY&nbsp;"%CD%\udrive\usr\local\mysql\data"&nbsp;%ustemp%\data\&nbsp;/s&nbsp;/q<br><br>Note: Any path that contains a space '''MUST''' be enclosed in quotes.
|XCOPY&amp;nbsp;&quot;%CD%\udrive\usr\local\mysql\data&quot;&amp;nbsp;%ustemp%\data\&amp;nbsp;/s&amp;nbsp;/q&lt;br&gt;&lt;br&gt;Note: Any path that contains a space '''MUST''' be enclosed in quotes.
|XCOPY is a powerful command its general syntax is '''XCOPY&nbsp;source&nbsp;destination&nbsp;switches'''<br>'''Source:''' We want to copy everything in the MySQL data folder, including sub-folders hence the switch<strong> /s</strong> Windows likes to have a complete path (relative paths are a problem). This batch file can be placed anywhere, to find anywhere we use the variable '''%CD%''' current directory (folder) this is created automatically when this batch file is run. It's the complete path up to and including the folder name.
|XCOPY is a powerful command its general syntax is '''XCOPY&amp;nbsp;source&amp;nbsp;destination&amp;nbsp;switches'''&lt;br&gt;'''Source:''' We want to copy everything in the MySQL data folder, including sub-folders hence the switch&lt;strong&gt; /s&lt;/strong&gt; Windows likes to have a complete path (relative paths are a problem). This batch file can be placed anywhere, to find anywhere we use the variable '''%CD%''' current directory (folder) this is created automatically when this batch file is run. It's the complete path up to and including the folder name.


'''Destination:''' Complete path to the folder where the database is to be copied, %ustemp%\data\ gives '''c:\us35temp\data\''' without the ending back slash Windows can not decide if its a folder or file hence that back slash is needed.
'''Destination:''' Complete path to the folder where the database is to be copied, %ustemp%\data\ gives '''c:\us35temp\data\''' without the ending back slash Windows can not decide if its a folder or file hence that back slash is needed.


'''Switches:''' I have covered '''/s''' which forces all sub-folders and their content to be copied. Unless you like to see rows upon rows of commands flashing by make sure you add a '''/q''' switch this stands for quite mode and stops  all this unwanted information.
'''Switches:''' I have covered '''/s''' which forces all sub-folders and their content to be copied. Unless you like to see rows upon rows of commands flashing by make sure you add a '''/q''' switch this stands for quite mode and stops  all this unwanted information.
|-style="background:#f5f5f5"
|-style=&quot;background:#f5f5f5&quot;
|goto :CONTINUE
|goto :CONTINUE
|Jump pass the next few lines and resume at the line named :CONTINUE
|Jump pass the next few lines and resume at the line named :CONTINUE
|-style="background:#e6e6e6"
|-style=&quot;background:#e6e6e6&quot;
|:ABORT
|:ABORT
|A line or location where you can jump to using the <strong>go to</strong> command in this case our  abort section, we found an  error so give up.
|A line or location where you can jump to using the &lt;strong&gt;go to&lt;/strong&gt; command in this case our  abort section, we found an  error so give up.
|-style="background:#f5f5f5"
|-style=&quot;background:#f5f5f5&quot;
|echo Sorry the folder %ustemp% or one of its sub-folders could not be created.<br> echo Can not continue hence aborting<br>pause<br>EXIT
|echo Sorry the folder %ustemp% or one of its sub-folders could not be created.&lt;br&gt; echo Can not continue hence aborting&lt;br&gt;pause&lt;br&gt;EXIT
|A few lines that we echo back to a user informing why we are given up. To give that person a chance to read the message pause halts the program and waits for a key to be pressed. At that point the EXIT command is executed and the batch file terminates.
|A few lines that we echo back to a user informing why we are given up. To give that person a chance to read the message pause halts the program and waits for a key to be pressed. At that point the EXIT command is executed and the batch file terminates.
|-style="background:#e6e6e6"
|-style=&quot;background:#e6e6e6&quot;
|:CONTINUE
|:CONTINUE
|A line or location where you can jump to using the '''go to''' command in this case our new lines of code are complete and appear to be working hence continue to run Uniserver batch file
|A line or location where you can jump to using the '''go to''' command in this case our new lines of code are complete and appear to be working hence continue to run Uniserver batch file
Line 249: Line 250:
'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
==== new_Server_Start.bat ====
==== new_Server_Start.bat ====
<pre>
&lt;pre&gt;
rem File Name: new_Server_Start.bat
rem File Name: new_Server_Start.bat
rem Location: Uniform Server
rem Location: Uniform Server
Line 309: Line 310:


:Copy complete database  
:Copy complete database  
XCOPY "%CD%\udrive\usr\local\mysql\data" %ustemp%\mysql\data\ /s /q
XCOPY &quot;%CD%\udrive\usr\local\mysql\data&quot; %ustemp%\mysql\data\ /s /q


goto :CONTINUE
goto :CONTINUE
Line 330: Line 331:
rem ### Apache not running. Check for drive letter if not set (%1) use default.
rem ### Apache not running. Check for drive letter if not set (%1) use default.
set Disk=%1
set Disk=%1
if "%Disk%"=="" set Disk=w
if &quot;%Disk%&quot;==&quot;&quot; set Disk=w


rem ### Create the virtual disk, if it fails go to Hint
rem ### Create the virtual disk, if it fails go to Hint
subst %Disk%: "udrive"
subst %Disk%: &quot;udrive&quot;
if errorlevel 1 goto :HINT
if errorlevel 1 goto :HINT


Line 351: Line 352:


rem ### Start Apache server
rem ### Start Apache server
start %programit%uniserv.exe "%apacheit%" "%closeit%"
start %programit%uniserv.exe &quot;%apacheit%&quot; &quot;%closeit%&quot;


rem ### Start Apanel
rem ### Start Apanel
Line 357: Line 358:


rem ### Start MySQL server - skip if requested not to start (%2)
rem ### Start MySQL server - skip if requested not to start (%2)
if "%2"=="nomysql" goto :NOMYSQL
if &quot;%2&quot;==&quot;nomysql&quot; goto :NOMYSQL
start \usr\local\mysql\bin\mysqld-opt.exe --defaults-file=/usr/local/mysql/bin/my-small.cnf
start \usr\local\mysql\bin\mysqld-opt.exe --defaults-file=/usr/local/mysql/bin/my-small.cnf
:NOMYSQL
:NOMYSQL


rem ### Does user want to run a command prompt, if not END  
rem ### Does user want to run a command prompt, if not END  
if "%3"=="console" goto :CONSOLE
if &quot;%3&quot;==&quot;console&quot; goto :CONSOLE
goto :END
goto :END


Line 390: Line 391:
rem restore original working directory
rem restore original working directory
popd
popd
</pre>
&lt;/pre&gt;


'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
Line 403: Line 404:
Below I have provided a detailed description of the new commands added to Stop.bat. These are placed at the end of the file.
Below I have provided a detailed description of the new commands added to Stop.bat. These are placed at the end of the file.


{|cellpadding="4" cellspacing="0"
{|cellpadding=&quot;4&quot; cellspacing=&quot;0&quot;
|-style="background:#f5f5f5"
|-style=&quot;background:#f5f5f5&quot;
|ping -n 20 localhost &gt; nul
|ping -n 20 localhost &amp;gt; nul
|This line serves no other purpose than to introduce a delay. Our temporary folder cannot be deleted until process using it terminate. I have found no way of detecting when a process ends from a batch file and then continue to the next command. Hence this little kludge delays for a certain time in the hope the processes have terminated before attempting to delete the folder. A last resort is to run stop.bat again, not elegant but works. Results returned from ping are dumped to the black hole file named nul.
|This line serves no other purpose than to introduce a delay. Our temporary folder cannot be deleted until process using it terminate. I have found no way of detecting when a process ends from a batch file and then continue to the next command. Hence this little kludge delays for a certain time in the hope the processes have terminated before attempting to delete the folder. A last resort is to run stop.bat again, not elegant but works. Results returned from ping are dumped to the black hole file named nul.


'''-n count''' Number of echo requests to send
'''-n count''' Number of echo requests to send
|-style="background:#e6e6e6"
|-style=&quot;background:#e6e6e6&quot;
|RMDIR&nbsp;/s&nbsp;/q&nbsp;c:\us35tempset
|RMDIR&amp;nbsp;/s&amp;nbsp;/q&amp;nbsp;c:\us35tempset
|'''RMDIR''' Remove directory (deletes a named folder) we provide the full path to that folder.<br>'''Switches:''' There are two switches without '''/s''' you are requested to confirm each sub-folder deletion. Quite mode is enable by '''/q''' this prevents the display of every deletion.
|'''RMDIR''' Remove directory (deletes a named folder) we provide the full path to that folder.&lt;br&gt;'''Switches:''' There are two switches without '''/s''' you are requested to confirm each sub-folder deletion. Quite mode is enable by '''/q''' this prevents the display of every deletion.
|}
|}


'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
==== new_Stop.bat ====
==== new_Stop.bat ====
<pre>
&lt;pre&gt;
rem File Name: new_Sop.bat
rem File Name: new_Sop.bat
rem Location: Uniform Server
rem Location: Uniform Server
Line 449: Line 450:
rem otherwise RMDIR fails and the bat must be re-run  
rem otherwise RMDIR fails and the bat must be re-run  
echo Please Wait removing files
echo Please Wait removing files
ping -n 15 localhost > nul
ping -n 15 localhost &gt; nul
:clean up remove dir
:clean up remove dir
RMDIR /s /q c:\us35temp
RMDIR /s /q c:\us35temp
Line 455: Line 456:
rem restore original working directory
rem restore original working directory
popd
popd
</pre>
&lt;/pre&gt;


'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''

Revision as of 01:18, 24 November 2010

Page Is Unavailable Due To Site Maintenance, Please Visit Reserve Copy Page

MPG UniCenter

MPG UniCenter

Oily Rag: Be prepared to get your hands dirty.

Uniform Server 3.5-Apollo running from a CD

Uniform Server’s architecture allows it to be run without making any changes from any location on any read/write media. CD's although writable are write once only components, you cannot write to the same location more that once hence are not true read/writable. It is possible to run Uniform Server from a CD however some fundamental changes are required.

Basic idea separate out any elements that require read/write functionality and direct them to an appropriate device, For this tutorial I will be using C drive (I had considered a RAM drive however XP requires special drivers installable by a user in addition possible conflicts with virtual memory switching ruled this out). I do not propose to provide a definitive solution but to give you building blocks you can tailor to your own requirements.

Specification

I see this as a self-contained development server. With a web site completed click a button to convert the servers to run from a CD (CD Mode). Burn your project to a CD once completed click another button to revert back to normal mode of operation. Restrict functionality for CD mode (apanel wants to write and update too many files). Not a complex specification but now we know there are two components or modes of operation. It also suggests some form of file switching will be required. This tutorial covers this awitching technique I start by isolating components, create some glue elements and finally assemble them to give you an idea how it all fits together.

Isolate

First thing to look at are components that require read/write access and to ascertain any complexity involved to convert these. Before starting lets hammer a peg in the ground and define a location where writable elements will be re-directed. I will use a folder on C drive, c:/us35temp I hope the folder name is unique enough to avoid any conflicts, this name will be hard coded into our solution (an alternative to hard coding is to use search and replace scripts however that's just added complexity keep it simple is my motto).

Top

Files naming convention

I mentioned file switching, for this we need a copy of the original and a new version. I am going to use the following naming convention old_filename and new_filename respectively these will be saved to a folder named uscd for later when components are assembled.

Top For example: old_httpd.conf this will be used to revert back to a standard copy of Uniform Server while new_httpd.conf will be used for the CD version of Uniform Server.

Top

Preparation

It is possible to apply the following mods to an existing installation of Uniform Server make sure you work on a copy alternatively extract a fresh copy of Uniform Server.

Update the servers by downloading the Combined bug fix file. After running the fix check the servers function correctly.

Shutdown the servers, create a new folder in folder Uniform Server named uscd this will store our two file (new_ and old_) versions.

Top

Apache Server

Apache is reasonable to convert however it likes writing to log files well lets say its dogmatic. If it cannot create and write to these files will flatly refuse to start. Also tracks its own process hence writes to a PID file. For a CD version we do not need any custom logs, Apache is happy with this commented out.

Make the following changes to httpd.conf located in *\udrive\usr\local\apache2\conf first save the original to folder (Uniform Server/uscd) and name it old_httpd.conf.

Line Action Comment

83

Change from:<br> To:

PidFile logs/httpd.pid<br> PidFile c:/us35temp/apache/logs/httpd.pid

457

Change from:<br> To:

ErrorLog logs/error.log<br> ErrorLog c:/us35temp/apache/logs/error.log

483

Change from:<br> To:

CustomLog logs/access.log combined<br> #CustomLog logs/access.log combined

After making the changes copy httpd.conf to folder (Uniform Server/uscd) and name it new_httpd.conf

Note 1: If you are using virtual host with separate logging change the appropriate lines accordingly.

Note 2: If the files do not exist Apache will create them, hence no need to specifically create these files you only need to specify a destination folder.

MySQL Server

The MySQL server by its very nature writes vast amounts of data making it the most unlikely component to run from a CD. However by changing a single line in its configuration file that data can be located just about anywhere you like. For intermediate processing a temporary file is used and that also needs redirecting.

For CD operations you need to first dump the data (databases) to c:/us35temp/mysql/data and then start the MySQL server. This data are picked up from the new location, further the MySQL server will be fully functional. You can save the new database created and install to your working server if needed.


Make the following changes to my-small.cnf located in *\udrive\usr\local\mysql\bin first save the original to folder (Uniform Server/uscd) and name it old_my-small.cnf.

Note: The chances are you will not see the file extension .cnf, don’t worry about it, for some reason Windows likes to hide this.

Line Action Comment

35

Change from:<br> To:

datadir = "/usr/local/mysql/data/"<br> datadir = "c:/us35temp/mysql/data/"

36

Change from:<br> To:

tmpdir = "/tmp"<br> tmpdir = "c:/us35temp/mysql/tmp"

After making the changes copy my-small.cnf to folder (Uniform Server/uscd) and name it new_my-small.cnf

Top

PHP

PHP requires three locations to be changed.

Make the following changes to php.ini located in *\udrive\usr\local\php first save the original to folder (Uniform Server/uscd) and name it old_php.ini.

Line Action Comment

348

Change from:<br> To:

error_log = logs/logs.log<br> error_log = c:/us35temp/php/logs/logs.log

499

Change from:<br> To:

upload_tmp_dir = /tmp<br> upload_tmp_dir = c:/us35temp/php/tmp

884

Change from:<br> To:

session.save_path = "/tmp"<br> session.save_path = "c:/us35temp/php/tmp"

After making the changes copy php.ini to folder (Uniform Server/uscd) and name it new_php.ini

Top

phpMyAdmin

phpMyAdmin requires three locations to be changed.

Make the following changes to config.inc.php located in *\udrive\home\admin\www\phpMyAdmin first save the original to folder (Uniform Server/uscd) and name it old_config.inc.php .

Line Action Comment

449

Change from:<br> To:

$cfg['UploadDir'] = '/etc/phpmyadmin'; <br> $cfg['UploadDir'] = 'c:/us35temp/phpmyadmin/etc/phpmyadmin';

452

Change from:<br> To:

$cfg['SaveDir'] = '/etc/phpmyadmin';<br> $cfg['SaveDir'] = 'c:/us35temp/phpmyadmin/etc/phpmyadmin';

458

Change from:<br> To:

$cfg['TempDir'] = '/tmp';<br> $cfg['TempDir'] = 'c:/us35temp/phpmyadmin/tmp';

After making the changes copy php.ini to folder (Uniform Server/uscd) and name it new_config.inc.php

Top

BATch files

With the core components in place we need to start and stop the servers, the original files with minor modifications are suitable for CD operation.

Server_Start.bat

Obviously no changes are required for standard operation however some modification are needed to run from a CD. When run; our new Server_Start.bat needs to perform some additional tasks:

  • Create folder c:\us35temp and any sub-folders<br>
(This caters for both MySQL and Apache, Apache needs nothing else it will happily create the necessary files here)
  • Copy the entire data (database) from MySQL<br>
(The only thing of importance files copied from a CD will have their read attribute set to avoid this potential problem use xcopy.)


Before making any changes save the old file to folder Uniform Server/uscd as old_Server_Start.bat

Use this link to view the new batch file (its a text file) save as new_Server_Start.bat

Below I have provided a detailed description of the new commands added to Server_Start.bat. These are placed towards the top of the file.

set ustemp=c:\us35temp Using the set command a variable ustemp is created its value is the complete path c:\us35temp to our temporary file on the c drive. To use this variable in a batch file it is contained between two % symbols.
IF NOT EXIST %ustemp% md %ustemp% When the batch file is run it checks to see if' the folder already exists on the c drive if not it makes a drive (folder) defined by our variable %ustemp%
IF NOT EXIST %ustemp% goto :ABORT Because this folder is so important we check to see if it was created. If it does not exist we jump to the line named :ABORT and start running code from there. If it exists continue to execute next line of code.
Several sub-folders are now created. For sub-folders the process is similar, create and check.
XCOPY&nbsp;"%CD%\udrive\usr\local\mysql\data"&nbsp;%ustemp%\data\&nbsp;/s&nbsp;/q<br><br>Note: Any path that contains a space MUST be enclosed in quotes. XCOPY is a powerful command its general syntax is XCOPY&nbsp;source&nbsp;destination&nbsp;switches<br>Source: We want to copy everything in the MySQL data folder, including sub-folders hence the switch<strong> /s</strong> Windows likes to have a complete path (relative paths are a problem). This batch file can be placed anywhere, to find anywhere we use the variable %CD% current directory (folder) this is created automatically when this batch file is run. It's the complete path up to and including the folder name.

Destination: Complete path to the folder where the database is to be copied, %ustemp%\data\ gives c:\us35temp\data\ without the ending back slash Windows can not decide if its a folder or file hence that back slash is needed.

Switches: I have covered /s which forces all sub-folders and their content to be copied. Unless you like to see rows upon rows of commands flashing by make sure you add a /q switch this stands for quite mode and stops all this unwanted information.

goto :CONTINUE Jump pass the next few lines and resume at the line named :CONTINUE
:ABORT A line or location where you can jump to using the <strong>go to</strong> command in this case our abort section, we found an error so give up.
echo Sorry the folder %ustemp% or one of its sub-folders could not be created.<br> echo Can not continue hence aborting<br>pause<br>EXIT A few lines that we echo back to a user informing why we are given up. To give that person a chance to read the message pause halts the program and waits for a key to be pressed. At that point the EXIT command is executed and the batch file terminates.
:CONTINUE A line or location where you can jump to using the go to command in this case our new lines of code are complete and appear to be working hence continue to run Uniserver batch file

Top

new_Server_Start.bat

<pre> rem File Name: new_Server_Start.bat rem Location: Uniform Server rem Created By: The Uniform Server Development Team rem Edited By: Olajide Olaolorun (empirex) rem Comment: After start, go to apanel directly. rem To Developers: Implemented %www%, and %apanel% :) rem Edited Last By: Mike Gleaves (Ric) rem Comment: Proposed mods MPG (Ric) 14-4-2008 rem Proposed enhancement MPG 3-7-08 rem Added new section for CD ROM 29-06-08 rem Tutorial Oily Rag 1: CD Part 1

@echo off rem working directory current folder pushd %~dp0

rem Command line parameters: rem Server_Start.bat %1 %2 %3 rem %1 = Drive letter to use rem %2 = mysql (run MySql server) or nomysql (do not run MySql server) rem %3 = console (Open a command prompt at folder MySQL Bin) rem Note: If using %2 you must set a value for %1 rem Note: If using %3 you must set values for %1 and %2 rem Note: Default, uses drive W, runs the MySQL server and does not a command prompt.

rem === MPG new code added for CD ROM ================================================ set ustemp=c:\us35temp

Create main folder on C

IF NOT EXIST %ustemp% md %ustemp% IF NOT EXIST %ustemp% goto :ABORT

IF NOT EXIST %ustemp%\tmp md %ustemp%\tmp IF NOT EXIST %ustemp%\tmp goto :ABORT

Apache

IF NOT EXIST %ustemp%\apache\logs md %ustemp%\apache\logs IF NOT EXIST %ustemp%\apache\logs goto :ABORT

MySQL

IF NOT EXIST %ustemp%\mysql\data md %ustemp%\mysql\data IF NOT EXIST %ustemp%\mysql\data goto :ABORT

IF NOT EXIST %ustemp%\mysql\tmp md %ustemp%\mysql\tmp IF NOT EXIST %ustemp%\mysql\tmp goto :ABORT

php ini

IF NOT EXIST %ustemp%\php\logs md %ustemp%\php\logs IF NOT EXIST %ustemp%\php\logs goto :ABORT IF NOT EXIST %ustemp%\php\tmp md %ustemp%\php\tmp IF NOT EXIST %ustemp%\php\tmp goto :ABORT

phpMyAdmin config.ini.php

IF NOT EXIST %ustemp%\phpmyadmin\etc\phpmyadmin md %ustemp%\phpmyadmin\etc\phpmyadmin IF NOT EXIST %ustemp%\phpmyadmin\etc\phpmyadmin goto :ABORT IF NOT EXIST %ustemp%\phpmyadmin\tmp md %ustemp%\phpmyadmin\tmp IF NOT EXIST %ustemp%\phpmyadmin\tmp goto :ABORT

Copy complete database

XCOPY "%CD%\udrive\usr\local\mysql\data" %ustemp%\mysql\data\ /s /q

goto :CONTINUE

ABORT

echo Sorry the folder %ustemp% or one of its sub-folders could not be created. echo Can not continue hence aborting pause EXIT

CONTINUE

rem === END CD ROM ============================================================

rem ### Is Apache running if it is jump to STARTED rem ### First check for system error jump to Pause allows error message to be displayed. udrive\home\admin\program\pskill.exe Apache.exe if errorlevel 2 goto :PAUSE if not errorlevel 1 goto :STARTED

rem ### Apache not running. Check for drive letter if not set (%1) use default. set Disk=%1 if "%Disk%"=="" set Disk=w

rem ### Create the virtual disk, if it fails go to Hint subst %Disk%: "udrive" if errorlevel 1 goto :HINT

rem ### Drive was created. Create variables for paths and programs set apachepath=\usr\local\apache2\ set apacheit=%Disk%:%apachepath%bin\Apache.exe -f %apachepath%conf\httpd.conf -d %apachepath%. set programit=%Disk%:\home\admin\program\ set closeit=%programit%close.bat %Disk%

rem ### Change path to PHP - Required for running scripts %Disk%: cd \usr\local\php

rem ### Provide feedback to user CLS echo The server is working on the disk %Disk%:\ [http/127.0.0.1/apanel/]

rem ### Start Apache server start %programit%uniserv.exe "%apacheit%" "%closeit%"

rem ### Start Apanel start \home\admin\www\redirect.html

rem ### Start MySQL server - skip if requested not to start (%2) if "%2"=="nomysql" goto :NOMYSQL start \usr\local\mysql\bin\mysqld-opt.exe --defaults-file=/usr/local/mysql/bin/my-small.cnf

NOMYSQL

rem ### Does user want to run a command prompt, if not END if "%3"=="console" goto :CONSOLE goto :END

CONSOLE

rem ### User wants to run a command prompt. Opens in MySQL bin rem ### Allows command clients to be used (musql.exe and mysqladmin.exe ) %Disk%: cd \usr\local\mysql\bin start cmd.exe goto :END

HINT

CLS echo The disk %Disk% is busy. Use start.bat [disk letter] goto :PAUSE

STARTED

CLS echo ERROR!!! echo One of the instances of Apache server is started. Use stop.bat

PAUSE

echo . pause

END

rem restore original working directory popd </pre>

Top

Stop.bat

UniServer boast that it leaves no dust behind in keeping with this philosophy the last thing our new Stop.bat file does is to delete the temporary folder and all its content.

Before making any changes save the old file to folder Uniform Server/uscd as old_Stop.bat

Use this link to view the new batch file (its a text file) save as new_Stop.bat

Below I have provided a detailed description of the new commands added to Stop.bat. These are placed at the end of the file.

ping -n 20 localhost &gt; nul This line serves no other purpose than to introduce a delay. Our temporary folder cannot be deleted until process using it terminate. I have found no way of detecting when a process ends from a batch file and then continue to the next command. Hence this little kludge delays for a certain time in the hope the processes have terminated before attempting to delete the folder. A last resort is to run stop.bat again, not elegant but works. Results returned from ping are dumped to the black hole file named nul.

-n count Number of echo requests to send

RMDIR&nbsp;/s&nbsp;/q&nbsp;c:\us35tempset RMDIR Remove directory (deletes a named folder) we provide the full path to that folder.<br>Switches: There are two switches without /s you are requested to confirm each sub-folder deletion. Quite mode is enable by /q this prevents the display of every deletion.

Top

new_Stop.bat

<pre> rem File Name: new_Sop.bat rem Location: Uniform Server rem Created By: The Uniform Server Development Team rem Edited By: Olajide Olaolorun (empirex) rem Comment: Tara's new syetm of shutting down the server rem To Developers: Implemented a new system of server shutdown rem Edited Last By: Mike Gleaves (Ric) rem Comment: Proposed mods MPG (Ric) 14-4-2008 rem Proposed enhancement MPG 3-7-08 rem Added new section for CD ROM 29-06-08 rem Tutorial Oily Rag 1: CD Part 1

@echo off rem working directory current folder pushd %~dp0

rem Stop Apache indirectly stops MySQL udrive\home\admin\program\pskill.exe Apache.exe c

rem ### Check for system error jump to Pause allows error message to be displayed. if errorlevel 2 goto :PAUSE goto :END

PAUSE

echo . pause

END

rem === MPG new code added for CD ROM ============================ rem This intruduces a delay allowing processes to end rem otherwise RMDIR fails and the bat must be re-run echo Please Wait removing files ping -n 15 localhost > nul

clean up remove dir

RMDIR /s /q c:\us35temp rem ===END CD ROM ================================================ rem restore original working directory popd </pre>

Top

Top

Download

If you have problems consider downloading this overlay file CD Part 1 copy the file to folder Uniform Server before running the file make sure you are using a copy of your servers otherwise you will need to manually reverse the above changes to return to your original servers.

Top

Testing

Start the servers using new_Server_Start.bat check they function correctly. Stop the servers using new_Stop.bat make sure the folder c:/us35temp is deleted.

That completes testing all that remains is to burn folder Uniform Server (and all its content) to a CD.

To run Uniform Server from a CD navigate to folder Uniform Server and use new_Server_Start.bat remember to run new_Stop.bat

Top

Summary

Take one clean copy of Uniform Server, add your site including database; make the above changes, burn to a CD and enjoy. I have tested the above using a copy of Uniform Server running MediaWiki with no problems.

The CD mode has a few limitations notably certain elements in apanel and phpMyBackupPro will not work; however the three core components Apache, MySQL and phpMyAdmin do.

Well what happened to this mode switching thing? Remember that folder you diligently filled with old and new files seems a pointless exercise however on the next page I put these to good use where I cover mode switching.

Top


Ric