Surviving without Apache (with Nginx, mod_wsgi and php-cgi)
This tutorial is very simple, anyone with basic understanding of linux should be able to get it up and running.
(this blog and everything else on hamsworld.net is running on this configuration)
Side note: If you don’t want to compile nginx and/or want a more stable solution consider gunicorn.
- Download nginx and mod_wsgi from the web and extract them
wget http://nginx.org/download/nginx-0.8.53.tar.gz whet http://bitbucket.org/lifeeth/mod_wsgi/get/6975f0ec7eeb.gz tar xvzf nginx-0.8.53.tar.gz 6975f0ec7eeb.gz
- Make sure there are folders “nginx-0.8.53″ and “mod_wsgi”
- Install nginx (you will need gcc, libssl-dev and libpcre3-dev packages installed, you can just apt-get install them)
cd nginx-0.8.53 ./configure --sbin-path=/usr/sbin --conf-path=/etc/nginx/nginx.conf --add-module=../mod_wsgi/ --with-debug make sudo make install cd ..
- Install mod_wsgi
cd mod_wsgi sudo python setup.py install --sbin-path=/usr/sbin --conf-path=/etc/nginx cd ..
- Configure nginx
Go to /etc/nginx/ and create a directory sites or something like that for per virtual server configs and then edit your nginx.conf to something like that:
user www-data;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;
#gzip on;
wsgi_python_optimize 0;
#wsgi_python_executable /usr/bin/python;
#wsgi_python_home /usr/;
wsgi_enable_subinterpreters on;
include /etc/nginx/sites/*;
}
- If you need php, follow this few simple steps to get php-cgi up and running (skip “Install nginx” and “test”): http://davidwinter.me/articles/2009/06/13/php-and-nginx-the-easy-way/
- Now all that is left are per-site configurations. For every site create a file in /etc/nginx/sites/ and paste something like that in it:
Django or other wsgi (you’ll need django.wsgi file from here http://docs.djangoproject.com/en/1.2/howto/deployment/modwsgi/):
server {
listen 80;
server_name www.example.com; #change this
location /media/ {
root /path/to/django/project/; #change this; without media at the end
}
location / {
wsgi_pass /path/to/django/project/django.wsgi; #change this
include wsgi_vars;
wsgi_pass_authorization off;
wsgi_script_reloading on;
wsgi_use_main_interpreter on;
}
}
WordPress:
server {
listen 80;
server_name www.example.com; #change this
root /path/to/wordpress/; #change this
index index.php;
try_files $uri $uri/ /index.php?q=$uri&$args;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Other PHP:
Same as wordpress, just delete the try_files if you don’t want it (it redirects everything that doesn’t exist to index).
Pingback: Janina Thwaites
Pingback: weight loss diets
Pingback: Shonda Penney
Pingback: mybkexperience
Pingback: melamine dinnerware
Pingback: Billy Cerys
Pingback: Daniele Margret
Pingback: click the following internet site
Pingback: viagra
Pingback: credit scores
Pingback: Mae Chloe
Pingback: Alissa Johnette
Pingback: construction apps for iphone
Pingback: electric guitar skills
Pingback: dance fox
Pingback: simply click the up coming document
Pingback: of the top housewarming gifts
Pingback: Thyroid Diet
Pingback: Fay Louis
Pingback: moscow metro
Pingback: Margeret Sammer
Pingback: no fax payday loan
Pingback: Cheap Bicycles
Pingback: Meridith Justin
Pingback: fully automatic espresso
Pingback: Cassondra Velazques
Pingback: directory listing
Pingback: alligator wallet
Pingback: erotic clothing
Pingback: Toney Lenz
Pingback: Don Varden
Pingback: Devin Caudle
Pingback: http://lastkingssnapback.webs.com/
Pingback: home income package
Pingback: Gerald Allender
Pingback: internet
Pingback: Peter