Archive for July, 2008

Use wp super cache plugin to make your wordpress blogs run faster and your apache run better

wp-super-cache
Wordpress site wp-super-cache download

Setting up email to work for wordpress on slicehost

1. Instal postfix

sudo apt-get postfix
or
sudo aptitude install postfix

Say Yes at the prompt.

2. After it’s finished installing run:

sudo /etc/init.d/postfix restart

How to watch your swap on slicehost

SuperJared has a great post on swap and how to watch it. He also notes that Apache is usually a serious culprit.

vmstat 1 10

Setting up ssl on nginx on slicehost with ssl_requirement plugin

1. Purchase ssl certificate at GoDaddy

2. Create temp directory and create the key and csr

mkdir /home/username/temp
cd /home/username/temp
openssl genrsa -des3 -out myssl.key 1024
openssl req -new -key myssl.key -out myssl.csr

For the csr, you will have to enter information. Try to make it match to what you put in GoDaddy’s ssl form online.

3. Remove the passphrase you just had to create for reboot reasons with the server
See the slicehost tutorial for this

4. Copy the contents of myssl.csr to the GoDaddy form to generate the ssl certificate

cat myssl.csr
# then copy and paste the resulting text

5. For server software drop down box just choose apache, then press continue, and then check your email.

6. The technical contact on the domain name whois information will have to approve the certificate then you will receive an email with details of the certificate. Click the link in that email and on the next screen choose Apache once again. Then click ‘Download Signed Certificate’. You will get a zip file containing to files - your certificate file and the gd_intermediate_bundle.crt.

7. Combine the contents of these files into one file called myssl.crt (from here) and upload onto your web server at the same place you generated your key and csr - /home/username/temp I just used my ftp program to do this step.

8. Now we need to copy the relevant files to the /etc/ssl/ directory

sudo cp myssl.crt /etc/ssl/certs/
sudo cp myssl.key /etc/ssl/private/

9. Now follow the slicehost article for ssl and vhosts on nginx

10. Then I installed the ssl_requirement plugin in my app by following the instructions from Advanced Rails Recipe 68.

Note: This required one additional change to my /usr/local/nginx/sites-available/domain.com file. I had to add ‘proxy_set_header X_FORWARDED_PROTO https;’ at the top of my location section of the file.

Example:

server {
  listen 443;
  ...
  location / {
    proxy_set_header X_FORWARDED_PROTO https;
    ...
  }
}

Resources:
- GoDaddy ssl on gninx
- SSL certificates on slicehost with nginx
- Rails development with ssl

Making Apache run lighter on slicehost

I run more than 10 sites on a 256mb slice on slicehost - all php, mostly wordpress sites. They are rarely visited sites with the most popular one getting about 300 hits a day.

By changing the mpm_prefork_module I was able to get my slice to run much lighter on memory.

# default

    StartServers                  5
    MinSpareServers           5
    MaxSpareServers          10
    MaxClients                    150
    MaxRequestsPerChild   0


# to this - thanks to http://forum.slicehost.com/comments.php?DiscussionID=2099#Item_2

StartServers       3
MinSpareServers    3
MaxSpareServers    3
ServerLimit        50
MaxClients         50
MaxRequestsPerChild  1000

Here’s the difference in my memory:

Before:

Picture 1.png

After:
Picture 2.png

Brand new 256 mb slice memory usage

Here’s what a brand new 256 mb slice from slicehost looks like for memory on slicehost.

brand-new-empty-slice.png

How to check your ubuntu version on slicehost

You can check your ubuntu version on slicehost with the following command in your terminal window.

sudo lsb_release -a

or here’s another way to do it from a slicehost article

cat /etc/lsb-release

Using google charts api with rails (googlechart gem)

I opted to use the googlechart gem (Google Charts) because the website was nicely designed and had numerous examples. It also seemed to currently have the most development around it. On github it had the most recent commit. This guy also decided on the googlecharts gem.

gem sources -a http://gems.github.com/
sudo gem install googlecharts

Then add the following to the end of your environment.rb file (for some reason, if you put config.gem ‘gchart’ in the new rails 2.0 fashion it does not work.

require 'gchart'

Then put some code in your view and clean up however you want or need.

<%= Gchart.line(:data => [0, 40, 10, 70, 20]) %>

Trying out mongrel instead of thin

UPDATE: I tried out thin again, but ran only one server for my two small apps, and then ran 3 thin servers for my large app - twinstang.com. Much faster. See the output difference. I’m sticking with thin, but will stay light on the amount servers from now on. Mongrel was just noticeably slower and that bothered me.

Picture 1.png

Picture 2.png

I am trying out mongrel instead of thin for one of my apps on my slicehost. I was running 3 apps, but my swap kept getting used slightly.

So far the mongrel is definitely slower than the 2 thin apps running, but my swap is now down to zero as I would like. Maybe mongrel is lighter on the server than thin?

Passenger (mod_rails) versus Thin on nginx

Here’s a good post on Passenger versus Thin, and here is a better benchmark that includes thin on nginx.

image001.png

passenger_mongrel_thin_benchmark.png

Passenger looks to be pretty darn quick. I’m impressed.