Archive

Posts Tagged ‘apache’

Installing TileCache on RedHat/CentOS

July 25th, 2007 rupert Comments off

1. Install Apache
./configure –prefix=/usr/local/apache2 –enable-so –enable-rewrite –with-mpm=prefork
make
make install
rm -Rf /usr/local/apache2/htdocs/*

2. Install mod_python-3.3.1

./configure --with-apxs=/usr/local/apache2/bin/apxs
make
make install

3. Install Python Imaging Library (PIL) – Imaging-1.1.6

python setup.py install

Note: To check if PIL was successfully installed:
#python selftest.py
***Test Failed*** 1 failures.
*** 1 tests of 57 failed.

47 ln -s /usr/lib/libjpeg.so.62 /usr/lib/libjpeg.so
48 ldconfig
49 python setup.py install
51 python selftest.py
54 rm -rf Imaging-1.1.6
55 tar -zxvf Imaging-1.1.6.tar.gz
56 cd Imaging-1.1.6
58 python selftest.py -> still fails
59 python setup.py install
60 python selftest.py -> ok

4. Check if mod_python was sucessfully installed.
http://www.dscpl.com.au/wiki/ModPython/Articles/GettingModPythonWorking

[root@rupert-centos pytest]# python
Python 2.4.3 (#1, Mar 14 2007, 18:51:08)
[GCC 4.1.1 20070105 (Red Hat 4.1.1-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mod_python
>>> mod_python.version
'3.3.1'
>>>

4. Edit httpd.conf

<directory>
 AddHandler python-program .py
 PythonHandler TileCache.Service
 PythonOption TileCacheConfig /usr/local/apache2/htdocs/tilecache/tilecache.cfg
 PythonDebug On
 PythonPath "sys.path + ['/usr/local/apache2/htdocs/tilecache/']"
</directory>
 
<directory>
 AddHandler mod_python .py
 PythonHandler test
 PythonDebug On
</directory>

Note: This syntax will work for all versions of mod_python. In version 3.0 and later, the name of the mod_python handler reference has actually been changed and thus it is now preferred to use “mod_python” instead of “python-program”. The old name though is still supported and will be used here to avoid confusion for those using version 2.7.

5. Test your python

from mod_python import apache
 
def handler(req):
      req.log_error('handler')
      req.content_type = 'text/plain'
      req.send_http_header()
      req.write('mptest.py\n')
      return apache.OK

Installing Trac on CentOS4

June 27th, 2007 rupert 1 comment

There is a problem with clearsilver on CentOS systems. I get neo_cgi.so module not found. Don’t force yourself, it would simply not work (Trac0.10.4 on CentOS, not unless we try the DAG repositories).

So, I have to use Trac 0.11, setuptools and Genshi.

Prerequisites:
- Must have python 2.3+
- Must have mod_python-3.3.1.tgz
- Must have httpd2.0.x+ or httpd2.2.x

A. Core Trac Installation

1. Install setuptools-0.6c6-py2.3.egg. Download the setuptools according to your python distribution and simply run:

sh setuptools-0.6c4-py2.3.egg

2. Install Genshi. There are numerous ways of installing Genshi.

easy_install Genshi

or


#wget http://ftp.edgewall.com/pub/genshi/Genshi-0.4.2-py2.3.egg
#chmod +x Genshi-0.4.2-py2.3.egg
#easy_install Genshi-0.4.2-py2.3.egg

3. Install Trac 0.11. We need to install trac from svn
#svn co http://svn.edgewall.org/repos/trac/trunk trac
#python ./setup.py install

This would install trac-admin and tracd in /usr/bin.

Trac Post Intall

#mkdir -p /var/www/trac
#cd /var/www/trac
#trac-admin /var/www/trac/poimgr initenv
#chown -Rf nobody:root /var/www
#chmod -Rf 755 /var/www

Just accept the defaults for now, we can change it later on /var/www/trac/poimgr/conf/trac.ini.

C. Apache Configuration

LoadModule python_module /usr/local/apache2/modules/mod_python.so
 
<location>
SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonOption TracEnv /var/www/trac/poimgr
PythonOption TracUriRoot /trac/poimgr
#Order deny,allow
#Deny from all
#Allow from 192.168.1.0/24
AuthType Basic
AuthName "TRAC-POIMGR"
AuthUserFile "/repos/svn-auth-file"
require valid-user
</location>

Notes:
http://www.yolinux.com/TUTORIALS/LinuxSubversionAndTracServer.html

Depending on your installation, you may encounter some problems. I had problems with expat errors:


ExpatError (null): line 1,column 0.

Turns out that it was confused between the link libraries of apache and that of python.

#ps aux | grep http | head -3
#sof -p 29982 | grep expat
# strings libexpat.so.0.1.0 | grep expat_
expat_1.95.2
# strings /usr/lib/python2.3/lib-dynload/pyexpat.so | grep expat_
expat_1.95.7
 
Quickfix is to use symbolic links:
#cd /usr/local/apache2/lib/
#cp -Rf /usr/lib/libexpat.so.0.5.0 /usr/local/apache2/lib/
#ln -s libexpat.so.0.5.0 libexpat.so
#ln -s libexpat.so.0.5.0 libexpat.so.0
#su -l
#/etc/init.d/httpd restart

Configuring Trac.
1. I have to move /etc/svn-auth-file to /repos-auth-file. Change the permissions so “nobody” could access it.

2. How to configure my users? Well, since its an intranet application and my trac-users and developers is both in the svn-auth-file, I need a way to configure users easily. Follow these steps from trac-hack.

easy_install http://trac-hacks.org/svn/accountmanagerplugin/trunk

Role base authorisation in trac

trac-admin /var/www/trac/poiclient permission remove anonymous \
TICKET_CREATE TICKET_MODIFY WIKI_CREATE WIKI_MODIFY
 
for n in rupert andrew; do
trac-admin /var/www/trac/{app_name} permission add $n TRAC_ADMIN
done
 
for n in rupert andrew; do
trac-admin /var/www/trac/{app_name} permission add $n WIKI_DELETE
done
 
trac-admin /var/www/trac/poiclient permission add authenticated \
BROWSER_VIEW CHANGESET_VIEW FILE_VIEW LOG_VIEW MILESTONE_VIEW \
REPORT_SQL_VIEW REPORT_VIEW ROADMAP_VIEW SEARCH_VIEW \
TICKET_CREATE TICKET_MODIFY TICKET_VIEW TIMELINE_VIEW \
WIKI_CREATE WIKI_MODIFY WIKI_VIEW

3. Here’s my trac.ini. Things to look at is the notification and account-manager.

4. Deleting a Trac Ticket:

# sqlite3 trac.db
delete from ticket_custom where ticket = [ticketID];
delete from ticket_change where ticket = [ticketID];
delete from ticket where id = [ticketID];

Other References:
http://www.dscpl.com.au/wiki/ModPython/Articles/ExpatCausingApacheCrash
http://www.yolinux.com/TUTORIALS/LinuxSubversionAndTracServer.html
Trac and Multiple Subversion Repositories

Future Work:
http://insurrection.tigris.org/

Categories: linux, subversion Tags: , , , ,

HTTP access_log analysis

June 21st, 2007 rupert 2 comments

1. In order to report execution times, include a “%T” in your httpd.conf as follows:

    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %&gt;s %b %T" common
 
    <ifmodule>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </ifmodule>
 
    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a <virtualhost>
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per-</virtualhost><virtualhost> access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    CustomLog logs/access.log common
</virtualhost>

2. There are many log analysis softwares (webalizer, awstats, etc) out there, but most of them are outdated. I found this nifty little tool called visitor from www.hping.org. Freely distributed for unix but demo versions for windows build. Here’s a demo.

Categories: linux Tags:

Transparent Overlays in TileCache

March 31st, 2007 rupert Comments off

From the tilecache mailing list….

Hi Everyone,

Really appreciate all the replies…

1. Installed Imaging-1.1.6.tar.gz (PIL).

[root@rupert-linux ~]# python
Python 2.3.4 (#1, Mar 10 2006, 06:12:09) [GCC 3.4.5 20051201 (Red Hat 3.4.5-2)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import sys
&gt;&gt;&gt; print sys.path
['', '/usr/lib/python23.zip', '/usr/lib/python2.3', '/usr/lib/python2.3/plat-linux2', '/usr/lib/python2.3/lib-tk', '/usr/lib/python2.3/lib-dynload', '/usr/lib/python2.3/site-packages',
'/usr/lib/python2.3/site-packages/PIL',
'/usr/lib/python2.3/site-packages/gtk-2.0']
&gt;&gt;&gt;

2. Modified test1.cfm

     41         var options = {
     42                         controls: [new OpenLayers.Control.MouseDefaults()]
     43                       };
     44
     45         map = new OpenLayers.Map( $('map'), options);
     46
     47         var layer_base = new OpenLayers.Layer.WMS(
     48                     "Base Layer",
     49                     "#request.mapserv_tile#",
     50                     {
     51                         map: '/home/map/beijing/new/wms.map',
     52                         layers: '#request.basemap_tile#',
     53                         format: 'image/png', 'transparent': 'false'
     54                     }
     55                     );
     56
     57         var layer_road = new OpenLayers.Layer.WMS(
     58                     "Road Layer",
     59                     "#request.mapserv_tile#",
     60                     {
     61                         map: '/home/map/beijing/new/wms.map',
     62                         layers: '#request.roads_tile#',
     63                         format: 'image/png', 'transparent': 'true'
     64                     },
     65                     {
     66                         reproject: false
     67                     }
     68                     );
     69
     70         map.addLayer(layer_base);
     71         layer_base.setIsBaseLayer(true);
     72
     73         layer_road.setIsBaseLayer(false);
     74         map.addLayer(layer_road);

3. tilecache.cfg. Commented metaTile=true http://222.128.19.19/tilecache/tilecache.cfg

     47 [basemap]
     48 type=WMSLayer
     49 url=http://127.0.0.1/cgi-bin/mapserv?map=/home/map/beijing/new/wms.map
     50 layers=district,greens,major_river,minor_river
     51 #bbox=-180,-90,180,90
     52 #metaTile=true
     53 extension=png
     54
     55 [roads]
     56 type=WMSLayer
     57 url=http://127.0.0.1/cgi-bin/mapserv?map=/home/map/beijing/new/wms.map
     58 #layers=road4,road4label,road3,road3label,road2,road2label,road1,road1label,road11,road11label
     59 #bbox=116.1737,39.8211,116.5640,40.0799
     60 #maxresolution=1.40625
     61 #bbox=-180,-90,180,90
     62 layers=road1,road1label,road11,road11label
     63 extension=png
     64 #metaTile=true

4. Modified wms.map http://222.128.19.19/tilecache/wms.map

OUTPUTFORMAT
     NAME png
     DRIVER "GD/PNG"
     MIMETYPE "image/png"
     IMAGEMODE RGB
     EXTENSION "png"
     FORMATOPTION "INTERLACE=OFF"
END

5. Checked access_log. “transparent=true” exists…

192.168.1.150 - - [30/Mar/2007:13:46:26 +0800] "GET /tilecache/tilecache.py?MAP=%2Fhome%2Fmap%2Fbeijing%2Fnew%2Fwms.map&LAYERS=r
oads&FORMAT=image%2Fpng&TRANSPARENT=true&SERVICE=WMS&VERSION=1.1.1&REQUEST=G
etMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BB
OX=116.334229%2C39.891357%
2C116.345215%2C39.902344&WIDTH=256&HEIGHT=256 HTTP/1.1" 200 14580

Now, this is really weird. I have “transparent”: true in test1.cfm all the time. That didn’t worked.

For every test iteration i made, I always tried clearing the cache, removing the python compiled scripts, then restarting Apache just to get a clean state..


rm -Rf /usr/local/apache2/htdocs/tmp/*
rm /wwwroot/tilecache/TileCache/*.pyc
/etc/init.d/httpd restart

Then I tried appending “transparent=true” to tilecache.cfg based on Eric’s suggestion…
That worked. Now I wonder why… Nevertheless, its working now. Again many thanks to everyone…

Rupert

On Fri, Mar 30, 2007 at 01:57:43PM +0800, Rupert de Guzman Jr wrote:
> Hi Everyone,
>
> Really appreciate all the replies…
> Then I tried appending “transparent=true” to tilecache.cfg based on
> Eric’s suggestion…
> That worked. Now I wonder why… Nevertheless, its working now. Again
> many thanks to everyone…

TileCache pays almost no attention to the URL: Only the BBOX and the layername matter. Anything else is simply ignored: so your transparency being set in OpenLayers actually has 0 affect.

The reason for this is that TileCache can only store one copy of an image. If the URL parameters modified the content, you could get an inconsistent cache.

This is ‘by design’, insofar as there is no obvious solution (other than to complain more loudly when TC Gets parameters it isn’t expecting, which is an outstanding FIXME in the code). The lack of error message is not by design, and I’m sorry you got bit by the poorly documented behavior.

Regards,

Christopher Schmidt
MetaCarta

Verbose Installation of ColdFusion and Apache in Linux

January 18th, 2007 rupert Comments off

You would find all the installers here:

http://192.168.1.10/installers/

1. Edit hosts file as follows:

[root@appserver php]# more /etc/hosts

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               localhost.localdomain localhost
192.168.1.10            appserver

2. Edit your host as follows:
[root@appserver php]# more /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=appserver
GATEWAY=192.168.1.1

3. Apache:

http://192.168.1.10/installers/httpd-2.0.58.tar.gz

# tar -zxvf httpd-2.0.58.tar.gz
# cd httpd-2.0.58
# ./configure --help
# ./configure --prefix=/usr/local/apache2 --enable-so --with-mpm=prefork --enable-rewrite
# make
# make install

3.1 Starting apache2 on boot

#cd /usr/local/apache2/bin
#cp -Rf apachectl /etc/init.d/httpd

3.2 Edit httpd as follows

#cd /etc/init.d
#vi httpd

#!/bin/sh
# chkconfig: 35 80 15
# processname: httpd
# description: httpd
# Copyright 2000-2005 The Apache Software Foundation or its licensors, as
# applicable.

3.3 create runlevels for httpd

#/sbin/chkconfig --add httpd
#/sbin/chkconfig --level 345 httpd on
#/etc/init.d/httpd start

4. ColdFusion
4.1 Download http://192.168.1.10/installers/coldfusion-61-lin.bin
# chmod +x coldfusion-61-lin.bin

4.2 Run installer
# ./coldfusion-61-lin.bin

4.3 ColdFusion install:

Launching installer...
 
Preparing CONSOLE Mode Installation...
 
===============================================================================
Choose Locale...
----------------
 
  -&gt;1- English
 
CHOOSE LOCALE BY NUMBER: 1
 
DO YOU ACCEPT THE TERMS OF THIS LICENSE AGREEMENT?
    (Y/N) : Y
 
The installer has found the following errors/warnings:
 
Warning: C++ compatibility pack
 
The installer was unable to determine if the C++ compatibility pack is
installed by running the following command: rpm --query compat-libstdc++
If this machine uses a version of glibc that is 2.2.5.x or higher the
compatibility pack is necessary for C++ custom tags, Verity, and web server
connectors to work properly.
 
For more information see the installation manual at
http://www.macromedia.com/go/livedocs_cfmx61docs
 
PRESS  TO CONTINUE WITH THE INSTALLER:
 
===============================================================================
Existing Macromedia ColdFusion MX Installation?
-----------------------------------------------
 
You cannot install a new installation of Macromedia ColdFusion MX 6.1 if you
have an existing version of Macromedia ColdFusion MX installed on this
computer.
 
If you do have a previous version installed, the installer can update your
current current installation to Macromedia ColdFusion MX 6.1.
 
Is there already a version of Macromedia ColdFusion MX installed on this
   computer? (Y/N): N
===============================================================================
Install Type
------------
 
Choose the type of Macromedia ColdFusion MX installation you want to perform:
 
  -&gt;1- Install new version of ColdFusion MX
    2- 30-day trial (Enterprise Edition)
    3- Developer Edition (Single-IP Only)
 
Installation Choice: 1
 
Serial Number: CED600-18040-87264-92597
 
===============================================================================
Install Configuration
---------------------
 
What kind of installation do you want?
 
  -&gt;1- Server configuration
    2- J2EE configuration (ColdFusion MX with JRun 4)
    3- J2EE configuration (EAR file)
    4- J2EE configuration (WAR file)
 
Please choose one of the following options: 1
 
===============================================================================
Choose Install Folder
---------------------
 
Select the directory in which to install Macromedia ColdFusion MX.
 
Directory:
 
  Default Install Folder: /opt/coldfusionmx
 
ENTER AN ABSOLUTE PATH, OR PRESS  TO ACCEPT THE DEFAULT
: [just press enter]
 
===============================================================================
Existing ColdFusion 4.5 or 5 Installation?
------------------------------------------
 
The installer can migrate your settings from ColdFusion 4.5 or 5 if you have
an
installation on this computer.
 
Is there a version of ColdFusion 4.5 or 5 installed on this computer? (Y/N) N
 
===============================================================================
Configure Web Servers
---------------------
 
Please configure your webserver(s).  If you do not configure a webserver the
built-in webserver will be used on port 8500.
 
    1- Add Web Server Configuration
  -&gt;2- Continue with installation
 
Choice: 2
 
===============================================================================
Runtime User
------------
 
Enter the name of the runtime user.   This user must exist already on the
system.
 
User Name: (DEFAULT: nobody): [enter]
 
===============================================================================
Init System
-----------
 
Would you like ColdFusion MX to start at System Boot? Please note, this is
only supported on Solaris and Red Hat Linux. If you answer no to this, you can add
ColdFusion MX to system boot post install by running
/opt/coldfusionmx/bin/cfmx-init.sh
 
Answer (Y/N): Y
 
===============================================================================
Administrator Password
----------------------
 
Enter the password you will use to control access to the ColdFusion MX
Administrator.
 
This field is required.
 
Password:
Confirm Password:
 
===============================================================================
Installation Confirmation
-------------------------
 
Installation Type:
  Server configuration
 
Licensing:
  Fully Licensed Edition
  Serial Number: CED600-18040-87264-92597
 
Install Directories:
  Product: /opt/coldfusionmx
  Web root: /opt/coldfusionmx/wwwroot
 
Server Information:
  Web Server: Built-in Web Server
  Port: 8500
 
Disk Space Information (for Installation Target):
  Required: 433,293,879 bytes
  Available: 25,831,923,712 bytes
 
PRESS  TO CONTINUE:
[enter]
 
PRESS  TO CONTINUE:
 
===============================================================================
Installing...
-------------
 
 [==================|==================|==================|==================]
 [------------------|------------------|------------------|------------------]
 
===============================================================================
Installation Complete
---------------------
 
You have successfully completed the first step in installing Macromedia
ColdFusion MX.
 
To continue with your installation, go to /opt/coldfusionmx/bin and type
"./coldfusion start" to start your server.
 
Once the server is started log in to the Configuration Wizard at
http://[machinename]:8500/CFIDE/administrator/index.cfm
 
PRESS  TO EXIT THE INSTALLER:

5. Start coldfusion
# /etc/init.d/coldfusionmx start
Starting ColdFusion MX…
There may be a few moments before you can access the ColdFusion MX administrator. This is normal.
======================================================================
ColdFusion MX has been started.
ColdFusion MX will write logs to /opt/coldfusionmx/logs/cfserver.log
======================================================================

6. Bind ColdFusion with Apache.

$JAVA_EXECUTABLE -jar $CF_DIR/runtime/lib/wsconfig.jar \
        -ws apache \
        -dir /usr/local/apache2/conf \
        -bin /usr/local/apache2/bin/httpd \
        -script /usr/local/apache2/bin/apachectl \
        -coldfusion -v


[root@appserver /]# cd /opt/coldfusionmx/bin/connectors/
[root@appserver connectors]# ls
apache_connector.sh connectorslist.sh iplanet_connector.sh remove_all_connectors.sh upgrade_all_connectors.sh
[root@appserver connectors]# sh -v apache_connector.sh

You can check if your binding is successfull if you see the ff
messages:
 
Found JRun server default at 127.0.0.1:2901
CentOS release 4.4 (Final)
Detected Red Hat Linux release 7 or lower
Using Apache binary /usr/local/apache2/bin/httpd
Server version: Apache/2.0.58
Apache 2.0.58 is supported
Using Apache control script /usr/local/apache2/bin/apachectl
Parsing Apache configuration file /usr/local/apache2/conf/httpd.conf
Exec'ing chmod 777 /opt/coldfusionmx/runtime/lib/wsconfig/1
Set permission to 777 on /opt/coldfusionmx/runtime/lib/wsconfig/1
Exec'ing chmod +x /opt/coldfusionmx/runtime/lib/wsconfig/1/mod_jrun20.so
Set permission to execute on /opt/coldfusionmx/runtime/lib/wsconfig/1/mod_jrun20.so
Created file /opt/coldfusionmx/runtime/lib/wsconfig/1/mod_jrun20.so
Wrote file /usr/local/apache2/conf/httpd.conf
Added JRun configuration to Apache configuration file /usr/local/apache2/conf/httpd.conf
Created file /opt/coldfusionmx/runtime/lib/wsconfig/1/README.txt
Wrote file /opt/coldfusionmx/runtime/lib/wsconfig/wsconfig.properties
Exec'ing /usr/local/apache2/bin/apachectl restart
httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
Restarted Apache server
The Apache connector was installed to /usr/local/apache2/conf

7. Your httpd.conf file should contain the ff:

------------------------httpd.conf------------------------------
# NOTE: DO NOT ATTEMPT TO PUT THIS IN YOUR HTTPD.CONF MANUALLY.
LoadModule jrun_module /opt/coldfusionmx/runtime/lib/wsconfig/1/mod_jrun20.so
 
    JRunConfig Verbose false
    JRunConfig Apialloc false
    JRunConfig Ssl false
    JRunConfig Ignoresuffixmap false
    JRunConfig Serverstore /opt/coldfusionmx/runtime/lib/wsconfig/1/jrunserver.store
    JRunConfig Bootstrap 127.0.0.1:51010
    #JRunConfig Errorurl
    AddHandler jrun-handler .jsp .jws .cfm .cfml .cfc

8. Copy ColdFusion Administrator to your webroot
# cd /usr/local/apache2/htdocs
# rm -Rf *
# cp -Rf /opt/coldfusionmx/wwwroot/CFIDE .
# ln -s CFIDE cfide

Open your browse and point to: http://192.168.1.15/cfide/administrator/

9. CFADMIN settings:
- Check Disable RDS Services. Press Next
- Install Documents: Yes. Press Next
- OK

10. Copy cfdocs to webroot:
# cp -Rf /opt/coldfusionmx/wwwroot/cfdocs /usr/local/apache2/htdocs/

Categories: coldfusion Tags: , ,