Nginx學習筆記——安裝

Nginx安裝

linux安裝

下載 tar.gz 包,以及依賴 openssl、zlib、pcrephp

openssl、zlib、pcre 安裝html

cd 對應目錄 
./configure
make
make install

nginx 安裝linux

cd 對應目錄
./configure --with-pcre=pcre路徑 --with-zlib=zlib路徑 --with-openssl=openssl路徑
make
make install

ps:./configure 用法 參考 nginx

http://www.linuxidc.com/Linux/2011-02/32211.htm
http://www.cnblogs.com/tdalcn/archive/2011/11/11/2245402.htmlwindows

./configure -prefix=/usr 意思是將該軟件安裝在 /usr 下面,執行文件就會安裝在 /usr/bin,資源文件就會安裝在 /usr/share(而不是默認的/usr/local/share),具體能夠經過 --help 查看。bash

windows安裝服務器

官網下載windows版本 安裝以後,雙擊啓動(窗口會一閃而過,會有兩個nginx進程,應該是主和從)併發

Nginx 默認配置

默認配置以下app

user  nginx;
worker_processes  1; #啓用的進程數,根據cpu數量配置

error_log  /var/log/nginx/error.log warn; #錯誤日誌輸出文件
pid        /var/run/nginx.pid;


events {
    worker_connections  1024; #單個後臺worker process進程的最大併發連接數
}


http {
    include       /etc/nginx/mime.types; #設定mime類型,類型由mime.type文件定義
    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  /var/log/nginx/access.log  main; #日誌輸出文件

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65; #鏈接超時時間

    #gzip  on; #開啓gzip壓縮

    include /etc/nginx/conf.d/*.conf;
}
server {
    listen       80; #監聽端口
    server_name  localhost; #使用localhost訪問時

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main; #設定本虛擬主機的訪問日誌

    location / {
        root   /usr/share/nginx/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   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    # php腳本請求轉發到 http://127.0.0.1
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1; 
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    # PHP 腳本請求所有轉發到 FastCGI處理. 使用FastCGI默認配置.
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    # 禁止訪問 .htxxx 文件
    #location ~ /\.ht {
    #    deny  all;
    #}
}
相關文章
相關標籤/搜索