安裝
$ 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後,顯示的檔案時間為檔案的伺服器時間