<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 閱讀(416) 評論(0)  編輯  收藏 所屬分類: 每日一記Tool 安裝應用

    <2025年7月>
    293012345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

    常用鏈接

    留言簿(6)

    隨筆檔案

    文章分類

    文章檔案

    新聞分類

    新聞檔案

    相冊

    收藏夾

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲精品视频在线免费| 亚洲精品亚洲人成在线播放| 久久久久成人精品免费播放动漫| 亚洲成色999久久网站| 一二三四影视在线看片免费| 免费精品人在线二线三线区别 | 亚洲男人的天堂网站| 国产美女无遮挡免费视频网站| 大妹子影视剧在线观看全集免费 | 色老板亚洲视频免在线观| 免费h成人黄漫画嘿咻破解版| 亚洲AV无码成人专区| 又大又硬又爽免费视频| 久久国产乱子伦精品免费不卡| 99亚偷拍自图区亚洲| 伊人久久精品亚洲午夜| 成熟女人牲交片免费观看视频| 亚洲午夜在线播放| 中文字幕第13亚洲另类| 免费H网站在线观看的| 二级毛片免费观看全程| 亚洲精品老司机在线观看| 免费又黄又爽又猛大片午夜| 噜噜噜亚洲色成人网站∨| 免费v片在线观看品善网| 222www免费视频| 中文字幕在线免费播放| 亚洲人成欧美中文字幕| 久久久久亚洲av无码专区导航| 亚洲AV无码乱码精品国产| 福利免费观看午夜体检区| 三年片在线观看免费| 亚洲综合视频在线| 亚洲国产午夜中文字幕精品黄网站 | 成年人性生活免费视频| 免费av片在线观看网站| 免费的黄网站男人的天堂| 亚洲人成7777| 色播亚洲视频在线观看| 亚洲高清国产拍精品26U| 免费观看午夜在线欧差毛片|