For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
安装参考:installing nginx
测试:
1. 按照Beginner's Guide的serving static content,写出了一个nginx.conf(可以放到/usr/local/nginx/conf下,或在这个目录下链接到conf文件):
events { # 不能省,否则报错
}
http {
server {
location / {
root data/www; # 此处不能是“/data/www”,下同
index index.html; # 可以不加此句,因为默认如此
}
location /images/ { # nginx采用最长匹配原则
root data;
index yq.jpg; # 这个无效,似乎nginx不能将index设为非页面文件。但不报错
}
}
}
然后在任意文件夹下创建data/www和data/images文件夹(www下需要创建index.html,否则404),再在nginx安装目录(默认/usr/local/nginx)下创建到这个data的链接。
2. 在Setting Up a Simple Proxy Server中,配置了一个反向代理,将localhost 8080端口的转向访问80端口;并利用正则表达式地位图片文件:
events {
}
http {
server {
location / {
proxy_pass http://localhost:8080;
}
location ~ \.(gif|jpg|png)$ { # 正则表达式前要加~,注意空格
root data/images;
}
}
server {
listen 8080;
root data/upl;
location / {
}
}
}
在data文件夹下创建新文件夹upl,并copy index.html。
3. Setting up FastCGI Proxying,首先参看:
1)what is CGI和 what is FastCGI ,FastCGI。重要的区别:Instead of creating a new process for each request, FastCGI uses persistent processes to handle a series of requests. These processes are owned by the FastCGI server, not the web server.
2)nginx不支持CGI(不能直接实现一个脚本的执行),支持FastCGI,但需要另外搭建一个FastCGI server,比如流行的PHP环境:实战Nginx与PHP(FastCGI)的安装、配置与优化。也可以搭建perl-fcgi,复杂些:perl + fastcgi + nginx搭建。其他C/C++,Python,Lisp都可以类似搭建。