Categories
command-line How-To wordpress

What You Missed At WordCamp LA

Here’s what you missed:

Installing nginx with php-fpm with varnish on the front end will make your WordPress install fly 50 times faster.

If you’re using apt-get, you can just use:
apt-get install php-fpm
Or try this guide on how-to forge.
Here’s the install process I used using PHP 5.3.3 on OS X:

sudo ./configure --prefix=/usr/local --enable-fpm \ 
  --with-fpm-user=daemon --with-fpm-group=daemon \ 
  --with-mcrypt --with-mysql=/usr/local/mysql --with-zlib \
  --enable-mbstring --disable-pdo --with-curl --disable-debug \
  --disable-rpath --enable-inline-optimization --with-bz2 
  --with-zlib --enable-sockets --enable-sysvsem \
  --enable-sysvshm --enable-pcntl --enable-mbregex \
  --with-mhash --enable-zip --with-pcre-regex \ 
  --with-iconv=shared,/usr
make && make install
cp sapi/fpm/php-fpm.conf /usr/local/etc/php-fpm.conf
# edit php-fpm.conf with the right paths
cp sapi/fpm/php-fpm /usr/local/sbin/php-fpm
cp init.d.php-fpm /etc/init.d/php-fpm
/etc/init.d/php-fpm start

If you get an error message it’s probably because you didn’t go through the config to set things up.

The next part is nginx.

./configure --prefix=/usr/local/nginx && make && make install

My conf/nginx.con looks like this. My sites-enabled/default.conf looks like this. My conf/fastcgi_params file is here.

I just start nginx with /usr/local/nginx/sbin/nginx and I’m good to go.

The quote that stuck with me the most was what Josh Highland said about caching:

“You should use WordPress Cache Plugins. It’s like printing money. It’s free!”

For adding your own contact form, I learned about Contact Form 7. You can ditch WuFoo if you have this configured on your WordPress.

There’s also Pods, which is like contact-form-7 except it’s a whole framework for creating your own content types and making them show up where you want.

Categories
command-line How-To sysadmin

Commands I Use Frequently

Here’s a list of commands I use frequently, where the first number represents the number of times I used that command today:

86 git – the best version control software ever
59 cd – used to change directories on the command-line
54 ls – used to list files in a directory
41 vim – when textmate just isn’t fast enough for moving and manipulating text I use this text editor
24 grep – this is great for searching through code
21 sudo – I use this for stopping and starting servers and anything that requires super user access

I figured this out by using the following:

history | cut -c8-20 | sort > commands.txt

I created the following script in Perl:

#!/usr/bin/env perl

use strict;
use warnings;

my %h_list = ();
my @sorted = ();
my @listed = ();

open(LS, “commands.txt”);
while() {
if ($_ =~ /(\w+)/) {
$h_list{$1}++;
}
}

close(LS);

foreach my $key (keys %h_list)
{
push @listed, $h_list{$key} . “\t” . $key;
}

@sorted = sort { $b <=> $a } @listed;
foreach (@sorted)
{
print $_ . “\n”;
}

Categories
command-line

Install Script For Rails on Debian

The following works great on Rackspace’s Debian Virtual Servers and within 5 minutes you got a running rails instance.

#!/bin/bash

apt-get update -y
apt-get upgrade -y
apt-get install dlocate -y
apt-get install build-essential libssl-dev libreadline5-dev zlib1g-dev -y
apt-get install sqlite3 -y
cd /usr/local/src
wget ftp://ftp.ruby-lang.org/pub/ruby/stable-snapshot.tar.gz
tar zxvf stable-snapshot.tar.gz
cd ruby
./configure && make && make install
ruby -v
ruby -ropenssl -rzlib -rreadline -e “puts :Hello”
cd /usr/local/src
wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz
tar zxvf rubygems-1.3.5.tgz
cd rubygems-1.3.5
ruby setup.rb
gem install rails
apt-get install mysql-server mysql-client -y
apt-get install libmysql-ruby libmysqlclient15-dev -y
gem install mysql — –with-mysql-include=/usr/include –with-mysql-lib=/usr/lib
gem install mongrel –include-dependencies
apt-get install git -y

Categories
command-line git How-To

Git: How to Cherry Pick Commits and Package them Under a Tag

I’ve pretty much come to rely on git to pull me out of any bad jams in the chaotic environment I work in.

One thing I’ve had to learn to do is cherry pick commits and package them under a tag in git.

Here’s how to do it if you were working with my newLISP project called Sitebeagle:

fork sitebeagle on this page

cd sitebeagle

git fetch –tags

git checkout 8f5bb33a771f7811d21b8c96cec67c28818de076

git checkout -b sample_cherry_pick

git cherry-pick 22aab7

git cherry-pick b1334775

git diff sample_cherry_pick..master

git tag leaving_out_one_commit

git push origin –tags

At this point, you should have a tagged branch that doesn’t have the commit with the change to the “2nd file.” The diff should look exactly like this:

diff –git a/test.lsp b/test.lsp
index 9cf1667..158b625 100755
— a/test.lsp
+++ b/test.lsp
@@ -1,6 +1,7 @@
#!/usr/bin/newlisp

; test tag test_a
+; cherry pick test 2

(load “sitebeagle.lsp”)
(load “twitter.lsp”);

Categories
command-line sysadmin WebApps

Doing Sysadmin on the iPhone

For checking up on sites in the enterprise, I use Alertsite. It was suggested to me by a VP I work with at McCann, Ed Recinto. It’s been a great tool.

For personal websites that I manage, I’ve been using something I rolled in newLISP, sitebeagle. Why? Because beagles are great watchdogs.

Very often, most problems can be solved with tweaking code, changing permissions, or upgrading and apache or mysql.

Very often, it’s the weekend, I’m sitting in a cafe, and get an alert from Nagios or Alertsite. With iSSH, on the iPhone, I can ssh into a LAMP server and do the work I need.

I can see things getting a bit more complex. What tools do you use to sysadmin from an iPhone?

Categories
command-line scalability hacking

Oddments: A Great Blog For Keeping Up With Drizzle and Gearman

Alan Kasindorf just introduced me to a great blog by Eric Day, Oddments.

If you are into learning about alternatives to MySQL like Drizzle, or how to scale writes to a database using Gearman, then I wholeheartedly recommend his blog.

I really like the samples of code he puts up that acts as a very useful, and direct tutorial to new technologies.

Categories
command-line How-To WebApps

Setting Up a newLISP Webserver

How fast can you get on the web? With newLISP it’s about as fast as typing:

newlisp -http -d 8080 -w /usr/home/www/httpdocs &

How fast can you create a backdoor with newLISP?

newlisp -p 1234 &

If you telnet into port 1234 in localhost, you’ll see something that looks like this:

Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.
newLISP v.10.0.0 on OSX IPv4 UTF-8.

>

This opens up a lot of possibilities for distributed computing.

For example, you can set up a newLISP server that’s ready to respond to a newLISP client with this command:

newlisp -c -d 1234

Your newLISP client can have code that sends a computing problem to be solved to the server:

(net-eval “localhost” 1234 “(+ 3 4)” 1000)

Or let’s say you had a farm of newLISP servers:

#!/usr/bin/newlisp

(set ‘result (net-eval ‘(
(“192.168.1.100” 4711 {(+ 3 4)})
(“192.168.1.101” 4711 {(+ 5 6)})
(“192.168.1.102” 4711 {(+ 7 8)})
(“192.168.1.103” 4711 {(+ 9 10)})
(“192.168.1.104” 4711 {(+ 11 12)})
) 1000))

(println “result: ” result)

(exit)

If the above example reminds you of Gearman, you get +12 points.

Categories
command-line How-To TechBiz

The Infamous Zed Shaw Declares ACL Is Dead

If you work with ACL, this may be the most important video you watch ever. Zed shows how ACL is not Turing complete, which explains all the problems you’ve been having with control lists.


Zed Shaw – The ACL is Dead from CUSEC on Vimeo.

Categories
command-line How-To TechBiz

Setting Up An EC2 LAMP Server

Pre-requisites:

Now we’re ready to build an EC2 LAMP Server.

cd .ec2

You’ll find that a lot of ec2 stuff happens in the .ec2 directory.

To list the possible servers that you can set up run:

ec2-describe-images -a

I ran

ec2-describe-images -a | wc -l

and got 1477 possible servers. Some are Windows.

Let’s say we see this listing:

IMAGE ami-1539dc7c level22-ec2-images/ubuntu-8.04-hardy-20080205a.manifest.xml

If we want to start up the ubuntu server listed above we just type:

ec2-run-instances ami-5647a33f -k ec2-keypair

And then we run this command:

ec2-describe-instances

We should see either “pending” or the actual instance running with its FQDN listed in the 4th column. An example FQDN is this:

ec2-173-33-159-95.compute-1.amazonaws.com

And if we go to:
http://ec2-173-33-159-95.compute-1.amazonaws.com/

we should see a webserver.

And if we ssh:

ssh -i ec2-keypair ec2-173-33-159-95.compute-1.amazonaws.com

we’ll get the root prompt:
#~

That’s basically it. Now you can go in and mess around with server settings.

In the next blog post, we’ll look at how to save your custom server settings and set up using S3.

Categories
command-line How-To

Apps That Seem to Crash WoW on OS X 10.5.5

I wrote this quick script to take care of apps that seem to Crash OS X 10.5.5 on my Macbook Pro. I have just 1GiB of RAM instead of the recommended 2GiB, but ever since killing the processes in the script below, I haven’t had a crash.

The bad guys are:

  • Google Updater
  • Cross Over
  • HPEventHandler
  • HP IO Classic Proxy
  • HP IO Classic Proxy 2

I killed privoxy in my script below just to get more memory to run Warcraft.

#!/bin/bash

C1=`ps ax | grep Cross | grep -v grep | cut -c3-6`
echo “C1: $C1”
kill -9 $C1
C1=`ps ax | grep “Google Updater” | grep -v grep | cut -c3-6`
echo “C1: $C1”
kill -9 $C1
C1=`ps ax | grep “HPEventHandler” | grep -v grep | cut -c3-6`
echo “C1: $C1”
kill -9 $C1
C1=`ps ax | grep “HP IO Classic Proxy 2” | grep -v grep | cut -c3-6`
echo “C1: $C1”
kill -9 $C1
C1=`ps ax | grep “HP IO Classic Proxy \-” | grep -v grep | cut -c3-6`
echo “C1: $C1”
kill -9 $C1
C1=`ps ax | grep “privoxy” | grep -v grep | cut -c3-6`
echo “C1: $C1”
kill -9 $C1