Posts tagged: configuration

Ruby – internal configuration information

Ruby – to see Ruby internal configuration information

require 'rbconfig'
Config::CONFIG.inspect

More usefully, something like:

Config::CONFIG["prefix"]

List of properties:

  • DESTDIR
  • INSTALL
  • prefix
  • EXEEXT
  • ruby_install_name
  • RUBY_INSTALL_NAME
  • RUBY_SO_NAME
  • SHELL
  • PATH_SEPARATOR
  • PACKAGE_NAME
  • PACKAGE_TARNAME
  • PACKAGE_VERSION
  • PACKAGE_STRING
  • PACKAGE_BUGREPORT
  • exec_prefix
  • bindir
  • sbindir
  • libexecdir
  • datarootdir
  • datadir
  • sysconfdir
  • sharedstatedir
  • localstatedir
  • includedir
  • oldincludedir
  • docdir
  • infodir
  • htmldir
  • dvidir
  • pdfdir
  • psdir
  • libdir
  • localedir
  • mandir
  • ECHO_C
  • ECHO_N
  • ECHO_T
  • LIBS
  • build_alias
  • host_alias
  • target_alias
  • MAJOR
  • MINOR
  • TEENY
  • build
  • build_cpu
  • build_vendor
  • build_os
  • host
  • host_cpu
  • host_vendor
  • host_os
  • target
  • target_cpu
  • target_vendor
  • target_os
  • CC
  • CFLAGS
  • LDFLAGS
  • CPPFLAGS
  • OBJEXT
  • CPP
  • GREP
  • EGREP
  • GNU_LD
  • CPPOUTFILE
  • OUTFLAG
  • YACC
  • YFLAGS
  • RANLIB
  • AR
  • AS
  • ASFLAGS
  • NM
  • WINDRES
  • DLLWRAP
  • OBJDUMP
  • LN_S
  • SET_MAKE
  • INSTALL_PROGRAM
  • INSTALL_SCRIPT
  • INSTALL_DATA
  • RM
  • CP
  • MAKEDIRS
  • ALLOCA
  • DLDFLAGS
  • ARCH_FLAG
  • STATIC
  • CCDLFLAGS
  • LDSHARED
  • DLEXT
  • DLEXT2
  • LIBEXT
  • LINK_SO
  • LIBPATHFLAG
  • RPATHFLAG
  • LIBPATHENV
  • TRY_LINK
  • STRIP
  • EXTSTATIC
  • setup
  • MINIRUBY
  • PREP
  • RUNRUBY
  • EXTOUT
  • ARCHFILE
  • RDOCTARGET
  • XCFLAGS
  • XLDFLAGS
  • LIBRUBY_LDSHARED
  • LIBRUBY_DLDFLAGS
  • rubyw_install_name
  • RUBYW_INSTALL_NAME
  • LIBRUBY_A
  • LIBRUBY_SO
  • LIBRUBY_ALIASES
  • LIBRUBY
  • LIBRUBYARG
  • LIBRUBYARG_STATIC
  • LIBRUBYARG_SHARED
  • SOLIBS
  • DLDLIBS
  • ENABLE_SHARED
  • MAINLIBS
  • COMMON_LIBS
  • COMMON_MACROS
  • COMMON_HEADERS
  • EXPORT_PREFIX
  • MAKEFILES
  • arch
  • sitearch
  • sitedir
  • configure_args
  • NROFF
  • MANTYPE
  • ruby_version
  • rubylibdir
  • archdir
  • sitelibdir
  • sitearchdir
  • topdir
  • CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup}

Java – log4j configuration

Log4j is a widely-used Java logging package.

How does Log4j find configuration information?

From the Log4j Manual – Default initialization procedure

The log4j library does not make any assumptions about its environment. In particular, there are no default log4j appenders. Under certain well-defined circumstances however, the static inializer of the Logger class will attempt to automatically configure log4j. The Java language guarantees that the static initializer of a class is called once and only once during the loading of a class into memory. It is important to remember that different classloaders may load distinct copies of the same class. These copies of the same class are considered as totally unrelated by the JVM.

The default initialization is very useful in environments where the exact entry point to the application depends on the runtime environment. For example, the same application can be used as a stand-alone application, as an applet, or as a servlet under the control of a web-server.

The exact default initialization algorithm is defined as follows:

  1. Setting the log4j.defaultInitOverride system property to any other value then “false” will cause log4j to skip the default initialization procedure (this procedure).
  2. Set the resource string variable to the value of the log4j.configuration system property. The preferred way to specify the default initialization file is through the log4j.configuration system property. In case the system property log4j.configuration is not defined, then set the string variable resource to its default value “log4j.properties”.
  3. Attempt to convert the resource variable to a URL.
  4. If the resource variable cannot be converted to a URL, for example due to a MalformedURLException, then search for the resource from the classpath by calling org.apache.log4j.helpers.Loader.getResource(resource, Logger.class) which returns a URL. Note that the string “log4j.properties” constitutes a malformed URL. See Loader.getResource(java.lang.String) for the list of searched locations.
  5. If no URL could not be found, abort default initialization. Otherwise, configure log4j from the URL. The PropertyConfigurator will be used to parse the URL to configure log4j unless the URL ends with the “.xml” extension, in which case the DOMConfigurator will be used. You can optionaly specify a custom configurator. The value of the log4j.configuratorClass system property is taken as the fully qualified class name of your custom configurator. The custom configurator you specify must implement the Configurator interface.

From the Log4j Manual – Default initialization under Tomcat

The default log4j initialization is particularly useful in web-server environments. Under Tomcat 3.x and 4.x, you should place the log4j.properties under the WEB-INF/classes directory of your web-applications. Log4j will find the properties file and initialize itself. This is easy to do and it works. You can also choose to set the system property log4j.configuration before starting Tomcat. For Tomcat 3.x The TOMCAT_OPTS environment variable is used to set command line options. For Tomcat 4.0, set the CATALINA_OPTS environment variable instead of TOMCAT_OPTS. Example 1

The Unix shell command

   export TOMCAT_OPTS="-Dlog4j.configuration=foobar.txt"

tells log4j to use the file foobar.txt as the default configuration file. This file should be place under the WEB-INF/classes directory of your web-application. The file will be read using the PropertyConfigurator. Each web-application will use a different default configuration file because each file is relative to a web-application.

Example 2

The Unix shell command

   export TOMCAT_OPTS="-Dlog4j.debug -Dlog4j.configuration=foobar.xml"

tells log4j to output log4j-internal debugging information and to use the file foobar.xml as the default configuration file. This file should be place under the WEB-INF/classes directory of your web-application. Since the file ends with a .xml extension, it will read using the DOMConfigurator. Each web-application will use a different default configuration file because each file is relative to a web-application.

Example 3

The Windows shell command

   set TOMCAT_OPTS=-Dlog4j.configuration=foobar.lcf -Dlog4j.configuratorClass=com.foo.BarConfigurator

tells log4j to use the file foobar.lcf as the default configuration file. This file should be place under the WEB-INF/classes directory of your web-application. Due to the definition of the log4j.configuratorClass system property, the file will be read using the com.foo.BarConfigurator custom configurator. Each web-application will use a different default configuration file because each file is relative to a web-application.

Example 4

The Windows shell command

   set TOMCAT_OPTS=-Dlog4j.configuration=file:/c:/foobar.lcf

tells log4j to use the file c:\foobar.lcf as the default configuration file. The configuration file is fully specified by the URL file:/c:/foobar.lcf. Thus, the same configuration file will be used for all web-applications.

Different web-applications will load the log4j classes through their respective classloaderss. Thus, each image of the log4j environment will act independetly and without any mutual synchronization. For example, FileAppenders defined exactly the same way in multiple web-application configurations will all attempt to write the same file. The results are likely to be less than satisfactory. You must make sure that log4j configurations of different web-applications do not use the same underlying system resource.

Initialization servlet

It is also possible to use a special servlet for log4j initialization. Here is an example,

package com.foo;

import org.apache.log4j.PropertyConfigurator;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.io.IOException;

public class Log4jInit extends HttpServlet {

  public
  void init() {
    String prefix =  getServletContext().getRealPath("/");
    String file = getInitParameter("log4j-init-file");
    // if the log4j-init-file is not set, then no point in trying
    if(file != null) {
      PropertyConfigurator.configure(prefix+file);
    }
  }

  public
  void doGet(HttpServletRequest req, HttpServletResponse res) {
  }
}

Define the following servlet in the web.xml file for your web-application.

  <servlet>
    <servlet-name>log4j-init</servlet-name>
    <servlet-class>com.foo.Log4jInit</servlet-class>

    <init-param>
      <param-name>log4j-init-file</param-name>
      <param-value>WEB-INF/classes/log4j.lcf</param-value>
    </init-param>

    <load-on-startup>1</load-on-startup>
  </servlet>

Writing an initialization servlet is the most flexible way for initializing log4j. There are no constraints on the code you can place in the init() method of the servlet.

Apache 2 + FastCGI

Some build things ….

Apache2 needs the following flags set on the build

[To be filled in]

So does FastCGI itself.

Some configuration things …

Script Directory

Start at the root of the directory tree (“/”) that contains any directory using an ALIAS or SCRIPTALIAS directive. Every directory in the tree must be readable to the Apache2 server, usually running as “www:www”. This means read and execute permissions ( ‘o+rx’) for the world for every directory in the tree.

ALIAS vs SCRIPTALIAS

Appears to matter for CGI, but oddly enough, not for FCGI. Go figure.

IPC Directory

The IPC directory set by the required directive:

FastCgiIpcDir /var/run/fcgi

must have read and write permission to the Apache2 user, “www:www”. The easiest thing is to make ‘www:www” the user, and specify “u+rwx”.

File extensions

You need to make sure that the extension specified for the FCGI handler – normally .fcgi – matches that used for the files themselves.

Example

# /var/run/fcgi needs to have write permission for user www:www (see main file)
FastCgiIpcDir /var/run/fcgi
LoadModule fastcgi_module modules/mod_fastcgi.so
#AddHandler fastcgi-script .fcgi

#ScriptAlias /test/ “/home/jay/test_apache2/”
Alias /test/ “/home/jay/test_apache2/”

<Directory “/home/jay/test_apache2/”>
Options All
AllowOverride All
Order allow,deny
Allow from all
<IfModule mod_fastcgi.c>
AddHandler fastcgi-script .fcgi
</IfModule>
</Directory>

Apache 2 – Configuration and build

Configuration options that seem to make Apache2 and Ruby on Rails happy

./configure \
–enable-rewrite=yes \
–enable-dav=yes \
–enable-suexec \
–with-suexec-docroot=/usr/local/apache2/htdocs \
$@

PHP4 – Configuration and build

'./configure' \
'--prefix=/Library/PHP4' \
'--with-apxs2=/Library/Apache2/bin/apxs' \
'--with-openssl=/usr' \
'--with-zlib=/usr' \
'--enable-calendar'  \
'--enable-shared'  \
'--enable-exif' \
'--enable-ftp'  \
'--enable-mbstring'  \
'--enable-mbregex'  \
'--enable-session'  \
'--enable-sockets'  \
'--enable-tokenizer'  \
'--enable-wddx'  \
'--with-xml'  \
'--enable-yp'  \
'--enable-versioning'  \
'--enable-trans-id'  \
'--enable-track-vars'  \
'--with-mysql=/Library/PHP4'  \
'--with-ldap=/usr'  \
'--with-iodbc=/Library/PHP4' \
'--with-gd'  \
'--with-jpeg-dir=/Library/PHP4'  \
'--with-png-dir=/Library/PHP4'  \
'--enable-xslt'  \
'--with-xslt-sablot=/Library/PHP4'  \
'--with-pdflib=/Library/PHP4'  \
'--with-tiff-dir=/Library/PHP4'  \
'--with-pgsql=/Library/PHP4'  \
'--with-iconv'  \
'--with-sybase=/Library/PHP4'  \
'--with-mcrypt=/Library/PHP4'  \
'--with-curl=/usr'  \
'--with-freetype-dir=/Library/PHP4'  \
'--with-ttf=/Library/PHP4'  \
'--with-gettext=/Library/PHP4'  \
'--with-xmlrpc' ' \
--with-mime-magic' ' \
--with-pspell=/Library/PHP4' '\
--with-expat-dir=/Library/Apache2' '
--with-t1lib=/Library/PHP4'
'--enable-dbx' '
--with-imap=/Library/PHP4' '
--with-imap-ssl=/usr' '
--enable-cli' '
--without-xpm-dir' '
--enable-dbase' '
--with-bz2=/usr' '
--enable-cgi' '
--with-pear' '
--with-java' '
--with-dom=/Library/PHP4' '
--with-dom-xslt=/Library/PHP4' '
--with-dom-exslt=/Library/PHP4' '
--with-snmp=/Library/PHP4' '
--enable-ucd-snmp-hack' '
--with-mhash=/Library/PHP4' '
--with-ming=/Library/PHP4' '
--with-pear' '
--enable-shmop' '
--with-mcal=/Library/PHP4' '
--with-gmp=/Library/PHP4' '
--enable-dio' '
--enable-bcmath' '
--enable-ctype' '
--enable-dba' '
--with-cdb' '
--enable-gd-native-ttf' '
--with-zip=/Library/PHP4'

Setting up XP system from scratch

Install XP

Install XP from CD
Reformat everything

Run Windows Update

Get stuff to reinstall

Access a network share

Network shares are specified as ‘\\192.168.1.101\tracy`

Turn off bubbles

To Disable The Notification Area Balloon Tips
Warning If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that you can solve problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk.
1.    Click Start, click Run, type regedit, and then press ENTER.
2.    Navigate to the following subkey:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced
3.    Right-click the right pane, create a new DWORD value, and then name it EnableBalloonTips.
4.    Double-click this new entry, and then give it a hexadecimal value of 0.
5.    Quit Registry Editor. Log off Windows, and then log back on.
These steps disable all Notification Area balloon tips for this user. There is no way to disable balloon tips for specific programs only.

Disable Compressed Folders

Click Start > Run…
Type regsvr32 /u C:\windows\system32\zipfldr.dll
Click the OK button.

lighttpd – Rails configuration

server.port = 81
server.bind = “127.0.0.1″
server.event-handler = “freebsd-kqueue”
server.modules = ( “mod_rewrite”, “mod_fastcgi”)
url.rewrite = ( “^/$” => “index.html”, “^([^.]+)$” => “$1.html”)
server.error-handler-404 = “/dispatch.fcgi”
server.document-root = “”
server.errorlog = “/log/server.log”
fastcgi.server = ( “.fcgi” =>
( “localhost” =>
(
“min-procs” => 10,
“max-procs” => 10,
“socket” => “/tmp/application.fcgi.socket”,
“bin-path” => “/public/dispatch.fcgi”,
“bin-environment” => ( “RAILS_ENV” => “production”)
)

)

)

SSH – Avoiding Timeouts

In your ./.ssh/config file

ConnectTimeout 0

Host *
ServerAliveInterval 120
ServerAliveCountMax 3

RedHat 4 (ES) – Configuration

Conventions

I have adopted the following directory convention:

- All untouched downloads for software installed on the system

/usr/local/downloads

- Source builds (all .tar and other intermediate unpack files should be removed)

/usr/local/src

DNS Servers

BIND Requires something other than installed version of OpenSSL. So, build OpenSSL first.

Install OpenSSL

wget http://www.openssl.org/source/openssl-0.9.8d.tar.gz
gunzip openssl-0.9.8d.tar.gz
tar xf openssl-0.9.8d.tar.gz
cd openssl-0.9.8d

# These options are VITAL to make the BIND build work

./config –prefix=/usr/local –openssldir=/usr/local/openssl
make
sudo make install

Install BIND

wget http://ftp.isc.org/isc/bind9/9.3.2-P1/bind-9.3.2-P1.tar.gz
gunzip bind-9.3.2-P1.tar.gz
tar xf bind-9.3.2-P1.tar
cd bind-9.3.2-P1

# These options are VITAL to make the build work with the correct version of OpenSSL
./configure –prefix=/usr/local –sysconfdir=/etc –localstatedir=/var –disable-threads –with-openssl=/usr/local
make
sudo make install

Configure BIND

# Startup command to run ‘named’ as a daemon
# Need to investigate whether any of the options are really needed.
/usr/local/sbin/named -4 -c /etc/named.conf

# Install startup script into Linux system startup – init.d model
# The startup file is in source control under …

#/sbin/chkconfig –levels 35 named on
Configure BIND

# Configuration files are stored in source control under ……

/etc/named.conf
/var/named/master/*

# Create required directories – make sure the directories and files are only root-readable – i.e. mode ’700′

/var/named
/var/named/master
/var/named/data
/var/named/keys

# Generate keys and paste into appropriately named key files in /var/named/keys

/usr/local/sbin/rndc-confgen -k rndc-local.key
/usr/local/sbin/rndc-confgen -k rndc-internal.key

# Paste output that looks like the following into /var/named/keys/rndc-local.key and /var/named/keys/rndc-internal.key

#key “rndc-local.key” {
#       algorithm hmac-md5;
#        secret “v0TXaA6JvrUM4v/1hYpGOQ==”;
#};

Add a line to /etc/hosts similar to:

10.1.10.50      eng.helium.com

Make sure that /etc/resolv.conf starts with a line similar to

nameserver 10.1.10.50

Make sure that /etc/nsswitch.conf  has a line similar to

hosts:      files dns

in which ‘files’ precedes ‘dns’

Run BIND

# Startup command to run ‘named’ as a daemon
# Need to investigate whether any of the options are really needed.
/usr/local/sbin/named -4 -c /etc/named.conf

# Install startup script into Linux system startup – init.d model
# The startup file is in source control under …

#/sbin/chkconfig –levels 35 named on

WordPress Themes