Tag Archive for 'technology'Page 2 of 5

Effortlessy switching between php4 and php5 for web development

I want to test my software on both php4 and php5 quickly and easily. Here’s the solution I came up with.

First, take out everything regarding php out of your main apache config. LoadModule phpX_module ..., AddModule mod_phpX.c, and anything else.

Next, make three files in the same directory as your apache config (/etc/httpd/ on OS X):

php4.conf

LoadModule php4_module        /usr/local/php/libphp4.so
AddModule mod_php4.c
Include /etc/httpd/php_stuff.conf

php5.conf

LoadModule php5_module        libexec/httpd/libphp5.so
AddModule mod_php5.c
Include /etc/httpd/php_stuff.conf

php_stuff.conf

AddType application/x-httpd-php .php

<IfModule mod_dir.c>
  DirectoryIndex index.html index.php
</IfModule>

Now add this line to the bottom of your httpd.conf:

Include /etc/httpd/php.conf

Now make the following two shell scripts and put them somewhere like ~/bin:

p4

cp /etc/httpd/php4.conf /etc/httpd/php.conf
apachectl graceful

p5

cp /etc/httpd/php5.conf /etc/httpd/php.conf
apachectl graceful

Ta da! Now to switch between php4 and php5, you can just do sudo p4 and sudo p5.

It would be nice to even tie this into an applescript with some sort of dock or even menu bar presence… if anyone has any tips on how this might be done let me know.

Programmer needed in Austin

My friend Zane is hiring a programmer in Austin.

Lyceum Public Beta

In preparation for the formal announcment and code release at the end of this month, the Lyceum team is running a public test intallation of the code. Check it out:

Lyceum Public Beta

The front page explains everything. Basically, sign up for a blog (or several), write posts, adjust settings, comment on other people’s blogs, and then send bug reports to lyceum-bugs AT lists DOT ibiblio DOT org.

Guide to Bash config files

I’ve put together a guide to Bash config files. Check it out and let me know what you think.

How to install Trac on RHEL 3

Trac + RHEL = pain, but this might help.

sudo up2date gcc
sudo up2date gcc-c++

python 2.4.2
./configure
make
make install

swig 1.3.27
./configure --with-python=/usr/local/bin/python
make
sudo make install

sqlite 3.2.8
./configure --disable-tcl
make
sudo make install
sudo /sbin/ldconfig

pysqlite 2.0.5
python setup.py build
python setup.py install

clearsilver 0.9.14
./configure
make
sudo make install
cd python
python setup.py build
sudo python setup.py install

subversion 1.3.0
./configure PYTHON=/usr/local/bin/python(I don’t understand this flag either, but that’s what the docs said to do)
make
sudo make install
make swig-py
sudo make install-swig-py

How to convert an sqlite 2 database into an sqlite 3 database

sqlite2 path/to/olddb .dump > backupfile
sqlite3 path/to/newdb < backupfile

My Backup Scripts

This is a followup to Operation: Simple Functional Backup.

Okay, here are the glorious scripts I came up with.

I call this one dailybackup: [UPDATE: a newer version of my script is posted here]

BASH:
  1. #!/bin/sh
  2.  
  3. SOURCEDIR=/Users/john ;
  4. ARCHIVEROOT=/Volumes/fire/backup ;
  5. ARCHIVENAME=PowerBookHomeDirectory ;rsync \
  6. -a –delete -delete-excluded \
  7. –exclude “/Music/” \
  8. –exclude “/tmp/” \
  9. –exclude “/Library/Caches/” \
  10. –exclude “/Desktop/downloads/” \
  11. $SOURCEDIR/ $ARCHIVEROOT/$ARCHIVENAME ;

I call this one monthlybackup:

BASH:
  1. #!/bin/sh
  2.  
  3. # Comment this out if you want to use the built-in disk burner. If you want to use an external device find it’s name from `hdiutil burn -list`
  4. DEVICE=‘-device IOService:/MacRISC2PE/pci@f4000000/AppleMacRiscPCI/firewire@E/AppleFWOHCI/IOFireWireController/IOFireWireDevice@30e00150abd577/IOFireWireUnit/IOFireWireSBP2Target/IOFireWireSBP2LUN/com_apple_driver_Oxford_Semi_FW911/IOSCSIPeripheralDeviceNub/IOSCSIPeripheralDeviceType05/IODVDServices’ ;
  5.  
  6. # Where the scripts should keep its files while working with them. everything is deleted in the end anyway so /tmp should be suitable.
  7. SCRATCH=/tmp ;
  8.  
  9. # Where dailybackup keeps its archive
  10. ARCHIVEROOT=/Volumes/fire/backup ;
  11.  
  12. # The name of the archive that dailybackup makes.
  13. ARCHIVENAME=PowerBookHomeDirectory ;
  14. # ARCHIVENAME=testtest ;
  15.  
  16. # The size of the chunks that gsplit should make, for DVD or CD.
  17. # I have not experimented with how much overhead there is for each type.
  18. # Please let me know if you have found an optimal size: john AT johnjosephbachir DOT org
  19. MEDIASIZE=4300 ;
  20. #MEDIASIZE=600 ;
  21.  
  22. # stop editing ###########################
  23. cd $ARCHIVEROOT ;
  24. echo “–creating $ARCHIVENAME.tar.gz–” ;
  25. tar czf $SCRATCH/$ARCHIVENAME.tar.gz $ARCHIVENAME ;
  26. cd $SCRATCH ;
  27. echo “–splitting $ARCHIVENAME.tar.gz into $MEDIASIZE MegaByte pieces–” ;
  28. gsplit –numeric-suffixes -b$MEDIASIZE“m” $ARCHIVENAME.tar.gz $ARCHIVENAME.tar.gz_ ;
  29.  
  30. echo “Pieces:”
  31. TOTAL=0 ;
  32. for i in $ARCHIVENAME.tar.gz_* ; do
  33. echo ”   $i” ;
  34. ((TOTAL++)) ;
  35. done;
  36.  
  37. echo “Archive has been split into $TOTAL part(s).” ;
  38.  
  39. echo “–deleting $ARCHIVENAME.tar.gz–” ;
  40. rm $ARCHIVENAME.tar.gz ;
  41.  
  42. COUNTER=0 ;
  43. for i in $ARCHIVENAME.tar.gz_* ; do
  44. ((COUNTER++)) ;
  45. NAME=$ARCHIVENAME.tar.gz_“$COUNTER”_of_“$TOTAL” ;
  46. mkdir $NAME ;
  47. mv$i$NAME ;
  48. echo “–creating disk image of $NAME–” ;
  49. hdiutil create -fs HFS+ -volname $NAME -srcfolder $NAME$NAME”.dmg ;
  50. echo “–deleting $NAME–” ;
  51. rm -r $NAME ;
  52. done;
  53.  
  54. for i in *.dmg ; do
  55. echo “–burning $i–”
  56. hdiutil burn -noverifyburn $DEVICE$i” ;
  57.  echo “–deleting $i–” ;
  58.  rm$i” ;
  59. done;

They could use some further refinement, but for the most part I am happy as a clam.

Two initial questions/problems:

  1. Do any of my geeky readers have recomendations for other things I should exclude in the first script?
  2. split seems to only want to make chunks that are about 600 megabytes each, even though I am specifying 4700 megabytes (DVD size). This is really annoying, but I am assuming that either I am missing something simple, or another solution will present itself.

    update: the problem is the split that ships with OS X seems to have a max size of 2^32 bytes. I installed the gnu coreutils using darwinports (sudo port install coreutils, which installs all the utils as "g__", very nice. If you get the coreutils source from gnu, it builds without a hitch but will install without the "g" prefix), switched to gsplit, and ta-da, everything is working.

Operation: Simple Functional Backup

Okay, after months and years of wanting a good backup solution, searching the net, and trying various scripts and shareware, I still don't have a simple effective backup solution.

I have a .mac account (It's overpriced and kind of flakey, I know I know) and with it comes Backup. Backup used to be pretty weak, but the newest version, version 3, Is put together pretty darn well in most regards. The interface is simple and functional, the preset backup plans are handy for novice users (I even use a couple of them myself), and it can handle incremental backups to disk or network, and backups that span multiple CDs or DVDs.

One place where it is sorely lacking is in the way it does incremental backups. If a file has changed since the last time you backed up, it makes a new copy of the entire file, instead of just the differences between the two files. So if you are working on a 3 gig file and only make 100k worth of changes every day, Backup will make another copy of your 3 gig file every day, which of course eats up your storage space very quickly.

If you don't mind loosing a week's worth of incremental backups, you can wipe all of your backups (including the original) and start over once a week, but there is no way to automate this.

Another problem is that as far as I can tell, it uses no compression whatsoever.

So I have decided to roll my own backup solution using rsync. There are a lot of these floating around out there, but they all seem to have more features or environment requirements than I need or want to deal with.

My system will have 2 scripts.

  1. A script which either I or a cron job runs every day or so, and does a compressed rsync on my home directory, excluding certain directories (Music, Library/Caches, Desktop/downloads, and tmp).
  2. A script that I run once a month or so, which makes a copy of the archive created by the first script, splits it into DVD sized chunks, and makes a .dmg out of each one, which I can then use Finder or Toast to burn to disk.

This solution actually won't solve the incremental problem, because I am no longer making incremental backups. But if I am not mistaken, the only way to make a complete new backup each day using Backup, without doing incremental backups, is to make a completely new backup from scratch.

Also, because I will be compressing the backups, they will hopefully fit on 1 DVD instead of 2 like they do now.

I'll keep both my readers posted on my progress.

UPDATE: here's what I came up with

How I configured a custom PHP5 build on my Dreamhost account

Dreamhost allows its users to run their own custom builds of php 5. They outline the procedure here (only accessible by Dreamhost customers). Here are details on how I got my custom php5 build running on my account:

  1. If you need unixODBC:
    1. Go here and download the newest version of the Debian binaries: unixODBC-x.x.x-x86-linux-deb.tar.gz
    2. to install: cd && tar xzf path/to/unixODBC-2.2.11.tar.gz
  2. If you need IMAP (much thanks to this guide in figuring this out):
    1. Go to ftp://ftp.cac.washington.edu/imap and download the latest IMAP. It will be named something like imap-2004g.tar.Z
    2. tar xzf imap-2004g.tar.Z
    3. cd imap-2004g
    4. make ldb SSLTYPE=none (say yes to the question it asks)
    5. mkdir lib
    6. mkdir include
    7. cd c-client
    8. cp *.h ../include/
    9. cp *.c ../lib/
    10. cp c-client.a ../lib/libc-client.a
  3. Download the latest php5 tarball from here
  4. Here is the command I used to configure php5. I started with the configuration used by dreamhost for their php5, which I found from phpinfo(). I then removed things I knew I wouldn't need, and added a few things I did need: './configure' '--prefix=/home/jjb/' '--enable-fastcgi' '--with-mysql=/usr' '--enable-calendar' '--enable-force-cgi-redirect' '--enable-trans-sid' '--with-gd' '--with-xml' '--with-xsl' '--with-ttf=/usr' '--with-freetype-dir=/usr' '--enable-exif' '--with-xslt' '--with-xslt-sablot=/usr' '--with-dom-xslt=/usr' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--with-zlib-dir=/usr' '--enable-ftp' '--enable-mbstring' '--with-mysqli' '--with-gettext' '--with-unixODBC=/home/jjb/' '--with-imap=/home/jjb/src/imap-2004g'
  5. make install
  6. cp /etc/php5/cgi/php.ini /home/jjb/lib/
  7. edit /home/jjb/lib/php.ini and set include_path = ".:/usr/local/php5/lib/php:/home/jjb/lib/php" (so that php can find your local PEAR libraries)
  8. I then copied ~/bin/php into the the top of my web directory and named it php.cgi, as dreamhost recommends. You might want to put it into http://example.com/cgi-bin/ or anywhere else.
  9. I then added the following to my .htaccess file:
    AddHandler custom-php .php .pcgi

    Action custom-php /php.cgi

Configuring Apache 2 and Subversion

Here is how I got Apache 2 and Subversion working together to provide me with WebDAV access to my repository. The OS was Red Hat Enterprise Linux ES release 3.

For Apache:

./configure --enable-dav --enable-so --with-prefix=/home/jjb/

Then, for Subversion (it's important that you install subversion second):

./configure --prefix=/home/jjb/ --with-apxs=/home/jjb/bin/apxs

What's great is that during the installation process Subversion will copy its apache modules into the the modules directory, and add the directives to your apache config (/home/jjb/conf/httpd.conf) for you!:

LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

Lines I changed:

Listen 8181
ServerName lyceum.jjb.cc:8181

And lines I added:

<Location />
DAV svn
SVNPath /var/svn/
AuthType Basic
AuthName "Lyceum Subversion Repository"
AuthUserFile /home/jjb/lyceumhttp
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
</Location>

Then to start the server: /home/jjb/bin/apachectl start




Close
Powered by ShareThis
All of mp3