ubuntu 12.04 安装测试nginx

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 FastCGIFastCGI。重要的区别: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都可以类似搭建。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值