By Rupert
Posts tagged apache
HTTP access_log analysis
Jun 21st
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\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b %T" common
<ifmodule>
# You need to enable mod_logio.c to use %I and %O
LogFormat "%h %l %u %t \"%r\" %>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.
Hiding and protecting CFM
Jun 8th
With recent client developments, I fiddled my way on how to protect IPR of my cfc/cfm source codes. Two tasks in mind was to hide the cfm extension from Apache and precompile the CF source files (cfm/cfc).
Hiding the cfm extension courtesy of PeterBell
1. Add the desired extension in httpd.conf
# JRun Settings
LoadModule jrun_module "D:/CFusionMX7/runtime/lib/wsconfig/1/mod_jrun22.so"
<ifmodule>
JRunConfig Verbose false
JRunConfig Apialloc false
JRunConfig Ssl false
JRunConfig Ignoresuffixmap false
JRunConfig Serverstore "D:/CFusionMX7/runtime/lib/wsconfig/1/jrunserver.store"
JRunConfig Bootstrap 127.0.0.1:51011
#JRunConfig Errorurl <optionally>
#JRunConfig ProxyRetryInterval 600
#JRunConfig ConnectTimeout 15
#JRunConfig RecvTimeout 300
#JRunConfig SendTimeout 15
AddHandler jrun-handler .cfm .cfml .cfc .cfr .cfswf .rup
</optionally>
</ifmodule>2. In C:\CFusionMX7\wwwroot\WEB-INF\web.xml
<servlet -mapping id="macromedia_mapping_14"> </servlet><servlet -name>CfmServlet</servlet> <url -pattern>*.rup</url>
3. Restart Apache and ColdFusion.
Re-compile templates for sourceless deployment..
1. Applications can now be distributed without the underlying source code. Run cfcompile as follows…
cfcompile -deploy webroot directory-to-compile output-directory
2. Compiled CF code goes into [cfusionmx]\wwwroot\WEB-INF\cfclasses. CFMX compiles and runs the code from this cfclasses directory, regardless of the location of the source file.
3. To see the generated Java code, Edit the file [cfusionmx]\wwwroot\WEB-INF\web.xml. Change “coldfusion.compiler.saveJava” from false to true. Restart the CF server.
4. Bottomline enable trusted cache on CFADMIN for production environments.
Main Reference:
Compilation and Precompilation in CFMX Templates By Charlie Arehart
Deploying Applications with ColdFusion MX 7 By Dave Carabetta
Future readings include EAR/WAR Deployment…
Transparent Overlays in TileCache
Mar 31st
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. >>> import sys >>> 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'] >>>
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"
END5. 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
Jan 18th
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... ---------------- ->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: ->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? ->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 ->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/
TileCache for Windows Revisited
Jan 17th
1. Downloaded TileCache1.8 from http://www.tilecache.org/
2. Get the current releases of python and mod_python.
http://www.python.org/download/releases/2.5/
http://httpd.apache.org/modules/python-download.cgi -> click on win32 binaries. Get the mod_python-3.3.1.win32-py2.5-Apache2.2.exe if your Apache is running on 2.2.
http://www.pythonware.com/products/pil/
http://effbot.org/downloads/PIL-1.1.6.win32-py2.5.exe
3. Install python2.5
4. Install mod_python and python_imaging.
5. Edit httpd.conf
LoadModule python_module modules/mod_python.so <directory> AddHandler python-program .py PythonHandler test PythonDebug On </directory> <directory> AddHandler python-program .py .cgi PythonHandler TileCache.Service PythonOption TileCacheConfig /wwwroot/tilecache/tilecache.cfg PythonDebug On </directory> ScriptInterpreterSource Registry SetEnv PYTHONUNBUFFERED 1 PassEnv PYTHONPATH
6. run regedit. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.4\PythonPath. Append “E:\wwwroot\tilecache” to PYTHONPATH
D:\Python24\Lib;D:\Python24\DLLs;D:\Python24\Lib\lib-tk;E:\wwwroot\tilecache;
7. Put D:\Python24 in your WINDOWS PATH
8. Test if apache could read python by http://127.0.0.1/pytest/test.py
9. http://127.0.0.1/tilecache/test1.cfm
10. tilecache_seed.py “http://127.0.0.1/tilecache/tilecache.py” roads 12 17 “116.28229,39.85291,116.48657,39.98783″
Comments