Tag Archives: nginx

Use varnish to optimize wordpress site

I use ubuntu as my wordpress site’s OS. Today I followed a guide from web to use varnish to optimize my wordpress site.

First of all, install varnish:

sudo apt-get install varnish

Change the listening port of varnish, edit /etc/default/varnish, modify the default port from 6081 to 80 in DAEMON_OPTS section.

Then input the rules in /etc/varnish/default.vcl Read more »

Using nginx+fastcgi to serve django request

Nginx is a fast and efficient HTTP and reverse proxy server. It’s suitable for building heavy traffic website. Python is a popular language because of it’s simpleness and fast develop speed. Django is no doubt the most used web development framework developed in python. Today I will write down how to make django work with nginx and fastcgi.

My development environment is based on ubuntu server. It’s very convinient to make it done under ubuntu. At first, install softwares we need.

# sudo apt-get install python-django python-flup spawn-fcgi nginx

Then add the following sentences in the nginx config file:

location / {
    # host and port to fastcgi server
    fastcgi_pass 127.0.0.1:8801;
    fastcgi_param PATH_INFO $fastcgi_script_name;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param QUERY_STRING $query_string;
    fastcgi_param SERVER_NAME $server_name;
    fastcgi_param SERVER_PORT $server_port;
    fastcgi_param SERVER_PROTOCOL $server_protocol;
    fastcgi_param CONTENT_TYPE $content_type;
    fastcgi_param CONTENT_LENGTH $content_length;
    fastcgi_pass_header Authorization;
    fastcgi_intercept_errors off;
}

At last, use the command to start fastcgi process:

# python manage.py runfcgi method=threaded host=127.0.0.1 port=8801

Open your browser and open http://localhost, if you see the django test page, then congratulations! You succeed.

Install Nginx 0.8 on Ubuntu Server 10.04

The nginx version in ubuntu 10.04′s repo is 0.7, it’s too old to me. I want to have a try of nginx 0.8. But I don’t want to compile it myself. I searched on the web and found the solution.

First of all, add a third party repository:

deb http://ppa.launchpad.net/jdub/devel/ubuntu lucid main


Then type the command:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E9EEF4A1
sudo apt-get update

At last, install the new nginx:

sudo apt-get install nginx.

It’s done.

Another thing is to enable multi processors of nginx, edit /etc/nginx/nginx.conf file:

vim /etc/nginx/nginx.conf

Set worker_processes number to 3 (I have four core in my cpu)

Add line:

worker_cpu_affinity 0010 0100 1000

This define nginx to use which three processors.

Then restart nginx to make it work.

HOWTO:WordPress with nginx on Debian 5

I try to build a wordpress blog site these days, and use vpslink to hold the site. Depends on the fact that I chose Debian as my vps host OS, I selected nginx to reduce the resouce usage on VPS. This article is written to share the steps to create the blog site. Read more »