Installing Tomcat 6 on a cPanel Server


The cPanel EasyApache system makes it easy to recompile Apache with various add-ons and modules. There’s even a checkbox for adding Tomcat. Unfortunately, this installs Tomcat 5.5, and I needed Tomcat 6.0. Here’s how I got it:

1) install Tomcat 5.5 using EasyApache (see this .pdf for details)

2) download and expand Tomcat 6 in /usr/local/jakarta

3) change the tomcat symlink to point to your new version (i.e. /usr/local/jakarta/apache-tomcat-6.0.XX)

4) from http://trulymanaged.com/blog/installation-of-tomcat6/:

#cd apache-tomcat-6.0.18
# cd bin
# tar xvfz jsvc.tar.gz
# cd jsvc-src
# chmod +x configure
# ./configure
# make
# cp jsvc ..
# cd ..

5) copy over any Host blocks from tomcat/conf/server.xml from the old Tomcat install to the new Tomcat install (you may or may not be able to set up new hosts through WHM)

6) copy over conf/workers.properties from the old Tomcat install to the new Tomcat install

7) start tomcat normally (/usr/sbin/starttomcat)

The /manager/html/ Tomcat manager application doesn’t load, though, so it’s not perfect.

If you ever need your old Tomcat back just stop Tomcat, flip the tomcat symlink back to the old install, and restart Tomcat.



Dreamhost to Google Apps naked domain name redirection


I’ve had this problem twice in recent memory, which warrants taking notes.

Dreamhost has a handy “Google Hosted” feature where with a single click they’ll completely configure your domain to use Google Apps. You can then use Google Sites and the rest of the Apps suite for your entire website. Unfortunately, while Google Sites allows you to map a subdomain to a Google Site page, mapping naked domains (e.g. example.com) are not supported. If one maps the www subdomain to a Google Site then the traditional www.example.com will resolve, but example.com gives a Google-served 404 error. When using the Dreamhost “Google Hosted” feature all of the generated domain DNS records are non-editable, so you’re stuck with an A record which maps the domain to a nonexistent site.

My solution was to not use the Dreamhost “Google Hosted” feature at all, but to instead use the “DNS Only” option. I copied down all the generated DNS entries from the “Google Hosted” setup and manually recreated them, with one exception. The A record for the naked domain I directed to 174.129.25.170, which is the IP address of WWWizer, a free service which handily redirects any naked domain request the the corresponding www subdomain.

Now I have a site set up on my www subdomain with Google footing the hosting bill, and naked domain requests are seamlessly redirected to the www-based home page.



Enabling chat outside Google Apps


Google Apps users can chat with other users on the Google Talk network, but it’s also possible to set up federation on your domain to allow your users to chat with anyone using the XMPP protocol.

The Google Help page on the topic, at http://www.google.com/support/a/bin/answer.py?hl=en&answer=34143, is pretty weak. “If you require assistance making these changes in your domain host account”, they offer, “we suggest contacting your domain host.”

The change involves adding SRV DNS records for your domain. The records to be added are:

_xmpp-server._tcp.gmail.com. IN SRV 5 0 5269 xmpp-server.l.google.com.
_xmpp-server._tcp.gmail.com. IN SRV 20 0 5269 xmpp-server1.l.google.com.
_xmpp-server._tcp.gmail.com. IN SRV 20 0 5269 xmpp-server2.l.google.com.
_xmpp-server._tcp.gmail.com. IN SRV 20 0 5269 xmpp-server3.l.google.com.
_xmpp-server._tcp.gmail.com. IN SRV 20 0 5269 xmpp-server4.l.google.com.
_jabber._tcp.gmail.com. IN SRV 5 0 5269 xmpp-server.l.google.com.
_jabber._tcp.gmail.com. IN SRV 20 0 5269 xmpp-server1.l.google.com.
_jabber._tcp.gmail.com. IN SRV 20 0 5269 xmpp-server2.l.google.com.
_jabber._tcp.gmail.com. IN SRV 20 0 5269 xmpp-server3.l.google.com.
_jabber._tcp.gmail.com. IN SRV 20 0 5269 xmpp-server4.l.google.com.

where gmail.com is replaced by your apps domain name.

Wikipedia takes a SRV record in the form

_sip._tcp.example.com. 86400 IN SRV 0 5 5060 sipserver.example.com.

and breaks it down thusly:

_Service._Proto.Name TTL Class SRV Priority Weight Port Target

Where:

  • Service: the symbolic name of the desired service.
  • Proto: the transport protocol of the desired service; this is usually either TCP or UDP.
  • Name: the domain name for which this record is valid.
  • TTL: standard DNS time to live field.
  • Class: standard DNS class field (this is always IN).
  • Priority: the priority of the target host, lower value means more preferred.
  • Weight: A relative weight for records with the same priority.
  • Port: the TCP or UDP port on which the service is to be found.
  • Target: the canonical hostname of the machine providing the service.

Taking the first of the Google provided record definitions as an example,

_xmpp-server._tcp.gmail.com. IN SRV 5 0 5269 xmpp-server.l.google.com.

we have:

  • Service: xmpp-server
  • Proto: tcp
  • Name: gmail.com.
  • TTL: (none given)
  • Class: IN
  • Priority: 5
  • Weight: 0
  • Port: 5269
  • Target: xmpp-server.l.google.com.

where, again, gmail.com is replaced by your Google Apps domain.

My DNS settings provider doesn’t offer a “Name” field while adding SRV records; instead they have a “Record/Hostname” field where the domain fixed but with the opportunity to enter a subdomain. This is usually not necessary with Google Apps, unless your primary Google Apps domain is actually a subdomain. For me I just left the “Record/Hostname” field blank and the “Name” was set correctly.

You can test that your new SRV records were created correctly using dig:

dig SRV _xmpp-server._tcp.gmail.com

You should get back, in the ANSWER SECTION, just what the Google Help page listed for that service (with a TTL added):

_xmpp-server._tcp.gmail.com. 86400 IN SRV 20 0 5269 xmpp-server1.l.google.com.
_xmpp-server._tcp.gmail.com. 86400 IN SRV 20 0 5269 xmpp-server2.l.google.com.
_xmpp-server._tcp.gmail.com. 86400 IN SRV 20 0 5269 xmpp-server3.l.google.com.
_xmpp-server._tcp.gmail.com. 86400 IN SRV 20 0 5269 xmpp-server4.l.google.com.
_xmpp-server._tcp.gmail.com. 86400 IN SRV 5 0 5269 xmpp-server.l.google.com.

If you don’t want to wait for the DNS updates to propagate you can ask your domains name server directly:

dig @69.28.203.75 SRV _xmpp-server._tcp.gmail.com

Where 69.28.203.75 is replaced with the IP address of your domains name server.



Shell Script


A fun little shell script:

:(){:|:&};:



DVD Backups


DVD Decrypter faithfully copies disks to drives. Mode ISO > Read will produce an .iso of a disk; a double-layer disk will produce an 8GB .iso. The File mode just copies all the files as is straight from the disk into a VIDEO_TS folder. DVD Decrypter looks like it can also burn .isos by changing the Mode to ISO > Write, but I haven’t tried it yet.

ImgBurn is great for burning .iso files to a DVD. Just insert a DVD, choose your source file, and click the button.

DVD Shrink will create a 4GB .iso from a double-layer disk!

See:

http://lifehacker.com/5444274/five-best-dvd+ripping-tools

http://lifehacker.com/5446090/best-dvd+ripping-tool-handbrake

http://lifehacker.com/208866/hack-attack-one+click-dvd-rips

http://www.softpedia.com/get/CD-DVD-Tools/CD-DVD-Rip-Other-Tools/DVD-Shrink.shtml

http://paininthetech.com/2006/04/30/how-to-back-up-a-dvd



Reusing stdout


stdout is nice–it let’s you see what’s going on. But what if you want to see what’s going on and also do something else with the same output.

tee is useful for redirecting stdout to a file, but what if you want to send the same output to another command too, like mail?

You disguise the command as a file, that’s what. Through process substitution you can say things like

echo "hello world" | tee >(mail -s "notice")

and have the message go to stdout and your mail program. You can chain process substitutions to do as many different things with the same output as you want.

Process substitution is supported in bash and friends, but not, as far as I can see, in sh.



Ubuntu Personal Package Archives


Personal Package Archives make it easy for anyone to make software available through the apt system without the need to be accepted into the official repository. You can simply create a PPA and other people can add, or subscribe to them. Updates pushed to a PPA show up in users Update Managers alongside all of the official updates. Ubuntu 9.10 makes PPAs easier than ever before. To add the PPA for Ubuntu Chromium – Dev Channel, just say

sudo add-apt-repository ppa:chromium-daily/dev

A few PPAs I like are



MySQL InnoDB tables vs. MyISAM tables


MySQL has multiple ways in which it can store your data, called storage engines. The two most commonly used engines are MyIASM and InnoDB; I have a hard time remembering which I wanted to use, and answering people when they ask why I used the type I did. So…

InnoDB tables support foreign keys; MyISAM does not. (ref)

“Full-text indexes can be used only with MyISAM tables”. (ref)

InnoDB supports transactions! Note autocommit is set by default. (ref)

Because MyISAM tables are non-transaction-safe they may be smaller, faster, and require less memory to update (ref).

The InnoDB engine also supports Clustered indexes, Data caches, and has finer locking granularity than MyISAM, although MyISAM does have something called “Geospatial indexing support.”

The official summaries:

MyISAM — The default MySQL storage engine and the one that is used the most in Web, data warehousing, and other application environments. MyISAM is supported in all MySQL configurations, and is the default storage engine unless you have configured MySQL to use a different one by default.

InnoDB — A transaction-safe (ACID compliant) storage engine for MySQL that has commit, rollback, and crash-recovery capabilities to protect user data. InnoDB row-level locking (without escalation to coarser granularity locks) and Oracle-style consistent non-locking reads increase multi-user concurrency and performance. InnoDB stores user data in clustered indexes to reduce I/O for common queries based on primary keys. To maintain data integrity, InnoDB also supports FOREIGN KEY referential-integrity constraints.



My First Mac


A little shy of a year ago I got my first Mac. I figured it would work well for business use: easy access to the command line and Unix core, but not requiring the fussing that Linux does.

Some things are surprisingly easy on the Mac:

  • set up desktop background image rotation
  • remap the keyboard (eg. capslock to control)
  • building presentations in Keynote

Many things are just downright impossible on the Mac:

  • open in one space an application which is already open in another space
  • alt-tab through applications just in the current space
  • hit the control key with your right hand (there is no control key on the right side of the keyboard)
  • change your username (you better get it right the first time)
  • eject a cd without powering on the computer (there is no pinhole eject)
  • resize a window from anywhere but the very bottom right-hand corner of the window (really annoying when that corner is off the screen or you just want to make a window taller)
  • “right-click” using just the keyboard (most laptops have a “right-click” key)
  • directly access a particular menu bar menu using just the keyboard
  • open a playlist in iTunes
  • use the keyboard to jump to the end of a row or column in Numbers
  • open a .log or .tab file in Numbers

Other annoyances:

  • closing the last window of a program doesn’t end the program
  • the program “Finder” is always open and running
  • although program windows can be moved to separate virtual desktops alt+tab always cycles through all open programs
  • ships with old versions of common UNIX tools such as grep

Things that are just kind of weird:

  • keyboard shortcuts are all rearranged

Configuration

Fix function keys
System Preferences -> Keyboard & Mouse -> Keyboard -> Use all F1, F2, etc. keys as standard function keys
Set touchpad tap to click
System Preferences -> Keyboard & Mouse -> Trackpad -> Tap to Click
set mouse to be two-button
System Preferences -> Keyboard & Mouse -> Mouse -> Secondary Button
Enable Secondary Click
System Preferences -> Keyboard & Mouse -> Trackpad -> Secondary Click
set mouse middle click to be button three
System Preferences -> Keyboard & Mouse -> Mouse -> Button 3
Set tracking speed (trackpad)
System Preferences -> Keyboard & Mouse -> Trackpad -> adjust Tracking Speed to Fast
Set tracking speed (mouse)
System Preferences -> Keyboard & Mouse -> Mouse -> adjust Tracking Speed to Fast
Enable Spaces
System Preferences -> Expose & Spaces -> Spaces -> Enable Spaces
Non-schizophrenic Zoom
System Preferences -> Keyboard & Mouse -> Trackpad -> Screen Zoom Options -> Only when the pointer reaches an edge
Allow browser to tab into all form elements
System Preferences -> Keyboard & Mouse -> Keyboard Shortcuts -> All Controls
Disable F-key hijacking
System Preferences -> Keyboard & Mouse -> Keyboard Shortcuts (uncheck as necessary)
Fix screen from auto-dimming every 1-2 minutes
Allow TextEdit to save .txt plaintext files
TextEdit -> Preferences -> Plain text
Date in Munu Bar
Use iStat Menus
Replace obsolete grep
Just download, build, install, and replace /usr/bin/grep with the new binary.

Some things you’ll need to know:
- Default document root is /Library/WebServer/Documents

Software

Cyberduck
For FTPing
Adium
All-purpose IM client
Eclipse
Firefox
Of course
GIMP
(but which build?)
Picasa
Otherwise there is no way to get photos off my digital camera
Skitch
The ultimate screenshot utility–more useful than you might think
Transmission>
For downloading large files quickly
VMWare Fusion

MacPorts Stuff

HexEdit
wget
phpMyAdmin
Subversion
MySQL

Start MySQL with /opt/local/lib/mysql5/bin/mysqld_safe &

The MySQL socket file is at /opt/local/var/run/mysql5/mysqld.sock

To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system

Apache

Document root is /opt/local/apache2/htdocs

The Apache config file is /opt/local/apache2/conf/httpd.conf

Comment out LoadModule ssl_module modules/mod_ssl.so in httpd.conf, since that seems to be broken in the MacPorts install.

Add these to your mimetypes:

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Add index.php to the DirectoryIndex:


DirectoryIndex index.html index.php

alias apache2ctl='sudo /opt/local/apache2/bin/apachectl' and apache2ctl start to get started!

###########################################################
# A startup item has been generated that will aid in
# starting apache2 with launchd. It is disabled
# by default. Execute the following command to start it,
# and to cause it to launch at startup:
#
# sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist
###########################################################


CodeIgniter Setup


CodeIgniter is a small and fast PHP framework. Not all of these steps are necessary to use the framework, but they result in a more secure setup where none of the framework files are ever web accessible.

  1. Download the .zip
  2. Create a public/ directory at the same level as the system/ directory containing asset directories: mkdir public public/images public/javascripts public/stylesheets
  3. Move the index.php file into the public/ directory: mv index.php public
  4. Edit the index.php file to reflect it’s new location: :%s/$system_folder = "system";/$system_folder = "..\/system";/
  5. Inside of system/application/config/config.php:
    1. Set the 'base_url' to your sites URL
    2. Clear the 'index_page' config (set it to the empty string)
    3. 'enable_query_strings' if necessary
    4. Adjust the 'log_threshold'
    5. Choose a unique 'encryption_key'
    6. Turn 'sess_encrypt_cookie' on
    7. At the end of config.php add:
      // optionally load (and potentially override) additional config values
      if (file_exists('../system/application/config/config.local.php'))
      {
          include('config.local.php');
      }
  6. Create (and promptly SVN ignore, if applicable) a config.local.php file. The file will usually only contain overrides for ‘base_url’, ‘index_page’, ‘log_threshold’, and ‘log_path’.
  7. Fill out the database.php config file as necessary, potentially with a companion database.local.php file as well.
  8. If you wish to remove the index.php from you URLs, create a .htaccess file like so:
    RewriteEngine On
    RewriteCond $1 !^(index\.php|images|stylesheets|javascripts|favicon\.ico|robots\.txt)
    RewriteRule ^(.*)$ /fresh/index.php/$1 [L]
  9. Point your document root to the new public/ directory and you’re off!
Next Page »

powered by WordPress     themed by Mukkamu     presented by ideaharbor.org     everything else by steve hulet