Web Technologies

From TechWiki


Web Server


Apache is the most popular open source web server running on more than 2/3 of the worlds web servers.



apachectl option

Apache 2:

apache2ctl option


start, stop, restart, status, fullstatus, configtest


Check that:

find . /etc/ -name "*apache2*"

results in:



/etc/rcX.d/S_K_Nr_apache2 is a link to /etc/init.d/apache2

for Apache 2 to automatically start when the system is booted.

If not, consult Installation.

Virtual Hosts

Edit config file:

  • Apache: /etc/apache/httpd.conf
  • Apache 2: /etc/apache2/sites-available/default


NameVirtualHost *

<VirtualHost *>
ServerName mysite.homeip.net
DocumentRoot /var/www/mysite

Restart Apache.


<VirtualHost *>
ServerName mysite.homeip.net
DocumentRoot /var/www/mysite
ErrorLog /var/log/apache2/error.log
LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
CustomLog /var/log/apache2/mysite.log combined

Restart Apache.


To see who is listening on what port:

netstat -nplt 


Password Protected Areas

Create subdirectory with:

mkdir secure
chmod 755 secure
cd secure

Create .htaccess file with the following content:

AuthUserFile /path/to/.htpasswd
AuthName "Secure Section"
AuthType Basic

<Limit GET>
require valid-user

Set up password with:

htpasswd -c /path/.htpasswd user1


htpasswd /path/.htpasswd user2

depending if .htpasswd file already exists or not (then the option -c creates).

Change permission:

chown root:www-data /path/.htpasswd
chmod 755 /path/.htpasswd

See http://lightsphere.com/dev/htpass.html.

Note that ripe.net will allow you to resolve IP numbers to names and companies.

Don't Show Directory Listing

Create .htaccess file in the directory of the webserver you want to protect and add the line

Options -Indexes

This means, if somebody browses to this URL, the message is


You don't have permission to access /arch/1523/ on this server.

To enable directory listing for subfolders, just an an additional .htaccess with the line

Options +Indexes


Server's Fully Qualified Domain Name

If you get error apache2: Could not determine the server's fully qualified domain name, using for ServerName after:

apache2ctl restart

then edit:


and add line:


Then check:


for the entry: name name
Options Indexes

If you havean .htaccess file in a directory with

Options -Indexes

and are still allowed to access the corresponding URL, check your log file (/var/log/apache2/error.log) to see if it contains something like this:

.htaccess: Option Indexes not allowed here

You need to add to your virtual host file (something like: /etc/apache2/sites-available/default)

       <Directory ~ priv$>
               AllowOverride all

for the corresponding directory. The example above does this for every directory containing the name priv.

However, I didn't get this to work for subdirectories, so the solution was to add

<Directory />
   AllowOverride All

to the <VirtualHost> section in your virtual host file. Then the .htaccess file needs to be

Options FollowSymLinks -Indexes

Restart the apache server

apache2ctl restart

If you access the URL, the .htaccess file forbids it to give a directory listing, and reports this in the error log:

Directory index forbidden by Options directive

So you can only read files if you know their names.


Used for PHPEclipse.

Insert into /etc/apache2/apache2.conf:

Alias /eclipse/ "/var/www/src/"
<Directory "/var/www/src/">
   Options Indexes MultiViews
   AllowOverride Options
   Order allow,deny
   Allow from all

Restart Apache:

apache2ctl restart

This allows Apache to serve the files from /var/www/src/ when we enter the location http://localhost/eclipse/, unless you have Zope running, in which case another rewrite is due:

 RewriteCond %{REQUEST_URI} !^/eclipse

see here.

Dynamic DNS

DynDNS makes your computer a node of the internet for free! More in Wikipedia.

It allows one to use varying IP numbers like fixed ones. Ususally fixed IP numbers are costly and for the standard internet connections (dialup, broadband) the ISP assigns you a varying IP number.

  • Create virtual host: here
apt-get install ipcheck

See http://ipcheck.sourceforge.net/.

  • Run once with --makedat option in writable directory (one line):
python /usr/sbin/ipcheck.py --makedat -l -r checkip.dyndns.org:8245 dyndnsuser
dyndnspassword mysite1.homeip.net,mysite2.homeip.net
  • Set cron job to check IP over the web ever 5 minutes. Note that clients can get the IP directly from some brands of routers. Edit /etc/crontab (one line):
*/5 * * * * root /usr/sbin/ipcheck.py -l -d /yourdirectory/
-r checkip.dyndns.org:8245 dyndnsuser dyndnspassword mysite1.homeip.net,mysite2.homeip.net

NB: Putting

>> /dev/null 2>&1

at the end of the crontab entry, will prevent any output to a terminal or system email.

Router Setting

Find Virtual Server Settings and set HTTP Server to the IP of your server (usually something like 192.168.xxx.xxx).


Application Server


Is an object-oriented application server written in Phython. See:

Used here only for Plone.


  • Python 2.3.4



If you only need Zope to run Plone, go to the Plone section and use apt-get to install, i.e., the downloads are not required.

Getting Started

Where things are:

/var/lib/zope/instance/default/ = INSTANCE_HOME

Start zope:

zopectl start

Open browser:


or better:


Note that for non-Debian systems the port is 8080.

Enter initial user and password (as set during install). If you don't know them:

zopectl stop
cd /var/lib/zope/instance/default/
zope-zpasswd inituser
           ---> name, passwd, encoding (SHA), domain restrictions (blank)
zopectl start

Note that some literature uses:

python /usr/lib/zope/zpasswd.py inituser

Zope, Apache, Proxies and Rewrites

See Plone.

Jakarta Tomcat


http://jakarta.apache.org/tomcat/. Used for J2EE stuff. Docs are here.






tar -xzf jakarta-tomcat-5.5.7.tar.gz

cd to that directory and launch


Works out of the box with JRE5 (Java 2 Standard Edition Runtime Environment version 5.0), for JRE1.4 or less further packages are required. Read RUNNING.txt.

Shutdown with


Set environment variable

CATALINA_HOME to install directory

Go to:


to see welcome page or


Applications: JSP

From here:

  • Change to the webapps subdirectory of the Tomcat installation directory.
  • Create a subdirectory with the name of your web application (such as homework1).
  • Inside that subdirectory, create a subdirectory WEB-INF (all uppercase, with a hyphen, not an underscore).
  • Inside the WEB-INF directory, create yet another subdirectory classes. The full path to that directory should be something like /usr/local/jakarta-tomcat-4.0.4/webapps/homework1/WEB-INF/classes
  • Place a file web.xml into the WEB-INF directory that has the following contents:
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

  • You can copy it from the .../webapps/tomcat-docs/WEB-INF directory if you don't want to type in the file.
  • For testing purposes, place a file test.jsp into your web application directory (such as ../webapps/homework1) with the contents
<%= new java.util.Date() %>
  • Start Tomcat again, as described previously
  • Point your browser to http://localhost:8080/homework1/test.jsp. The current date and time should be displayed.
  • Now you are ready to deploy your program. Place your JSP file(s) into the application directory. Place your class files into the WEB-INF/classes/bigjava subdirectory (see the note below).
  • Remember to shut down the server when you are done.

Applications: JAR


A wiki is like a content management system without any restrictions for publishing and editing.

The most popular wiki: wikipedia.org.

For a comparison of available wikis see www.wikimatrix.org.


Using MediaWiki, i.e., Wikipedias wiki technology. See FAQ.

Deutsches HowTo: apfelwiki.de.


Taken from: Install instructions.

Get the latest MediaWiki form MediaWiki SourceForge page, currently 1.5.4.

Or with wget:

wget  http://puzzle.dl.sourceforge.net/sourceforge/wikipedia/mediawiki-1.3.9.tar.gz

Copy it and extract in apache root directory:

cp mediawiki-1.3.9.tar.gz /var/www
cd /var/www
tar vxfz mediawiki-1.3.9.tar.gz

rename the extracted directory name to wiki

mv mediawiki-1.3.9 wiki

In order to configure the wiki you have to make the config subdirectory writable by the web server.

To make the directory writable on a Unix/Linux system:

cd /var/www/wiki
chmod a+w config

Navigate your browser to http://localhost/wiki and continue with installation.

Pay good attention for "Checking environment..." in MediaWiki installation script. This can solve a lot of problems for your MediaWiki successful installation. Fill out the configuration form and continue.

Once configuration is done you'll need to move the created LocalSettings.php to the parent directory.

cd /var/www/wiki/config/
mv LocalSettings.php ..

For added safety you can then remove the config subdirectory entirely.

cd ..
rmdir config

And navigate your browser to http://localhost/wiki to see your new wiki. Done!

How to move a wiki to another server

See: wikimedia.org.

MySQL dump (more here):

/usr/bin/mysqldump -ppassword -uroot db > db.sql

Restore tables (db needs to be created already):

mysql -uroot -p db < db.sql


Disable Anonymous Editing

In these times of hard core spamming, it is advisable to disable anonymous editing, or otherwise your wiki will be "attacked" by scripts inserting endless links to porn or viagra sites, aiding the spammer to get higher rankings in google.

Add in LocalSettings.php:

Pre 1.5

$wgWhitelistEdit = true;


 # Permission keys given to users in each group.
 # All users are implicitly in the '*' group including anonymous visitors;
 # logged-in users are all implicitly in the 'user' group. These will be
 # combined with the permissions of all groups that a given user is listed
 # in in the user_groups table.
 # This replaces wgWhitelistAccount and wgWhitelistEdit
 # The following line should be commented, otherwise these settings will
 # throw away the settings on DefaultSettings.php (you probably don't want this).
 # With this line commented you will only overwrite the settings you explicitly
 # define here (that's what you probably want).
 #$wgGroupPermissions = array();
 $wgGroupPermissions['*'    ]['createaccount']   = true;
 $wgGroupPermissions['*'    ]['read']            = true;
 $wgGroupPermissions['*'    ]['edit']            = false;

Taken from http://meta.wikimedia.org/wiki/Access_Restrictions.

Upload Files

Link: wikimedia.org.

Edit LocalSettings.php to contain:

$wgEnableUploads = true;

Problems: The file is corrupt or has an incorrect extension. Please check the file and upload again. Put this in LocalSettings.php:

$wgMimeDetectorCommand= "file -bi"; #use external mime detector (linux)

More on uploading images: [1].

Set permissions right in /var/www/mysite/wiki

chown www-data -R images/ 
chmod -R o-x images/


$wgLogo = "$wgScriptPath/.../logo.png";

Getting rid of the background image in the top part (picture of an opened book). Edit wiki/skins/monobook/main.css and comment out:

background: #f9f9f9 url(headbg.jpg) 0 0 no-repeat;

To enable a favicon.ico (symbol in the browser's address-line), edit /wiki/includes/Skin.php or place the favicon in the wiki directory.



Modifying the navigation tool box
  • Remove or change order of elements in the box, go to URL

and edit as you like.

To add new elements with external URL's:

** http://www.whatever.net|Text

More here: wikimedia.org


Extracts from wikimedia.org.

You need these packages installed:

  • ocaml
  • imagemagick
  • gs
  • cjk-latex
  • tetex-extra
  • php4-imagick
apt-get install ocaml imagemagick gs cjk-latex tetex-extra php4-imagick


apt-get install mediawiki-math

After installation, enable inline LaTeX equations by uncommenting:

$wgUseTeX           = true;

in LocalSettings.php file.

Make sure your php.ini contains the following row:


Next compile texvc in your math directory:

cd /var/www/wiki/math

You may have to manually create the directories for math temp and output directories:

cd /var/www/wiki/images
mkdir math tmp
chmod 777 math tmp

Read math/README for further detailed instructions.

  • Example:
e^{ix} = \sum_{n=0}^{\infty} \frac{(ix)^n}{n!} = \cos x + i \sin x

LaTeX and HTML

For some thoughts on using math in webpages, go to Usage.


Don't forget to do this.

Example Site

This site is an example of MediaWiki.


User rights

Disable anonymous editing:

$wgWhitelistEdit = true;

Google Analytics Integration in MediaWiki

See mediawiki.org.


Some content management systems.

For a comparison of available CMS see cmsmatrix.org.


This section is about technical aspects pertaining to Typo3, if you want to know how to get an installation to work go to My Typo3.

See http://typo3.org/, http://typo3.com/, http://wiki.typo3.org/index.php/Main_Page.


  • PHP4 (GDLib, Freetype)
  • MySQL: database, user, password; note that database dumps go in the typo3conf/ directory
  • ImageMagick


See installation guide or following TYPO3 Enterprise Content Management (Altmann, Fritz and Hinderink; Open Source Press; Munich; 2004):

cd /var/www/
wget http://puzzle.dl.sourceforge.net/sourceforge/typo3/dummy-3.7.0.tar.gz
wget http://puzzle.dl.sourceforge.net/sourceforge/typo3/typo3_src-3.7.0.tar.gz
tar -vxzf typo3_src-3.7.0.tar.gz
tar -vxzf dummy-3.7.0.tar.gz 
mv dummy-3.7.0 sitename
rm *.gz
cd sitename
chmod 770 typo3/ext/
chmod 770 typo3temp/
chmod -R 770 typo3conf
chmod 770 uploads/ 
chmod 770 fileadmin/

Note: 770 only works if user/group is www-data. Otherwise use 777 and risk security issues. Or:

chgrp -R www-data typo3_src-3.7.0/ sitename/
chmod -R g+w,o-rwx typo3_src-3.7.0/ sitename/


vi typo3/install/index.php

remove or comment line with:

die("In the source distribution of TYPO3, ...!");



Security issues for typo3/install/index.php; do one of the following:

  • change the password as defined by the md5-hash in TYPO3_CONF_VARS[BE][installToolPassword].
  • delete the folder 'typo3/install/' with this script in or just insert an 'exit;' line in the script-file there.
  • password protect the 'typo3/install/' folder, eg. with a .htaccess file


From 3.8.1 To 4.0

Theoretically easy due to the usage of symlinks in the directory structure.

First backup MySQL:

mysqldump -uroot -p db > db.sql

and backup uploads and fileadmin folders, e.g., as tar-files:

tar -czf name.tar.gz directory

Wow, that actually did go well:

  • Install new Typo3 source and dummy package
  • Log in to 1-2-4-Installer (complained about not being able to access MySQL, which is ok)
  • Installer lets you use mysqldump from old Typo3 database
  • Install all the extensions
  • In the installer click Continue to configure TYPO3 and go to Database Analyser and Compare. This will resolve database conflicts
  • If you did any manual editing in typo3/ext (templates and css) then you need to import the changes
  • Changes to localconf.php need to be ported as well (like $TYPO3_CONF_VARS["BE"]["interfaces"] = 'frontend, backend';)

Infos on update to version 4.0: here.

From 4.0 To 4.1.1


  • Update database and directory
  • Check that all extensions are Local or System and not Global


  • Download 4.1.1 source tarball from typo3 page and unpack new source directory
  • Change typo3_src link to point to new source directory
  • In the backend go to Install and check the databases with the Database Analyzer (Compare and Import) and run the Install Wizard




  • Having the admin login form display an additional selection interface allowing the user to jump to the Frontend or Backend after login:
Open the file .../typo3conf/localconf.php in your typo3 directory
Add: $TYPO3_CONF_VARS["BE"]["interfaces"] = 'backend, frontend';


Real URL

See http://typo3.fruit-lab.de/ and http://www.symplasson.de/infopool/magazin/typo3-suchmaschinenkompatibel/view.

Basically, install plugin


tune Apache to allow rewrite mod

cd /etc/apache2/mods-enabled
ln -s ../mods-available/rewrite.load
apache2ctl restart

put .htaccess file in base directory containing

RewriteEngine On
RewriteRule ^typo3$ - [L]
RewriteRule ^typo3/.*$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule (\.html|/)$ /index.php

Edit typo3 template

config.simulateStaticDocuments = 0
config.baseURL = http://j-node.homeip.net/
config.tx_realurl_enable = 1
config.uniqueLinkVars = 1
config.linkVars = L
config.prefixLocalAnchors = all

and edit localconf.php in /typo3conf/

$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'] = array(

'preVars' => array(
        'GETvar' => 'L',
        'valueMap' => array(
            'de' => '1',
        'noMatch' => 'bypass',

'fileName' => array (
                     'index' => array(
                                      'backend.php' => array(
                                                             'keyValues' => array (
                                                                                   'type' => 100,
                                                    'print' => array(
                                                                     'keyValues' => array(
                                                                                          'type' => 98,

'postVarSets' => array(
    '_DEFAULT' => array (
        'page' => array(
                'GETvar' => 'tx_drwiki_pi1[keyword]'

'pagePath' => array(
                    'type' => 'user',
                           'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
                           'spaceCharacter' => '-',
                       'languageGetVar' => 'L',
                           'expireDays' => 3


Google Sitemaps

Install extension mc_googlesitemap.

Example site







A CMS running on Zope.

Download CMFPlone.

Or following http://plone.org/downloads/debian:

vi /etc/apt/sources.list
apt-get update
apt-get install plone

to install Plone with all dependencies, e.g., all the Zope stuff.

Go to:


and select Plone Site in drop-down list and add. The Id you assign the new plone site is the name under wich you can access it directly. E.g., if the Id is myPlone:


Setting up Plone behind Apache

Although Zope is a full-featured web server, we want Apache to serve the Plone pages, i.e., act as a proxy.

First, install Virtual Host Monster:

Add it like the Plone Site in http://localhost:9673/manage

Then Apache needs modifications. Note that the following applies to Apache 2. For Apache all the modifications are in /etc/apache/httpd.conf.

  • Configure and load proxy and rewrite modules. Create a file called myProxy.conf in /etc/apache2/mods-available:
<IfModule mod_proxy.c>
       ProxyRequests Off
       <Proxy *>
               Order deny,allow
               Allow from <IP of your localhost>

and a file called myProxy.load also in /etc/apache2/mods-available:

LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so

Go to /etc/apache2/mods-enabled/ and add symbolic links:

ln -s /etc/apache2/mods-available/myProxy.load myProxy.load
ln -s /etc/apache2/mods-available/myProxy.conf myProxy.conf
ln -s /etc/apache2/mods-available/rewrite.load rewrite.load

Edit /etc/apache2/sites-available/default or whatever contains your virtual host settings:

<VirtualHost *>
ServerName www.yoursite.net
ServerAlias www.yoursite.net
ServerSignature On

 RewriteEngine On
 RewriteRule ^/(.*)
  http://localhost:9673/VirtualHostBase/http/www.yoursite.net:80/myPlone/VirtualHostRoot/$1 [L,P]

Note that RewriteRule ^/(.*) http://localhost:9[...]e/VirtualHostRoot/$1 [L,P] is on one line.

Restart apache:

apache2ctl restart

Special Proxying

If you would like some special subdirectories of www.yoursite.net not to be proxied to Zope, put a rewrite condition before your rewrite rule. E.g., www.yoursite.net/wiki should go to /var/www/yoursite/wiki like with a normal virtual host request and should not go to Zope. Edit /etc/apache2/sites-available/default:

<VirtualHost *>
DocumentRoot /var/www/yoursite/wiki

 RewriteEngine On
 RewriteCond %{REQUEST_URI} !^/wiki
 RewriteCond %{REQUEST_URI} !^/something_else 
 RewriteRule ^/(.*)

So any request with www.yoursite.net/wiki (or/something_else) will bypass the rewrite rule and instead look in your local /var/www/yoursite/wiki folder. Note: using [OR] between multiple RewriteCond didn't work.

Using it


Use the Zope Management Interface (ZMI), i.e., log in as admin and select Plone setup or go to http://localhost:9673/manage.

  • Logo

Go to:

 Plone Skins Tool => /portal_skins

Add image (drop-down list) and name ID:

  • Skin

Go to:

/portal_skins/custom/base_properties => Properties (tab)

Will create new settings in:

/portal_skins => custom => base_properties
  • Caching

For speed. Go to ZMI and select:

HTTP Cache
RAM Cache

See also Apache's mod_cache and mod_deflate. Chececk Zopes database in http://localhost:9673/manage:

Control_Panel -> Database Management -> Activity
  • Meta-Tags (Dublin-Core)

In the ZMI:

portal_skins => plone_templates => header => customize

Will create new template in:

/portal_skins => custom => header

Append code as described in [2]. Edit, e.g.:

<meta name="keywords" content="..."/>
<meta name="author" content="..."/>
<meta name="DC.Title" content="..."/>
<meta name="DC.Creator" content="..."/>
<meta name="DC.Subject" content="..."/>
<meta name="DC.Description" content="..."/>
<meta name="DC.Identifier" content="http://www.mysite.net/"/>
<meta name="DC.Rights" content="Open Source"/>
<meta name="revisit-after" content="7 days" />
<meta name="robots" content="index,follow" />
  • Error in Colophon (Dublin-Core)

The symbols under the footer for Section 508, W3C, etc. aren't displayed.In the ZMI:

portal_skins => plone_templates => colophon => customize

Will create new template in:

/portal_skins => custom => colophon


<metal:slot define-slot="colophon" />


ZMI -> myPlone -> MailHost

and set

SMTP Host: smtp.isp.net
SMTP Port: 25

Note that Mozilla may have another port defined.

Fix bug in Products/CMFPlone/PloneTools.py from:

if not self.validateEmailAddresses(to):


if not self.validateEmailAddresses(mto):

otherwise Plone will complain about "global name 'to' is not defined".

Related stuff: email server.


See Plone section in Backup.



Web Photo Albums






Get source:


Copy to required directory and

tar -xzf phpgraphy-0.9.8a.tar.gz

Create database:

mysqladmin -u root -p create dbname

Create tables:

mysql -u root -p dbname < sql_tables

Edit config.inc.php according your configuration.

Be sure that your pictures directory has the right attributes/owner so that the user running your php files can generate thumbnails.

If you are running PHP 4.2 or newer, phpGraphy won't work because register_globals is now set to off. Either edit php.ini (which everyone discourages) or put an .htaccess file with

php_flag register_globals on

in your directory containing phpGraphy.

For more MySQL stuff go here.






Lyceum is an open-source blogging platform based on WordPress. It is highly scalable and makes building up a community very easy.

See http://lyceum.ibiblio.org/

Misc Tools


HTML-editor, see here.

apt-get install nvu

Web File Browser


wget http://puzzle.dl.sourceforge.net/sourceforge/webfilebrowser/webfilebrowser-0.4b14.tar.gz

Mind Maps


Prefuse Visualization Tool


Web Statistics


See http://www.awstats.net/.


sudo apt-get install awstats





apt-get install webalizer

Needs Apache to do logging, see section Logging here. Default config file:



Run script with:

webalizer -n host1.dyndns.org -o /var/www/webalizer/host1 /var/log/apache2/host1.log

Or create cronjob in /etc/crontab:

0 23 * * * root webalizer -n host1.dyndns.org -o /var/www/webalizer/host1 /var/log/apache2/host1.log

It is also a good idea to delete the logs regularly, as they get big. Webalizer has the old statistics saved anyway.


Create dns_cache.db:

webalizer -o /var/www/webalizer/host1 -N 10 -D dns_cache.db /var/log/apache2/host1.log


webalizer -n host1.dyndns.org -o /var/www/webalizer/host1 -D dns_cache.db /var/log/apache2/host1.log

If you still get Unresolved/Unknown for the countries, check:


for DNS servers. If none or wrong ones are there, manually edit or use Xandros Control Center -> Network Connection -> DNS. The IP numbers of your DNS server can be found in the GUI of your router.

Also, see here.


See here.