Useful Rackspace Tutorials

Apache Configuration Virtual Hosts(sites-available & sites-active):

Security: (SSH Keys):
http://cloudservers.rackspacecloud.com/index.php/BasicCloudServerSecurity
IPTables :
http://cloudservers.rackspacecloud.com/index.php/Sampleiptables_ruleset
APT-GET Repositories : For some reason the ubunto distro 9.04 didn’t have these added to its apt-get sources.list. So I added them.
deb http://us.archive.ubuntu.com/ubuntu/ hardy universe deb-src http://us.archive.ubuntu.com/ubuntu/ hardy universe deb http://us.archive.ubuntu.com/ubuntu/ hardy-updates universe deb-src http://us.archive.ubuntu.com/ubuntu/ hardy-updates universe
Installing Ruby:
sudo apt-get install build-essential libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev mkdir ~/src && cd ~/src wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.gz tar -xvf ruby-1.9.1-p0.tar.gz cd ruby-1.9.1-p0 ./configure make make test sudo make install
Install Git Install Rails
sudo gem update –system sudo gem install rails
Install Ruby Mysql Modul
sudo gem install mysql

Install Pecl src : http://www.markfosteronline.com/2009/01/04/how-to-install-a-php-pecl-extensionmodule-on-ubuntu/

  • sudo apt-get install php-pear
  • sudo apt-get install php5-dev
  • sudo apt-get install libcurl4-openssl-dev
  • sudo pecl install pecl_http     just hit enter and use defaults

Monitor ETH Port

  • Use tcpdump -i eth0   to watch the ports
Install DTach – which allows you to run a session in a console, then dtach it, then go to another pc/console and attach.
  • apt-get install dtach
  • ex: dtach -A sessionname program arguments
    • press ctrl+\ to detach it from the terminal
    • then (from another computer or terminal) run “dtach -a sessionname”
  • ex:
    • dtach -A MyBashSession bash -l
    • [press ctrl+]
    • dtach -a MyBashSession
MySQL / Socket Not Found
  • sudo /etc/init.d/service mysql start
Install Zip
  • pecal install zip
  • * If it fails because of some error on expected = “” sudo apt-get install libpcre3-dev
Sources: http://rudygems.com/post/99075288/ruby-191-install

Linux command that are handy when configuring a new server

  • To view a user’s groups:
    “id [user]”
  • Add a user to a group :
    useradd -G {group-name} username
  • Add a user to multiple groups:
    usermod -a -G group1,group2 username
  • Change a users primary group:
    usermod -g group user
  • Add a group to a user
    usermod -a -G group user
  • Get a list of the groups:
    less /etc/group

Dropbox & Git… Don’t drop a git repo in GIT

Today i accidentally dropped a folder that had a git repo inside it into a dropbox folder.

Massive Memory Hog trying to index it both on update and delete….

OSX and Apache .htaccess allow mode rewrite

So today i had to get Apache, PHP and Mysql running again on my macbook after installing a new hardrive. PHP is installed already so thats fine. Mysql a simple download and install. I stick to the 32 bit for now as it not everything plays nicely w/ the 64 bit. Especially not with Python. Apache is naturally installed. Just need to turn on/off the internet sharing within the System Preferences Pane. Then comes the tricky part. In the http.conf file: ensure that the line including the ModRewrite module is uncommented. The line will look like this: LoadModule rewrite_module libexec/apache2/mod_rewrite.so Then go down to your system directive: And make it look like this: <Directory /> Options FollowSymLinks AllowOverride All # Order deny,allow # Deny from all </Directory> Also ensure that in the /etc/apache2/users/username.conf file that it looks like: <Directory "/Users/username/Sites/"> Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny Allow from all </Directory> Additionally when defining your Extra Virtual hosts: Make sure to enable all the error logs etc: ex: <VirtualHost *:80> ServerAdmin username@gmail.com DocumentRoot /Users/username/Sites/my.site.com ServerName local.site.com ServerAlias local.site.com RewriteLog "/Users/username/Sites/logs/my.site.com/rewrite_log" ErrorLog "/Users/username/Sites/logs/my.site.com/error_log" CustomLog "/Users/username/Sites/logs/my.site.com/access_log" common </VirtualHost>

CakePHP – Override .htacces to ignore directory

<IfModule mod_rewrite.c> RewriteEngine on RewriteRule    ^manager    -    [L] RewriteRule    ^pma    -    [L] RewriteRule    ^fm    -    [L] RewriteRule    ^$ app/webroot/    [L] RewriteRule    (.*) app/webroot/$1 [L] </IfModule>

Can-Do.org – Virtual Volunteer – Crow Creek Indian Reservation

Project Crow Creek & Can-DO.org

Bringing accountability and transparency to the Donation industry, we offer the tools to track your generosity from your hands, directly through to the end recipient, with nothing cut out for miscellaneous fees. Together, we can avoid the Donation Black Hole problem perpetuated by many charities. You will not need to wonder about where your money goes, we will show you every step of the way through a trackable, database. And more importantly, you can interact directly with those whose lives you have impacted, and follow their progress.

US Flag worn and weathered.

US Flag worn and weathered.

Installing Python & mod_python on OS X 10.5 Leopard

Source: http://blog.ultranurd.net/0000/01/28/compiling-django-with-twitter-support-as-a-mac-os-x-universal-binary/#Python

Files:

  1. MySQL 5.1.30
  2. Python 2.6.1
  3. setuptools 0.6c9-py2.6
  4. MySQL-python 1.2.2
  5. Django 1.0.2-final
  6. simplejson 2.0.7
  7. python-twitter 0.5
  8. mod_python 3.3.1

Python

While python.org provides a nice OS X Installer package for 2.6.1, it is compiled as a 32-bit “fat” binary, which doesn’t help us address the Universality problem. We’ll use their script for generating a package as well as installing the framework directly, after some minor changes, courtesy this mailing list post by Ned Deily.

If you’re feeling particularly trustworthy, you can download the disk image containing the Installer package that I built from my website. If not, you can make the changes yourself. Either way, Python.framework will be installed in /Library/Frameworks/.

In the Python 2.6.1 source directory, open the file Mac/BuildScript/build-installer.py in your favorite editor, and make the following changes on lines 1, 65, 68, 71, 633, and 1020:

1c1

< #!/usr/bin/python2.3

> #!/usr/bin/python 65c65

< DEPSRC = os.path.expanduser('~/Universal/other-sources')

> #DEPSRC = os.path.expanduser('~/Universal/other-sources') 68c68

< SDKPATH = "/Developer/SDKs/MacOSX10.4u.sdk"

> SDKPATH = "/Developer/SDKs/MacOSX10.5.sdk" 71c71

< ARCHLIST = ('i386', 'ppc',)

> ARCHLIST = ('i386', 'ppc', 'x86_64', 'ppc64') 633c633

< runCommand("%s -C --enable-framework --enable-universalsdk=%s LDFLAGS='-g -L%s/libraries/usr/local/lib' OPT='-g -O3 -I%s/libraries/usr/local/include' 2>&1"%(

> runCommand("%s -C --enable-framework --enable-universalsdk=%s --with-universal-archs=all LDFLAGS='-g -L%s/libraries/usr/local/lib' OPT='-g -O3 -I%s/libraries/usr/local/include' 2>&1"%( 1020c1020

< os.environ['MACOSXDEPLOYMENTTARGET'] = '10.3'

> os.environ['MACOSXDEPLOYMENTTARGET'] = '10.5'

You’ll note that some of the changes migrate this script to 10.5 (the hashbang path to Python, the deployment target and SDK version), and some of the changes add support for a Universal binary (adding to the architecture list. It’s possible that some of these changes will be fixed in a future source release of Python 2.6, but I’d guess that most efforts are focused on Python 3.0 at this point.

Once you’ve made the changes, just run the script. You need to be in the BuildScript subdirectory, unless you want to change some of the tmp paths the script uses. This script will do everything, build the framework, download and build any dependencies, install the framework, and generate a disk image. Just sit back and wait!

cd /usr/local/src/Python-2.6.1/Mac/BuildScript/

./build-installer.py

Depending on your shell configuration, you may need to make changes. In my $PATH /usr/local/bin/ trumps /usr/bin/, and I want to keep the Leopard system install of Python 2.5 in place in /System/Library/ and /usr/bin/. Here’s what I did:
cd /usr/local/bin/

for py in find /Library/Frameworks/Python.framework/Versions/2.6/bin -name py*; do ln -s $py; done;

This creates a symlink in /usr/local/bin/ for each of the various just-build Python binaries inside the framework (you’ll not that this is equivalent to the system install). If you run which python now, it should return /usr/local/bin/python. If not, adjust your $PATH as needed in your shell configuration file. This is beyond the scope of this post.

modpython

Sadly, we end with some pain. Long story short, modpython relies on apxs (the APache eXtenSion tool, best abbreviation ever) to configure its build, and does not obey any amount of environment variable manipulation to pass in multiple architectures. apxs retrieves useful compiler options, apparently based on the ones used to build your local copy apache… and herein lies the problem. apxs reads those flags from /usr/share/httpd/build/config_vars.mk, and if you inspect that file, you’ll see that there are no CFLAGS or LDFLAGS specified. This is particularly odd, considering that httpd is clearly running as a 64-bit process (according to Activity Monitor), and file reports that all of my other shared objects in /usr/libexec/apache2/ are Universal binaries.

This next bit is my idea, since I couldn’t find any suggestions by googling around. I know perl, so I just read the apxs script to figure out what it was doing, and how it was passing arguments to libtool.

This is probably a terrible idea.

Make a backup of config_vars.mk before adding the four architecture flags to CFLAGS and LDFLAGS on lines 59 and 62:

59c59

< CFLAGS =

> CFLAGS = -arch i386 -arch x86_64 -arch ppc7400 -arch ppc64 62c62

< LDFLAGS =

> LDFLAGS = -arch i386 -arch x86_64 -arch ppc7400 -arch ppc64

If you run apxs -q CFLAGS or apxs -q LDFLAGS, you’ll see these values, instead of empty strings.

Now just run the standard autoconf procedure to build and  install modpython.so in /usr/libexec/apache2/:

cd /usr/local/src/modpython-3.3.1/

./configure

make

cd test

python test.py

cd ..

make

sudo make install

Key Value Pair Database: Fast Full Text Searches

Store Data for full text searches in key:value pairs.

Tokyo DB

http://www.igvita.com/2009/02/13/tokyo-cabinet-beyond-key-value-store/

siFR: CSS, Flash & the fonts you love.

A really slick way to have any font you want on your website.

http://www.mikeindustries.com/blog/sifr/

Syncronize, Repositories, Backup, Git, SVN

I have come across some really great places to deal with file backups, syncing, and repository building.

File Syncing:

http://www.samba.org/rsync/

http://www.getdropbox.com

http://www.cis.upenn.edu/~bcpierce/unison/

Repository:

http://git-scm.com/