nginx 安装与简单设置

安装

$ tar xvfz nginx-1.0.0.tar.gz 

$ cd nginx-1.0.0/

$ sudo ./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tmp/nginx/client/  --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --user=nginx  --group=nginx > ~/nginx_install

$ sudo ./configure --prefix=/usr/local/nginx
--sbin-
path=/usr/sbin/nginx
--conf-
path=/etc/nginx/nginx.conf
--error-log-
path=/var/log/nginx/error.log
--pid-
path=/var/run/nginx/nginx.pid
--lock-
path=/var/lock/nginx.lock
--with-http_ssl_module
--with-http_flv_module
--with-http_gzip_static_module
--http-log-
path=/var/log/nginx/access.log
--http-client-body-temp-
path=/var/tmp/nginx/client/
--http-proxy-temp-
path=/var/tmp/nginx/proxy/
--http-fastcgi-temp-
path=/var/tmp/nginx/fcgi/
--user
=nginx
--group
=nginx
> ~/nginx_install

$ sudo make

$ sudo make install

编译参数: http://wiki.nginx.org/NginxChsInstallOptions

Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1 library is not used
+ using system zlib library

nginx
path prefix: "/usr/local/nginx"
nginx binary file:
"/usr/sbin/nginx"
nginx configuration prefix:
"/etc/nginx"
nginx configuration file:
"/etc/nginx/nginx.conf"
nginx pid file:
"/var/run/nginx/nginx.pid"
nginx error log file:
"/var/log/nginx/error.log"
nginx http access log file:
"/var/log/nginx/access.log"
nginx http client request body temporary
files: "/var/tmp/nginx/client/"
nginx http proxy temporary
files: "/var/tmp/nginx/proxy/"
nginx http fastcgi temporary
files: "/var/tmp/nginx/fcgi/"
nginx http uwsgi temporary
files: "uwsgi_temp"
nginx http scgi temporary
files: "scgi_temp"

Debian/Ubuntu  Linux下安装pcre-devel:

sudo apt-get update 

sudo apt-get install libpcre3 libpcre3-dev

还需要安装:
sudo apt-get install openssl libssl-dev

Nginx管理参数(可以通过help得到):

-?,-h : this help

-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /usr/local/nginx/)
-c filename : set configuration file (default: conf/nginx.conf)
-g directives : set global directives out of configuration file

Nginx允许列出整个目录(默认为不列出):
打开nginx.conf文件,在location server 或 http段中加入
autoindex on;

其他参数:

autoindex_exact_size off;

默认为on,显示出文件的确切大小,单位是bytes。
改为off后,显示出文件的大概大小,单位是kB或者MB或者GB

autoindex_localtime on;
默认为off,显示的文件时间为GMT时间。
改为on后,显示的文件时间为文件的服务器时间

posted @ 2011-05-17 23:48  TinyZ  阅读(1312)  评论(0编辑  收藏  举报