对大名鼎鼎的Nginx就不做介绍了,直接上重点。不过对nginx的发音我需要强调下,“engine X”。
一、安装环境:
2.6.18-164.el5
x86_64 GNU/Linux
其它信息忽略
二、安装过程
./configure
make
make install
默认情况下,Nginx 会被安装在 /usr/local/nginx。通过--prefix=#userpath#选项,你可以改变这个设定。
就这么简单
三、启动、关闭、重启
先说启动:
进入安装目录(我的是/usr/local/nginx/sbin),然后执行 #sudo ./nginx
这样就启动了, 默认是80端口。
可以用curl http://localhost 验证一下。正确启动的话返回信息如下:
<html>
<head>
<title>Welcome to nginx!</title>
</head>
<body bgcolor="white" text="black">
<center><h1>Welcome to nginx!</h1></center>
</body>
</html>
关闭nginx:
nginx -s stop 快速关闭Nginx,可能不保存相关信息,并迅速终止web服务。(quick exit)
nginx -s quit 平稳关闭Nginx,保存相关信息,有安排的结束web服务。(graceful exit)
重启nginx:
nginx -s reload 因改变了Nginx相关配置,需要重新加载配置而重载。(changing configuration,start a new worker,quitting an old worker gracefully.)
nginx -s reopen 重新打开日志文件。(reopenging log files)
四、常用的配置项
1、生成目录列表
location / { autoindex on; #开启目录列表 autoindex_localtime on; #显示本地时间 autoindex_exact_size on; #大小单位为byte s }
上述3项默认都为off。
2、
参考资料:
1、http://en.wikipedia.org/wiki/Nginx
2、http://wiki.nginx.org/NginxChs