<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    jojo's blog--快樂憂傷都與你同在
    為夢想而來,為自由而生。 性情若水,風起水興,風息水止,故時而激蕩,時又清平……
    posts - 11,  comments - 30,  trackbacks - 0
    Nginx (pronounced Engine-X) is a russian open source httpd server originally written by Igor Sysoev back in 2005. Nginx is a very light weight httpd server and reverse proxy. It is estimated that approx. 3 per cent of all web servers run nginx. In Russia the number is as high as 20 percent, including some of their biggest web sites. Nginx is also used by Wordpress.com and 4chan.

    Why use Nginx instead of Apache or Lighty? Nginx should be fast. I mean FAST. Fast in a way of over 10000 concurrent requests / sec per server. Now that's fast!

    I have wanted to screw 'round with Nginx for a while, so here goes nothing!

    How to install Nginx on your Linux box

    Nginx can be downloaded from www.nginx.net. Simple web page displays the latest distribution packages and small introduction. Further instructions can be found from Nginx Wiki.

    I installed Nginx on my CentOs 5.1 running on VMWare & Macbook. Nginx's version was 0.6.32. The default installation is very straightforward - configure, make & make install. I had to install pcre packages to my box before installing httpd server in order to enable rewrite module. I also used --prefix module to install application where i wanted:

    [root@cluster1 nginx-0.6.32]# ./configure --prefix=/opt/nginx-0.6.32
    [root@cluster1 nginx-0.6.32]# make
    [root@cluster1 nginx-0.6.32]# make install

    After this Nginx is ready to serve static files!


    How to configure Nginx

    When you move to your Nginx installation directory, here's what you see:

    drwxr-xr-x 2 root root 4096 Oct 5 23:52 sbin
    drwxr-xr-x 2 root root 4096 Oct 5 23:52 html
    drwxr-xr-x 2 root root 4096 Oct 5 23:52 conf

    Sbin directory has only nginx executable file which starts up httpd. Html directory is same as htdocs directory in Apache - copy your files here in order to serve 'em to the world! Conf-file has all configuration files.

    When you start up your nginx (just go to sbin and type ./nginx in order to start your web server!) you get few more directories:

    drwx------ 2 nobody root 4096 Oct 5 23:52 proxy_temp
    drwxr-xr-x 2 root root 4096 Oct 5 23:52 logs
    drwx------ 2 nobody root 4096 Oct 5 23:52 fastcgi_temp
    drwx------ 2 nobody root 4096 Oct 5 23:52 client_body_temp

    In the conf-directory you can see the following files:

    -rw-r--r-- 1 root root 3610 Oct 5 23:52 win-utf
    -rw-r--r-- 1 root root 2726 Oct 5 23:52 nginx.conf.default
    -rw-r--r-- 1 root root 2726 Oct 5 23:52 nginx.conf
    -rw-r--r-- 1 root root 2991 Oct 5 23:52 mime.types.default
    -rw-r--r-- 1 root root 2991 Oct 5 23:52 mime.types
    -rw-r--r-- 1 root root 2223 Oct 5 23:52 koi-win
    -rw-r--r-- 1 root root 2837 Oct 5 23:52 koi-utf
    -rw-r--r-- 1 root root 909 Oct 5 23:52 fastcgi_params.default
    -rw-r--r-- 1 root root 909 Oct 5 23:52 fastcgi_params

    The most important file of them all is of course nginx.conf. The default configuration looks like this after installation:

    #user nobody;
    worker_processes 1;

    #error_log logs/error.log;
    #error_log logs/error.log notice;
    #error_log logs/error.log info;

    #pid logs/nginx.pid;


    events {
    worker_connections 1024;
    }


    These are default configuration parameters to set user and logging preferences. If you are your box to run many different applications it is a good idea to change default user to something else, like "nginx" or "www_user".

    Worker_connections parameter sets the maximum number of connections each worker can handle. This is quite good default value.

    The following part defines base settings for the http access:

    http {
    include mime.types;
    default_type application/octet-stream;


    You should not tamper round with mime types because you will likely end up with screwed up web server!

    If you want to, you can also change default log format in the following part.

    #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 logs/access.log main;


    TCP nopush setting means that HTTP response hearders are all sent in one packet. Sendfile setting means that Nginx ignores the details of the file it is sending and uses kernel sendfile support instead. Keepalive setting defines how long server waits for users packets. This should be changed only to few seconds on busy sites. Gzip compression saves bandwith on site, depending what kind of packets server is sending.

    sendfile on;
    #tcp_nopush on;

    #keepalive_timeout 0;
    keepalive_timeout 65;

    #gzip on;



    The following server part is just like server settings on Apache HTTPD and if you have tampered 'round with Apache before this is quite straightforward to you.

    server {
    listen 80;
    server_name localhost;

    #charset koi8-r;

    #access_log logs/host.access.log main;

    location / {
    root html;
    index index.html index.htm;
    }

    #error_page 404 /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root html;
    }


    Example how to configure virtual host on Nginx:

    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    # listen 8000;
    # listen somename:8080;
    # server_name somename alias another.alias;

    # location / {
    # root html;
    # index index.html index.htm;
    # }
    #}




    These were basic examples of Nginx and what one can do with it. I stripped some configuration examples but here you can see the basics. Later we're going to configure Nginx to use PHP and we're going thru how to use mod_rewrite with Nginx.



    [root@TEST ~]# cd /usr/local/site/nginx/conf/

    posted on 2009-07-03 11:28 Blog of JoJo 閱讀(408) 評論(0)  編輯  收藏 所屬分類: 每日一記Tool 安裝應用

    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    常用鏈接

    留言簿(6)

    隨筆檔案

    文章分類

    文章檔案

    新聞分類

    新聞檔案

    相冊

    收藏夾

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 国产成人人综合亚洲欧美丁香花 | 91免费在线播放| 国产亚洲精品美女久久久久| 亚洲黄色在线视频| 综合久久久久久中文字幕亚洲国产国产综合一区首 | 亚洲中久无码永久在线观看同| 中文字幕无码不卡免费视频 | 久久精品国产亚洲AV网站| 免费a在线观看播放| 免费av欧美国产在钱| 亚洲免费在线视频| 亚洲精品视频免费| 羞羞漫画页面免费入口欢迎你| 亚洲制服丝袜一区二区三区| 久久精品亚洲综合| 国产亚洲av片在线观看18女人| 国产a不卡片精品免费观看| 一个人在线观看视频免费| 免费播放一区二区三区| 香蕉免费看一区二区三区| 在线视频亚洲一区| 亚洲日韩AV一区二区三区中文| 亚洲午夜在线一区| 久久久久亚洲av无码专区喷水 | 国产成人+综合亚洲+天堂| 亚洲日韩精品无码专区| 亚洲入口无毒网址你懂的| 亚洲国产精品xo在线观看| 亚洲无圣光一区二区| 亚洲欧洲日产国码www| 亚洲精品美女在线观看| 亚洲三级电影网站| 亚洲av永久无码精品秋霞电影影院| 久久久精品国产亚洲成人满18免费网站| 免费观看午夜在线欧差毛片| 国产女高清在线看免费观看| 日本一道一区二区免费看| 成人爱做日本视频免费| 国产美女无遮挡免费视频网站| 国产精品四虎在线观看免费| 国产精品冒白浆免费视频|