1:安装前的准备

openssl下载地址 http://www.openssl.org/source/
zlib库下载地址: http://ishare.iask.sina.com.cn/download/explain.php?fileid=13924714
pcre库安装:yum install pcre*

nignx下载http://wiki.nginx.org/Install

2:分别下载安装,都是tar.gz格式的,安装方式无非就是 .configure make && make install

3:下面是nginx的安装了

tar zxvf nginx-1.1.12.tar.gz
cd nginx-1.1.12/
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-openssl=/usr/local/ssl/include/openssl

make && make install

4:安装好之后,执行

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

5: ps -ef | grep nginx就能看到nginx的进程了

6:浏览器是输入localhost就能看到一句话

Welcome to nginx!

7:OK

-----------------------------------------------------------------------------

配置一个基于域名的虚拟主机

server {
listen 80;
server_name www.example.com;

location / {
root html;
index index.html index.htm;
}
}

------防止用户通过ip直接访问网站,可加上下面这段.....rewite是重定向,可以重定向到自己的网站首页,这样比较好,也可以return 404.....

server {
listen 80 default_server;
server_name _;
rewrite ^ http://www.baidu.com;
}