当今nginx的劲头越来越猛,记得2011年版本才1.0.6,现在已经更新到了1.5.1,nginx的更新速度越来越快。一直想记录一系列的nginx教程,处于各种原因没去做.今年抽出时间完成平时工作上用到的nginx.后续将会以视频教程的方式来做。当然,还是文章先出,下一篇文章将会讲nginx虚拟主机配置。有什么建议,望大家留言。
1、必要软件准备
- 安装pcre
为了支持rewrite功能,我们需要安装pcre
1
|
# yum install pcre* //如过你已经装了,请跳过这一步
|
- 安装openssl
需要ssl的支持,如果不需要ssl支持,请跳过这一步
1
|
# yum install openssl*
|
2、安装nginx
执行如下命令:
1
2
3
|
# ./configure --prefix=/usr/local/nginx-1.5.1 \
--
with
-
http_ssl_module
--
with
-
http_spdy
_module
\
--
with
-
http_stub_status_module
--
with
-
pcre
|
--with-http_stub_status_module:支持nginx状态查询
--with-http_ssl_module:支持https
--with-http_spdy_module:支持google的spdy,想了解请百度spdy,这个必须有ssl的支持
--with-pcre:为了支持rewrite重写功能,必须制定pcre
最后输出如下内容,表示configure OK了。
.....
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
checking
for
zlib
library
.
.
.
found
creating
objs
/
Makefile
Configuration
summary
+
using
system
PCRE
library
+
using
system
OpenSSL
library
+
md5
:
using
OpenSSL
library
+
sha1
:
using
OpenSSL
library
+
using
system
zlib
library
nginx
path
prefix
:
"/usr/local/nginx-1.5.1"
nginx
binary
file
:
"/usr/local/nginx-1.5.1/sbin/nginx"
nginx
configuration
prefix
:
"/usr/local/nginx-1.5.1/conf"
nginx
configuration
file
:
"/usr/local/nginx-1.5.1/conf/nginx.conf"
nginx
pid
file
:
"/usr/local/nginx-1.5.1/logs/nginx.pid"
nginx
error
log
file
:
"/usr/local/nginx-1.5.1/logs/error.log"
nginx
http
access
log
file
:
"/usr/local/nginx-1.5.1/logs/access.log"
nginx
http
client
request
body
temporary
files
:
"client_body_temp"
nginx
http
proxy
temporary
files
:
"proxy_temp"
nginx
http
fastcgi
temporary
files
:
"fastcgi_temp"
nginx
http
uwsgi
temporary
files
:
"uwsgi_temp"
nginx
http
scgi
temporary
files
:
"scgi_temp"
# make //确定你的服务器有安装make,如果没有安装请执行yum install make
# make install
|
3、启动、关闭、重置nginx
启动:直接执行以下命令,nginx就启动了,不需要改任何配置文件,nginx配置多域名虚拟主机请参考后续文章.
1
|
/
usr
/
local
/
nginx
-
1.5.1
/
sbin
/
nginx
|
试试访问:我这边不贴图,直接使用curl命令来读取web信息
1
2
|
[
root
@
ns
conf
]
# curl -s http://localhost | grep nginx.com
nginx
.
com
.
|
关闭:
1
|
/
usr
/
local
/
nginx
-
1.5.1
/
sbin
/
nginx
-
s
stop
|
重置:当你有修改配置文件的时候,只需要reload以下即可
1
|
/
usr
/
local
/
nginx
-
1.5.1
/
sbin
/
nginx
-
s
reload
|
整个nginx的安装就到这里结束了。
转载请注明出处:http://www.ttlsa.com/html/1548.html
收 藏
转载请注明:成长的对话 » nginx安装(1) – ttlsa教程系列之nginx