Ruby代码
$ ftp ftp.csx.cam.ac.uk username: anonymous > cd pub/software/programming/pcre/ > get pcre-7.4.tar.bz2 > quit $ tar -jxvf pcre-7.4.tar.bz2 $ cd pcre-7.4 $ ./configure $ make
不需要安装它,只是编译nginx时需要用到而已。
安装nginx
Ruby代码
$ wget $ tar -zxvf nginx-0.5.32.tar.gz $ cd nginx-0.5.32 $ ./configure –with-pcre=../pcre-7.4 $ make $ sudo make install
配置nginx
修改/usr/local/nginx/conf/nginx.conf:
Ruby代码
user someuser; worker_processes 1; error_log logs/error.log notice; pid logs/nginx.pid; events { worker_connections 1024; } http { include conf/mime.types; default_type application/octet-stream; access_log logs/access.log; sendfile on; tcp_nopush on; keepalive_timeout 65; tcp_nodelay on; gzip on; gzip_min_length 1100; gzip_buffers 4 8k; gzip_types text/plain; upstream mongrel { server 127.0.0.1:8100; server 127.0.0.1:8101; server 127.0.0.1:8102; server 127.0.0.1:8103; } server { listen 80; server_name your.server.com; location / { proxy_pass ; } root /home/your/app/path; access_log off; rewrite_log on; location ~ ^/$ { if (-f /index.html){ rewrite (.*) /index.html last; } proxy_pass ; proxy_set_header Host $host; } location / { if (!-f $request_filename.html) { proxy_pass ; } rewrite (.*) $1.html last; } location ~ .html { root /home/your/app/path; } location ~* ^.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls| exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mov)$ { root /home/your/app/path; } location / { proxy_pass ; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } }启动 nginx
$ sudo /usr/local/nginx/sbin/nginx
配置启动 mongrel cluster
Ruby代码