Debugging Tips

From The Uniform Server Wiki
Jump to navigation Jump to search

MPG UniCenter

Debugging Tips

General Debugging Tips including 3.5-Apollo Specific

I have always advocated go in hack Uniform Server around and break it. This little chap is the result of a session where I could not resolve the reason why I broke it. I decided to animate his eyes and antenna serves as a reminder not to go in heavy handed.

This page contains a few tips that will assist you in debugging on Uniform Server.

What’s my IP?

There are many on line services that will provide your IP address for example click this link: Whats My IP you cant miss it, top right big and bold.

On the above page try the “More Info About You” link.

Checking your server is externally accessible

You have popped your servers on-line and wondering if they are accessible from the Internet. Google translate is ideal for this, in order to translate a page it needs access to your servers (Exactly what we need and fully automated.).

  1. Go to Google Translate page: Google Translate
  2. Select Text and Web top menu bar (Automatically selected for you)
  3. Bottom of page you will find a text field Translate a web page enter a valid address for your page:
    1. It accepts IP addresses for example http://89.007.251.102/test/index.html
    2. Or domain names for example: http://fred.com/test/index.html
  4. Select any language from the drop down list.
  5. Click Translate
    1. If the page is accessible it is translated.
    2. If its not accessible a blank page is displayed.

Quick and effective that’s what I like.

Top

Apache not starting - httpd.conf syntax check 1

If you have made changes to Apache configuration file httpd.conf and find Apache no longer runs the chances are you made a typo? Apache will not run if there is a syntax error in the configuration file however the virtual drive (default W) may have been created if so you can use the following to check for syntax errors:

Open a command prompt (run > type cmd > click Ok)

  In the pop-up window type the following shown in bold:  

C:\Documents and Settings\fred>w:
W:\>cd usr\local\apache2\bin
W:\usr\local\apache2\bin>apache.exe -t
Syntax OK

W:\usr\local\apache2\bin>

 

This will run Apache and check the configuration syntax.

  • w: Selects the virtual drive change this if using a different one
  • cd Move to folder where the Apache program is
  • apache.exe -t Runs Apache with test flag -t

Any syntax errors will be reported.

Top

Apache not starting - httpd.conf syntax check 2

If Apache fails to start its more than likely the virtual drive will not be created. The following batch file will create a virtual drive and test the syntax. This batch file may be run with or without the servers running.

Save the following to a file named uc_apache_syntax.bat place the file in folder Uniform Server double click to run.

:Batch file to check Apache configuration syntax
:Creates a virtual drive if it does not already exist
:Optionally removes the virtual drive created
:Place in folder ”Uniform Server” with other bat files
:File: uc_apache_syntax.bat
:Author: Mike Gleaves
:Version: 1.0
:Date: 25-1-2008

@echo off

:== Set drive to W change this as required
set Disk=W

:== create virtual disk and map folder udrive to it
subst %Disk%: "udrive"

:== Clear screen hides error if already created 
cls

:== select drive, change to folder, run apache command,

%Disk%:
cd usr\local\apache2\bin
apache.exe -t

:== User option to remove virtual drive
echo.
echo.
SET remove_disk=N
SET /P remove_disk=Remove virtual drive %Disk% type Y or y press enter =
IF %remove_disk%==N goto :NOTREMOVED
IF %remove_disk%==Y goto :REMOVE
IF %remove_disk%==y goto :REMOVE

:NOTREMOVED
echo.
echo "Disk has not been removed"
goto :END

:REMOVE
echo.
echo "Disk removed"
subst %Disk%: /d

:END
echo.
pause

File details and notes:

file: uc_apache_syntax.bat

@echo off

:== Set drive to W change this as required
set Disk=W

:== create virtual disk and map folder udrive to it
subst %Disk%: "udrive"

:== Clear screen hides error if already created
cls

:== select drive, change to folder, run apache command,

%Disk%: cd usr\local\apache2\bin apache.exe -t

:== User option to remove virtual drive
echo.
echo.
SET remove_disk=N
SET /P remove_disk=Remove virtual drive %Disk% type Y or y press enter =
IF %remove_disk%==N goto :NOTREMOVED
IF %remove_disk%==Y goto :REMOVE
IF %remove_disk%==y goto :REMOVE

:NOTREMOVED
echo.
echo "Disk has not been removed"
goto :END

:REMOVE
echo.
echo "Disk removed"
subst %Disk%: /d

:END
echo.
pause

 

Notes:

  • You may run this file even when the servers are running.

If the servers are not running a virtual disk drive is created the default is “W” if you are using a different disk change the line: set Disk=W accordingly.


The next lines run the apache command –t to verify the configuration file syntax

Note: Command -t must be run from the virtual drive and not from where Uniform Server was extracted otherwise the following error is generated:

Syntax error on line 69 of G:/0_1/Uniform Server/udrive/usr/local/apache2/conf/h ttpd.conf: ServerRoot must be a valid directory

Hence these lines are required in the batch file they change the working disk and directory:

%Disk%:
cd usr\local\apache2\bin


The remaining lines provide an option to remove the virtual drive created.

  • If the drive already created (servers running) prior to running uc_apache_syntax.bat do not use it to delete the drive otherwise you will be unable to shutdown the servers (just means you will need to kill the processes manually).
  • If you are performing a syntax check without running the servers then delete the virtual drive otherwise the servers will not start when using Server_Start.bat

Top

Apache - Log files

Apache logs all its transactions to the following file access.log and errors to error.log these are located in folder:

*\Uniform Server\udrive\usr\local\apache2\logs

when debugging Apache problems make this your first port of call .

Top

Mod Rewrite - Log file

Logs all Mod Rewrite transactions to a file using “RewriteLog” and “RewriteLogLevel” directives. These instructions cannot be placed in an htaccess file they must be placed in Apache’s main configuration file httpd.conf preferably in a Vhost.

File: httpd.conf
Location: *Uniform Server\udrive\usr\local\apache2\conf

NameVirtualHost *
<VirtualHost *>
ServerName localhost:80
DocumentRoot /www

RewriteLog "logs/rewrite.txt"
RewriteLogLevel 9

</VirtualHost>

 
  • RewriteLog: Sets the log file name to which the server logs all rewrite transactions.(use any name you like)
  • RewriteLogLevel: Sets the log level. Maximum log level is "9" will log almost all-rewriting transactions a setting of "0? will disable rewrite logging. Choose a value that best suits your needs, try a value of “3 or 5”
  • Note: The log file rewrite.log will be found in folder: *Uniform Server\udrive\usr\local\apache2\logs

Note: Only enable these lines while testing do not use on a live server because logging will quickly eat your disk space. Comment out the lines (by placing # at the start of the line) or delete after testing, you may also wish to delete the log file (rewrite.txt).

Top


Ric