pere 是为了让 nginx 支持正则表达式。只是准备,并不安装,是为了避免在64位系统中出现错误。
1
2
|
wget
ftp
:
//ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
tar
-
zxf
pcre
-
8.30
|
同样只是准备,并不安装,是为了避免在64位系统中出现错误。
1
2
|
wget
http
:
//sourceforge.net/projects/libpng/files/zlib/1.2.6/zlib-1.2.6.tar.gz/download
tar
-
zxf
zlib
-
1.2.6.tar.gz
|
1
2
3
4
|
wget
http
:
//nginx.org/download/nginx-1.1.9.tar.gz
tar
-
zxf
nginx
-
1.1.9.tar.gz
cd
nginx
-
1.1.9
mkdir
-
p
/
var
/
tmp
/
nginx
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
.
/
configure
--
prefix
=
/
usr
/
local
/
nginx
\
--
pid
-
path
=
/
var
/
run
/
nginx
.pid
\
--
lock
-
path
=
/
var
/
lock
/
nginx
.lock
\
--
with
-
http_ssl_module
\
--
with
-
http_dav_module
\
--
with
-
http_flv_module
\
--
with
-
http_realip_module
\
--
with
-
http_gzip_static_module
\
--
with
-
http_stub_status_module
\
--
with
-
mail
--
with
-
mail_ssl_module
\
--
with
-
pcre
=
.
.
/
pcre
-
8.30
\
--
with
-
zlib
=
.
.
/
zlib
-
1.2.6
\
--
with
-
debug
\
--
http
-
client
-
body
-
temp
-
path
=
/
var
/
tmp
/
nginx
/
client
\
--
http
-
proxy
-
temp
-
path
=
/
var
/
tmp
/
nginx
/
proxy
\
--
http
-
fastcgi
-
temp
-
path
=
/
var
/
tmp
/
nginx
/
fastcgi
\
--
http
-
uwsgi
-
temp
-
path
=
/
var
/
tmp
/
nginx
/
uwsgi
\
--
http
-
scgi
-
temp
-
path
=
/
var
/
tmp
/
nginx
/
scgi
make
&&
make
install
ln
-
s
/
usr
/
local
/
nginx
/
sbin
/
nginx
/
usr
/
sbin
/
|
可参考:Nginx编译参数解析
�Cprefix #nginx安装目录,默认在/usr/local/nginx
�Cpid-path #pid问件位置,默认在logs目录
�Clock-path #lock问件位置,默认在logs目录
�Cwith-http_ssl_module #开启HTTP SSL模块,以支持HTTPS请求。
�Cwith-http_dav_module #开启WebDAV扩展动作模块,可为文件和目录指定权限
�Cwith-http_flv_module #支持对FLV文件的拖动播放
�Cwith-http_realip_module #支持显示真实来源IP地址
�Cwith-http_gzip_static_module #预压缩文件传前检查,防止文件被重复压缩
�Cwith-http_stub_status_module #取得一些nginx的运行状态
�Cwith-mail #允许POP3/IMAP4/SMTP代理模块
�Cwith-mail_ssl_module #允许POP3/IMAP/SMTP可以使用SSL/TLS
�Cwith-pcre=../pcre-8.11 #注意是未安装的pcre路径
�Cwith-zlib=../zlib-1.2.5 #注意是未安装的zlib路径
�Cwith-debug #允许调试日志
�Chttp-client-body-temp-path #客户端请求临时文件路径
�Chttp-proxy-temp-path #设置http proxy临时文件路径
�Chttp-fastcgi-temp-path #设置http fastcgi临时文件路径
�Chttp-uwsgi-temp-path=/var/tmp/nginx/uwsgi #设置uwsgi 临时文件路径
�Chttp-scgi-temp-path=/var/tmp/nginx/scgi #设置scgi 临时文件路径
1
|
vim
/
etc
/
init
.d
/
nginx
|
进入编辑模式,键入以下脚本内容:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#!/bin/bash
#
#chkconfig: - 85 15
#description: Nginx is a World Wide Web server.
#processname: nginx
nginx
=
/
usr
/
local
/
nginx
/
sbin
/
nginx
conf
=
/
usr
/
local
/
nginx
/
conf
/
nginx
.conf
case
$
1
in
start
)
echo
-
n
"Starting Nginx"
$nginx
-
c
$conf
echo
" done"
;
;
stop
)
echo
-
n
"Stopping Nginx"
killall
-
9
nginx
echo
" done"
;
;
test
)
$nginx
-
t
-
c
$conf
;
;
reload
)
echo
-
n
"Reloading Nginx"
ps
auxww
|
grep
nginx
|
grep
master
|
awk
'{print $2}'
|
xargs
kill
-
HUP
echo
" done"
;
;
restart
)
$
0
stop
$
0
start
;
;
show
)
ps
-
aux
|
grep
nginx
;
;
*
)
echo
-
n
"Usage: $0 {start|restart|reload|stop|test|show}"
;
;
esac
|
保存以上脚本后,执行以下操作
1
2
3
|
chmod
+
x
/
etc
/
init
.d
/
nginx
chkconfig
--
add
nginx
chkconfig
nginx
on
|
1
2
3
4
5
6
7
8
|
server
{
listen
80
;
server_name
vps
.
xj123
.
info
;
location
/
{
root
html
/
vps
;
index
index
.
html
index
.
htm
;
}
}
|
提示:可以使用nginx -t来检验语法是否有问题,如图所示: