Installation
============

If you are upgrading from older versions of LinkChecker you should
also read the upgrading documentation stored in UPGRADING.txt.


Requirements for Unix/Linux or Mac OS X
---------------------------------------

1. You need a standard GNU development environment with
   
   - C compiler (for example the GNU C Compiler gcc)
     
     Depending on your distribution, several development packages
     might be needed to provide a fully functional C development
     environment.
   
   Note for developers: if you want to regenerate the po/linkchecker.pot
   template from the source files, you will need xgettext with Python
   support. This is available in gettext >= 0.12.

2. Python >= 2.5 from http://www.python.org/ with zlib support
   
   Be sure to also have installed the included distutils module.
   On most distributions, the distutils module is included in
   an extra ``python-dev`` package.

3. *Optional, for bash-completion:*
   optcomplete Python module from http://furius.ca/optcomplete/

4. *Optional, for HTML/CSS syntax checks:*
   HTML tidy from http://utidylib.berlios.de/
   cssutils from http://cthedot.de/cssutils/

5. *Optional, for displaying country codes:*
   GeoIP from http://www.maxmind.com/app/python

6. *Optional, used for Virus checking:*
   ClamAv from http://www.clamav.net/


Requirements for Windows
------------------------

None, the installer contains all files.


Setup for Unix/Linux or Mac OS X
--------------------------------

1. Install check
   
   Be sure to have installed all required Unix/Linux software listed above.

2. Compile Python modules
   
   Run ``python setup.py sdist --manifest-only`` to create the MANIFEST
   file.
   Run ``python setup.py build`` to compile the Python files.
   For help about the setup.py script options, run
   ``python setup.py --help``.
   The CC environment variable is checked before compilation, so you can
   change the default C compiler with ``export CC=myccompiler``.

3.
   a) Installation as root
      
      Run ``su -c 'python setup.py install'`` to install LinkChecker.
   
   b) Installation as a normal user
      
      Run ``python setup.py install --home $HOME``. Note that you have
      to adjust your PATH and PYTHONPATH environment variables, eg. by
      adding the commands ``export PYTHONPATH=$HOME/lib/python`` and
      ``export PATH=$PATH:$HOME/bin`` to your shell configuration
      file.
      
      For more information look at the `Modifying Python's search path`_
      documentation.
      
      .. _Modifying Python's search path:
         http://docs.python.org/inst/search-path.html#SECTION000410000000000000000

Setup for Windows - the binary .exe installer:
----------------------------------------------

1. Execute the ``LinkChecker-x.y.exe`` file and follow
   the instructions.

2. If an error like ``This application has failed to start because the
   application configuation is incorrect", please install the Microsoft
   `Visual C++ 2008 runtime`_ package.
   
   .. _Visual C++ 2008 runtime:
      http://www.microsoft.com/downloads/details.aspx?FamilyID=9b2da534-3e03-4391-8a4d-074b9f2bc1bf&displaylang=en

Setup for Windows - compiling from source:
------------------------------------------

1. Install Python >= 2.5 from http://www.python.org/
   [http://www.python.org/ftp/python/2.6.1/python-2.6.1.msi]

2. *Optional, for console color support:*
   Wconio from http://newcenturycomputers.net/projects/wconio.html
   [http://newcenturycomputers.net/projects/download.cgi/WConio-1.5.win32-py2.5.exe]

3. *Optional, for HTML/CSS syntax checks:*
   HTML tidy from http://utidylib.berlios.de/
   cssutils from http://cthedot.de/cssutils/

4. *Optional, used for Virus checking:*
   ClamAv from
   http://www.sosdg.org/clamav-win32/
   [http://clamav-sosdg.googlecode.com/files/clamav-0.94.2-1a.exe]

5. Install the MinGW suite from http://mingw.sourceforge.net/
   Be sure to install in the given order:
   
   a) MingGW (this installer downloads additional packages)
      [http://downloads.sourceforge.net/mingw/MinGW-5.1.4.exe]
   b) MSYS
      [http://downloads.sourceforge.net/mingw/MSYS-1.0.10.exe]

6. Install InnoSetup from http://www.jrsoftware.org/isinfo.php
   [http://www.jrsoftware.org/download.php/is.exe]

7. Preparing Python for the MinGW compiler
   
   Search the file python26.dll in your windows folder.
   After you found it, launch MSYS. Change into the windows folder,
   for example ``cd c:\winnt\system32``. Then execute
   ``pexports python26.dll > python26.def``.
   Then use the dlltool with
   ``dlltool --dllname python26.dll --def python26.def --output-lib
   libpython26.a``.
   The resulting library has to be placed in the same directory as
   python26.lib. (Should be the libs directory under your Python installation
   directory, for example ``c:\Python26\Libs\``.)

8. Generate and execute the LinkChecker installer
   
   Close the MSYS application (by typing ``exit``) and open a DOS command
   prompt.
   Change to the ``linkchecker-X.Y`` directory and run
   ``scripts\bdist.bat`` to build a binary installer.
   
   This generates a binary installer
   ``dist\LinkChecker-X.Y.exe`` which you just have to execute.

After installation
------------------

LinkChecker is now installed. Have fun!


(Fast)CGI web interface
-----------------------

The included CGI scripts can run LinkChecker with a nice graphical web
interface.
You can use and adjust the example HTML files in the lconline directory
to run the script.

0. Note that running LinkChecker requires CPU and memory resources.
   Allowing a CGI script to execute such a program for possibly a
   large number of users might deplete those resources.
   Be sure to only allow access from trusted sites to this script.
   
1. Choose a CGI script. The simplest is lc.cgi and you need a web server
   with CGI support.
   The script lc.fcgi (I tested this a while ago) needs a web server
   with FastCGI support.

2. Copy the script of your choice in the CGI directory.

3. Adjust the "action=..." parameter in lconline/lc_cgi.html
   to point to your CGI script.

4. load the lconline/index.html file, enter an URL and klick on the
   check button

5. If something goes wrong, check the following:
   
   a) look in the error log of your web server
   b) be sure that you have enabled CGI support in your web server
      do this by running other CGI scripts which you know are
      working
   c) try to run the lc.cgi script by hand
   d) try the testit() function in the lc.cgi script
