Fedora Core 6 上安裝 beast (3)
阿新 • • 發佈:2019-01-24
覺得 pound + lighttpd 太麻煩嗎?又翻到一個應該不錯的選擇,
是一個俄國人寫的 http server, 也具有 reverse proxy 和
load balancing 的能力。
godfat ~ 3.2$ port info nginx
nginx 0.5.29, www/nginx (Variants: universal, dav, flv, mail, ssl)
http://nginx.net/
Nginx ("engine x") is a high-performance HTTP(S) server and reverse proxy,
as well as an IMAP/POP3 proxy server. Nginx was written by Igor Sysoev for
Rambler.ru, Russia's second-most visited website, where it has been running
in production for over two and a half years. Igor has released the source
code under a BSD-like license. Although still in beta, Nginx is known for
its stability, rich feature set, simple configuration, and low resource
consumption.
這個字實在是很難記…不過討論翻來翻去,他 serve static file 的效能和
lighttpd 在伯仲之間,而 load balancing 是正常可用的。所以與其使用
pound + lighttpd, 單用 nginx 可以簡化一些流程。我想缺點就是設定上
還是比 pound 複雜些,不過我個人是覺得比 lighttpd 簡單了。另外 nginx
好像沒有 windows 版,而 pound 和 lighttpd 都有 windows 版,
我想這對某些情況可能也是個考量吧?
雖然之前因為英文檔案太少所以不太流行,但最近似乎還算有蠻多人推薦的,
而且這在俄國好像還蠻廣泛被使用的,試試應該無妨。
sudo yum install nginx
跟 lighttpd 一樣,一起丟到 beast 目錄下比較容易管理。
cp /etc/nginx/nginx.conf \
/home/YOUR_NAME/projects/beast/stable-1.0/config/nginx.conf
cp /etc/nginx/mime.types \
/home/YOUR_NAME/projects/beast/stable-1.0/config/mime.types
前者是 config 檔,後者是 mime-type 設定檔,會被 include 進去。
nano config/nginx.conf
=======================
user YOUR_NAME YOUR_NAME;
worker_processes 1;
pid /home/YOUR_NAME/projects/beast/stable-1.0/tmp/pids/nginx.pid;
error_log /home/YOUR_NAME/projects/beast/stable-1.0/log/nginx_error.log;
events {
worker_connections 1024;
}
http {
include /home/YOUR_NAME/projects/beast/stable-1.0/config/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /home/YOUR_NAME/projects/beast/stable-1.0/log/nginx_access.log main;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/plain text/html text/xhtml text/css text/javascript;
upstream mongrel {
server 127.0.0.1:2000;
server 127.0.0.1:2001;
server 127.0.0.1:2002;
}
server {
listen 80;
server_name localhost;
location ~ ^/(images|javascripts|stylesheets)/ {
root /home/YOUR_NAME/projects/beast/stable-1.0/public
expires 30d;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://mongrel;
}
}
}
=======================
其實還有一大堆設定我省略掉了,可以自己上官網或 google 找其他的設定。
啟動:
sudo nginx -c config/nginx.conf
關閉:
sudo kill `cat tmp/pids/nginx.pid`
我用這個去跑 YSlow, 應該是設定的關係,分數從 62 => 75...
但當然以我測試機的超低流量來看,就算直接用 mongrel 應該也是瞬間反應…
是一個俄國人寫的 http server, 也具有 reverse proxy 和
load balancing 的能力。
godfat ~ 3.2$ port info nginx
nginx 0.5.29, www/nginx (Variants: universal, dav, flv, mail, ssl)
http://nginx.net/
Nginx ("engine x") is a high-performance HTTP(S) server and reverse proxy,
as well as an IMAP/POP3 proxy server. Nginx was written by Igor Sysoev for
Rambler.ru, Russia's second-most visited website, where it has been running
in production for over two and a half years. Igor has released the source
code under a BSD-like license. Although still in beta, Nginx is known for
its stability, rich feature set, simple configuration, and low resource
consumption.
這個字實在是很難記…不過討論翻來翻去,他 serve static file 的效能和
lighttpd 在伯仲之間,而 load balancing 是正常可用的。所以與其使用
pound + lighttpd, 單用 nginx 可以簡化一些流程。我想缺點就是設定上
還是比 pound 複雜些,不過我個人是覺得比 lighttpd 簡單了。另外 nginx
好像沒有 windows 版,而 pound 和 lighttpd 都有 windows 版,
我想這對某些情況可能也是個考量吧?
雖然之前因為英文檔案太少所以不太流行,但最近似乎還算有蠻多人推薦的,
而且這在俄國好像還蠻廣泛被使用的,試試應該無妨。
sudo yum install nginx
跟 lighttpd 一樣,一起丟到 beast 目錄下比較容易管理。
cp /etc/nginx/nginx.conf \
/home/YOUR_NAME/projects/beast/stable-1.0/config/nginx.conf
cp /etc/nginx/mime.types \
/home/YOUR_NAME/projects/beast/stable-1.0/config/mime.types
前者是 config 檔,後者是 mime-type 設定檔,會被 include 進去。
nano config/nginx.conf
=======================
user YOUR_NAME YOUR_NAME;
worker_processes 1;
pid /home/YOUR_NAME/projects/beast/stable-1.0/tmp/pids/nginx.pid;
error_log /home/YOUR_NAME/projects/beast/stable-1.0/log/nginx_error.log;
events {
worker_connections 1024;
}
http {
include /home/YOUR_NAME/projects/beast/stable-1.0/config/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /home/YOUR_NAME/projects/beast/stable-1.0/log/nginx_access.log main;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/plain text/html text/xhtml text/css text/javascript;
upstream mongrel {
server 127.0.0.1:2000;
server 127.0.0.1:2001;
server 127.0.0.1:2002;
}
server {
listen 80;
server_name localhost;
location ~ ^/(images|javascripts|stylesheets)/ {
root /home/YOUR_NAME/projects/beast/stable-1.0/public
expires 30d;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://mongrel;
}
}
}
=======================
其實還有一大堆設定我省略掉了,可以自己上官網或 google 找其他的設定。
啟動:
sudo nginx -c config/nginx.conf
關閉:
sudo kill `cat tmp/pids/nginx.pid`
我用這個去跑 YSlow, 應該是設定的關係,分數從 62 => 75...
但當然以我測試機的超低流量來看,就算直接用 mongrel 應該也是瞬間反應…