<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)

    隨筆檔案

    文章分類

    文章檔案

    新聞分類

    新聞檔案

    相冊

    收藏夾

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 四虎影视免费在线| 一级午夜免费视频| jlzzjlzz亚洲jzjzjz| 亚洲免费视频一区二区三区| 久久亚洲精品视频| 亚洲天然素人无码专区| 中文字幕永久免费视频| 免费无码AV电影在线观看| 国产乱辈通伦影片在线播放亚洲 | 亚洲AV无码成人网站久久精品大 | 亚洲欧洲日产国产综合网| 亚洲欧美日本韩国| 99精品免费观看| 亚洲精品WWW久久久久久| 国产va免费精品| 蜜臀91精品国产免费观看| 亚洲AV无码专区电影在线观看| 成人精品一区二区三区不卡免费看| 麻豆国产VA免费精品高清在线| 国产成人综合久久精品亚洲| 日本zzzzwww大片免费| 亚洲深深色噜噜狠狠爱网站| 亚洲人成网站免费播放| 亚洲成AⅤ人影院在线观看| 99久久国产亚洲综合精品| 中文字幕免费观看| 亚洲av无码专区国产乱码在线观看 | 国产成人免费a在线视频app| 亚洲伊人久久大香线蕉啊| 99热免费在线观看| 亚洲欧美国产欧美色欲| 亚洲综合图色40p| 一个人看的www视频免费在线观看 一个人看的免费观看日本视频www | 亚洲色少妇熟女11p| 亚洲精品成人久久久| 91成人免费观看| 免费视频成人国产精品网站| 日韩精品无码人妻免费视频| 亚洲熟女综合一区二区三区| 伊人婷婷综合缴情亚洲五月| 4hu四虎最新免费地址|