所需软件包:
1、下载nginx
http://nginx.org/download/nginx-1.6.2.tar.gz
2、下载MySQL
http://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.21.tar.gz
3、下载php
http://cn2.php.net/distributions/php-5.6.3.tar.gz
4、下载pcre (支持nginx伪静态)
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz
5、下载openssl(nginx扩展)
http://www.openssl.org/source/openssl-1.0.1j.tar.gz
6、下载zlib(nginx扩展)
http://zlib.net/zlib-1.2.8.tar.gz
7、下载cmake(MySQL编译工具)
http://www.cmake.org/files/v3.0/cmake-3.0.2.tar.gz
8、下载libmcrypt(php扩展)
http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
9、下载yasm(php扩展)
http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
10、t1lib(php扩展)
ftp://sunsite.unc.edu/pub/Linux/libs/graphics/t1lib-5.1.2.tar.gz
11、下载gd库安装包
https://bitbucket.org/libgd/gd-libgd/downloads/libgd-2.1.0.tar.gz
12、libvpx(gd库需要)
https://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2
13、tiff(gd库需要)
http://download.osgeo.org/libtiff/tiff-4.0.3.tar.gz
14、libpng(gd库需要)
ftp://ftp.simplesystems.org/pub/png/src/libpng16/libpng-1.6.15.tar.gz
15、freetype(gd库需要)
http://ring.u-toyama.ac.jp/archives/graphics/freetype/freetype2/freetype-2.5.4.tar.gz
16、jpegsrc(gd库需要)
http://www.ijg.org/files/jpegsrc.v9a.tar.gz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
[root@Zabbix_Server Tools]
# pwd
/usr/local/Tools
[root@Zabbix_Server Tools]
# ll
total 156480
-rw-r--r-- 1 root root 5490501 Feb 24 2016 cmake-3.0.2.
tar
.gz
#MySQL编译工具
-rw-r--r-- 1 root root 2301350 Feb 24 2016 freetype-2.5.4.
tar
.gz
#gd库需要
-rw-r--r-- 1 root root 1000034 Feb 24 2016 jpegsrc.v9a.
tar
.gz
#gd库需要
-rw-r--r-- 1 root root 2330322 Feb 24 2016 libgd-2.1.0.
tar
.gz
#gd库安装包
-rw-r--r-- 1 root root 1335178 Feb 24 2016 libmcrypt-2.5.8.
tar
.gz
#php扩展
-rw-r--r-- 1 root root 1479720 Sep 2 13:51 libpng-1.6.25.
tar
.gz
#gd库需要
-rw-r--r-- 1 root root 1310159 Feb 24 2016 libpng-1.6.7.
tar
.gz
-rw-r--r-- 1 root root 2084229 Feb 24 2016 libvpx-v1.3.0.
tar
.bz2
#gd库需要
-rw-r--r-- 1 root root 33009070 Feb 24 2016 mysql-5.6.21.
tar
.gz
-rw-r--r-- 1 root root 804164 Aug 24 2015 nginx-1.6.2.
tar
.gz
-rw-r--r-- 1 root root 4432964 Aug 24 2015 openssl-1.0.1j.
tar
.gz
#nginx扩展
-rw-r--r-- 1 root root 2009464 Aug 24 2015 pcre-8.36.
tar
.gz
#支持nginx伪静态
-rw-r--r-- 1 root root 17514721 Feb 24 2016 php-5.6.3.
tar
.gz
-rw-r--r-- 1 root root 1872534 Feb 24 2016 t1lib-5.1.2.
tar
.gz
#php扩展
-rw-r--r-- 1 root root 2051630 Feb 24 2016 tiff-4.0.3.
tar
.gz
#gd库需要
-rw-r--r-- 1 root root 1492156 Feb 24 2016 yasm-1.3.0.
tar
.gz
#php扩展
-rw-r--r-- 1 root root 571091 Aug 24 2015 zlib-1.2.8.
tar
.gz
#nginx扩展
[root@Zabbix_Server Tools]
#
|
安装编译工具及库文件(使用yum命令安装)
1
|
[root@Zabbix_Server Tools]
# yum install -y apr* autoconf automake bison bzip2 bzip2* cloog-ppl compat* cpp curl curl-devel fontconfig fontconfig-devel freetype freetype* freetype-devel gcc gcc-c++ gtk+-devel gd gettext gettext-devel glibc kernel kernel-headers keyutils keyutils-libs-devel krb5-devel libcom_err-devel libpng libpng* libpng-devel libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool* libgomp libxml2 libxml2-devel libXpm* libX* libtiff libtiff* make mpfr ncurses* ntp openssl nasm nasm* openssl-devel patch pcre-devel perl php-common php-gd policycoreutils ppl telnet t1lib t1lib* wget zlib-devel
|
安装MySQL
安装cmake
1
2
3
4
|
[root@Zabbix_Server Tools]
# tar zxvf cmake-3.0.2.tar.gz
[root@Zabbix_Server Tools]
# cd cmake-3.0.2
[root@Zabbix_Server cmake-3.0.2]
# ./configure
[root@Zabbix_Server cmake-3.0.2]
# make && make install
|
安装MySQL
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
|
[root@Zabbix_Server Tools]
# groupadd mysql #添加mysql组
[root@Zabbix_Server Tools]
# useradd -g mysql mysql -s /bin/false #创建用户mysql并加入到mysql组,不允许mysql用户直接登录系统
[root@Zabbix_Server Tools]
# mkdir -p /app/data/mysql #MySQL数据库存放目录
[root@Zabbix_Server Tools]
# chown -R mysql:mysql /app/data/mysql/ #设置MySQL数据库存放目录权限
[root@Zabbix_Server Tools]
# mkdir /app/mysql #MySQL安装目录
[root@Zabbix_Server Tools]
# tar zxvf mysql-5.6.21.tar.gz
[root@Zabbix_Server Tools]
# cd mysql-5.6.21
[root@Zabbix_Server mysql-5.6.21]
# cmake . -DCMAKE_INSTALL_PREFIX=/app/mysql/ -DMYSQL_DATADIR=/app/data/mysql/ -DSYSCONFDIR=/etc/ #配置
[root@Zabbix_Server mysql-5.6.21]
# make && make install
[root@Zabbix_Server mysql-5.6.21]
# mv /etc/my.cnf{,20160902bak} #删除或者改名系统默认的配置文件(可能有)
[root@Zabbix_Server mysql]
# ./scripts/mysql_install_db --user=mysql --basedir=/app/mysql/ --datadir=/app/data/mysql/ #生成mysql系统数据库
[root@Zabbix_Server mysql]
# ln -s /app/mysql/my.cnf /etc/my.cnf #添加到/etc目录的软连接
[root@Zabbix_Server mysql]
# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld #把Mysql加入系统启动
[root@Zabbix_Server mysql]
# chmod 755 /etc/rc.d/init.d/mysqld
[root@Zabbix_Server mysql]
# chkconfig mysqld on
[root@Zabbix_Server mysql]
# vim /etc/rc.d/init.d/mysqld
basedir=
/app/mysql
#MySQL程序安装路径
datadir=
/app/data/mysql
#MySQl数据库存放目录
[root@Zabbix_Server mysql]
# service mysqld start
[root@Zabbix_Server mysql]
# vim /etc/profile
export
PATH=$PATH:
/app/mysql/bin/
#把mysql服务加入系统环境变量:在最后添加下面这一行
[root@Zabbix_Server mysql]
# source /etc/profile
#下面这两行把myslq的库文件链接到系统默认的位置,这样你在编译类似PHP等软件时可以不用指定mysql的库文件地址。
[root@Zabbix_Server mysql]
# ln -s /app/mysql/lib/mysql /usr/lib/mysql
[root@Zabbix_Server mysql]
# ln -s /app/mysql/include/mysql /usr/include/mysql
[root@Zabbix_Server mysql]
# mkdir /var/lib/mysql
[root@Zabbix_Server mysql]
# ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
[root@Zabbix_Server mysql]
# mysql_secure_installation #设置Mysql密码,根据提示按Y 回车输入2次密码,我这里直接把密码设置成Zabbix,方便记忆。
|
安装Nginx
安装pcre
1
2
3
4
5
|
[root@Zabbix_Server mysql]
# cd /usr/local/Tools/
[root@Zabbix_Server Tools]
# mkdir /app/pcre
[root@Zabbix_Server Tools]
# tar zxvf pcre-8.36.tar.gz
[root@Zabbix_Server pcre-8.36]
# ./configure --prefix=/app/pcre/
[root@Zabbix_Server pcre-8.36]
# make && make install
|
安装openssl
1
2
3
4
5
6
7
8
9
|
[root@Zabbix_Server pcre-8.36]
# cd ..
[root@Zabbix_Server Tools]
# mkdir /app/openssl
[root@Zabbix_Server Tools]
# tar zxvf openssl-1.0.1j.tar.gz
[root@Zabbix_Server Tools]
# cd openssl-1.0.1j
[root@Zabbix_Server openssl-1.0.1j]
# ./config --prefix=/app/openssl/
[root@Zabbix_Server openssl-1.0.1j]
# make && make install
[root@Zabbix_Server openssl-1.0.1j]
# vim /etc/profile
export
PATH=$PATH:
/app/openssl/bin/
[root@Zabbix_Server openssl-1.0.1j]
# source /etc/profile
|
安装zlib
1
2
3
4
5
6
|
[root@Zabbix_Server openssl-1.0.1j]
# cd /usr/local/Tools/
[root@Zabbix_Server Tools]
# mkdir /app/zlib
[root@Zabbix_Server Tools]
# tar zxvf zlib-1.2.8.tar.gz
[root@Zabbix_Server Tools]
# cd zlib-1.2.8
[root@Zabbix_Server zlib-1.2.8]
# ./configure --prefix=/app/zlib/
[root@Zabbix_Server zlib-1.2.8]
# make && make install
|
安装Nginx
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[root@Zabbix_Server zlib-1.2.8]
# cd /usr/local/Tools/
[root@Zabbix_Server Tools]
# groupadd www
[root@Zabbix_Server Tools]
# useradd -g www www -s /bin/false
[root@Zabbix_Server Tools]
# tar zxvf nginx-1.6.2.tar.gz
[root@Zabbix_Server Tools]
# cd nginx-1.6.2
[root@Zabbix_Server nginx-1.6.2]
# ./configure --prefix=/app/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/Tools/openssl-1.0.1j --with-zlib=/usr/local/Tools/zlib-1.2.8 --with-pcre=/usr/local/Tools/pcre-8.36
[root@Zabbix_Server nginx-1.6.2]
# make && make install
[root@Zabbix_Server nginx-1.6.2]
# /app/nginx/sbin/nginx #启动nginx
[root@Zabbix_Server nginx-1.6.2]
# ps -ef|grep nginx
root 2477 1 0 17:10 ? 00:00:00 nginx: master process
/app/nginx/sbin/nginx
www 2478 2477 0 17:10 ? 00:00:00 nginx: worker process
root 2480 6918 0 17:10 pts
/0
00:00:00
grep
nginx
[root@Zabbix_Server nginx-1.6.2]
#
|
./configure时:--with-openssl=/usr/local/src/openssl-1.0.1j --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.36指向的是源码包解压的路径,而不是安装的路径,否则会报错
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
[root@Zabbix_Server nginx-1.6.2]
# vim /etc/rc.d/init.d/nginx #添加nginx启动文件
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /app/nginx/conf/nginx.conf
# pidfile: /app/nginx/logs/nginx.pid
# Source function library.
.
/etc/rc
.d
/init
.d
/functions
# Source networking configuration.
.
/etc/sysconfig/network
# Check that networking is up.
[
"$NETWORKING"
=
"no"
] &&
exit
0
nginx=
"/app/nginx/sbin/nginx"
prog=$(
basename
$nginx)
NGINX_CONF_FILE=
"/app/nginx/conf/nginx.conf"
[ -f
/etc/sysconfig/nginx
] && .
/etc/sysconfig/nginx
lockfile=
/var/lock/subsys/nginx
make_dirs() {
# make required directories
user=`$nginx -V 2>&1 |
grep
"configure arguments:"
|
sed
's/[^*]*--user=\([^ ]*\).*/\1/g'
-`
if
[ -z
"`grep $user /etc/passwd`"
];
then
useradd
-M -s
/bin/nologin
$user
fi
options=`$nginx -V 2>&1 |
grep
'configure arguments:'
`
for
opt
in
$options;
do
if
[ `
echo
$opt |
grep
'.*-temp-path'
` ];
then
value=`
echo
$opt |
cut
-d
"="
-f 2`
if
[ ! -d
"$value"
];
then
# echo "creating" $value
mkdir
-p $value &&
chown
-R $user $value
fi
fi
done
}
start() {
[ -x $nginx ] ||
exit
5
[ -f $NGINX_CONF_FILE ] ||
exit
6
make_dirs
echo
-n $
"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -
eq
0 ] &&
touch
$lockfile
return
$retval
}
stop() {
echo
-n $
"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -
eq
0 ] &&
rm
-f $lockfile
return
$retval
}
restart() {
#configtest || return $?
stop
sleep
1
start
}
reload() {
#configtest || return $?
echo
-n $
"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >
/dev/null
2>&1
}
case
"$1"
in
start)
rh_status_q &&
exit
0
$1
;;
stop)
rh_status_q ||
exit
0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q ||
exit
7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q ||
exit
0
;;
*)
echo
$
"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit
2
esac
[root@Zabbix_Server nginx-1.6.2]
# chmod 775 /etc/rc.d/init.d/nginx
[root@Zabbix_Server nginx-1.6.2]
# chkconfig nginx on
[root@Zabbix_Server nginx-1.6.2]
# /etc/rc.d/init.d/nginx restart
[root@Zabbix_Server nginx-1.6.2]
# cp /etc/sysconfig/iptables{,20160902bak}
[root@Zabbix_Server nginx-1.6.2]
# vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
[root@Zabbix_Server nginx-1.6.2]
# /etc/rc.d/init.d/iptables restart
|
在浏览器中打开服务器IP地址,会看到下面的界面,说明Nginx安装成功。
安装php
安装yasm
1
2
3
4
5
|
[root@Zabbix_Server nginx-1.6.2]
# cd /usr/local/Tools/
[root@Zabbix_Server Tools]
# tar zxvf yasm-1.3.0.tar.gz
[root@Zabbix_Server Tools]
# cd yasm-1.3.0
[root@Zabbix_Server yasm-1.3.0]
# ./configure
[root@Zabbix_Server yasm-1.3.0]
# make && make install
|
安装libmcrypt
1
2
3
4
5
6
|
[root@Zabbix_Server yasm-1.3.0]
# cd ..
[root@Zabbix_Server Tools]
# tar zxvf libmcrypt-2.5.8.tar.gz
[root@Zabbix_Server Tools]
# cd libmcrypt-2.5.8
[root@Zabbix_Server libmcrypt-2.5.8]
# ./configure
[root@Zabbix_Server Tools]
# cd libmcrypt-2.5.8
[root@Zabbix_Server libmcrypt-2.5.8]
# ./configure
|
安装libvpx
1
2
3
4
5
|
[root@Zabbix_Server libmcrypt-2.5.8]
# cd ../
[root@Zabbix_Server Tools]
# tar xvf libvpx-v1.3.0.tar.bz2
[root@Zabbix_Server libvpx-v1.3.0]
# cd libvpx-v1.3.0
[root@Zabbix_Server libvpx-v1.3.0]
# ./configure --prefix=/app/libvpx --enable-shared --enable-vp9
[root@Zabbix_Server libvpx-v1.3.0]
# make && make install
|
安装tiff
1
2
3
4
5
|
[root@Zabbix_Server libvpx-v1.3.0]
# cd ..
[root@Zabbix_Server Tools]
# tar zxvf tiff-4.0.3.tar.gz
[root@Zabbix_Server Tools]
# cd tiff-4.0.3
[root@Zabbix_Server tiff-4.0.3]
# ./configure --prefix=/app/tiff --enable-shared
[root@Zabbix_Server tiff-4.0.3]
# make && make install
|
安装libpng
1
2
3
4
5
|
[root@Zabbix_Server tiff-4.0.3]
# cd ..
[root@Zabbix_Server Tools]
# tar zxvf libpng-1.6.25.tar.gz
[root@Zabbix_Server Tools]
# cd libpng-1.6.25
[root@Zabbix_Server libpng-1.6.25]
# ./configure --prefix=/app/libpng --enable-shared
[root@Zabbix_Server libpng-1.6.25]
# make && make install
|
安装freetype
1
2
3
4
5
|
[root@Zabbix_Server libpng-1.6.25]
# cd ..
[root@Zabbix_Server Tools]
# tar zxvf freetype-2.5.4.tar.gz
[root@Zabbix_Server Tools]
# cd freetype-2.5.4
[root@Zabbix_Server freetype-2.5.4]
# ./configure --prefix=/app/freetype --enable-shared
[root@Zabbix_Server freetype-2.5.4]
# make && make install
|
安装jpeg
1
2
3
4
5
|
[root@Zabbix_Server freetype-2.5.4]
# cd ..
[root@Zabbix_Server Tools]
# tar zxvf jpegsrc.v9a.tar.gz
[root@Zabbix_Server Tools]
# cd jpeg-9a/
[root@Zabbix_Server jpeg-9a]
# ./configure --prefix=/app/jpeg --enable-shared
[root@Zabbix_Server jpeg-9a]
# make && make install
|
安装libgd
1
2
3
4
5
|
[root@Zabbix_Server jpeg-9a]
# cd ..
[root@Zabbix_Server Tools]
# tar zxvf libgd-2.1.0.tar.gz
[root@Zabbix_Server Tools]
# cd libgd-2.1.0
[root@Zabbix_Server libgd-2.1.0]
# ./configure --prefix=/app/libgd --enable-shared --with-jpeg=/app/jpeg/ --with-png=/app/libpng/ --with-freetype=/app/freetype/ --with-fontconfig=/app/freetype/ --with-xpm=/usr/ --with-tiff=/app/tiff/ --with-vpx=/app/libvpx/
[root@Zabbix_Server libgd-2.1.0]
# make && make install
|
安装t1lib
1
2
3
4
5
6
|
[root@Zabbix_Server libgd-2.1.0]
# cd ..
[root@Zabbix_Server Tools]
# tar zxvf t1lib-5.1.2.tar.gz
[root@Zabbix_Server Tools]
# cd t1lib-5.1.2
[root@Zabbix_Server t1lib-5.1.2]
# ./configure --prefix=/app/t1lib --enable-shared
[root@Zabbix_Server t1lib-5.1.2]
# make without_doc
[root@Zabbix_Server t1lib-5.1.2]
# make install
|
安装php
1
2
3
|
[root@Zabbix_Server t1lib-5.1.2]
# cd ..
[root@Zabbix_Server Tools]
# cp -frp /usr/lib64/libltdl.so* /usr/lib/
[root@Zabbix_Server Tools]
# cp -frp /usr/lib64/libXpm.so* /usr/lib/
|
如果系统是64位,请执行以上两条命令,否则安装php会出错(32位系统不需要执行)
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
47
48
49
50
|
[root@Zabbix_Server Tools]
# tar zxvf php-5.6.3.tar.gz
[root@Zabbix_Server Tools]
# cd php-5.6.3
[root@Zabbix_Server php-5.6.3]
# export LD_LIBRARY_PATH=/app/libgd/lib/
[root@Zabbix_Server php-5.6.3]
# ./configure --prefix=/app/php --with-config-file-path=/app/php/etc --with-mysql=/app/mysql --with-mysqli=/app/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=/app/mysql --with-gd --with-png-dir=/app/libpng --with-jpeg-dir=/app/jpeg --with-freetype-dir=/app/freetype --with-xpm-dir=/usr/ --with-vpx-dir=/app/libvpx/ --with-zlib-dir=/app/zlib --with-t1lib=/app/t1lib --with-iconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --enable-ctype
[root@Zabbix_Server php-5.6.3]
# make && make install
[root@Zabbix_Server php-5.6.3]
# cp php.ini-production /app/php/etc/php.ini #复制php配置文件到安装目录
[root@Zabbix_Server php-5.6.3]
# rm -rf /etc/php.ini
[root@Zabbix_Server php-5.6.3]
# ln -s /app/php/etc/php.ini /etc/php.ini
[root@Zabbix_Server php-5.6.3]
# cp /app/php/etc/php-fpm.conf.default /app/php/etc/php-fpm.conf #拷贝模板文件为php-fpm配置文件
[root@Zabbix_Server php-5.6.3]
# ln -s /app/php/etc/php-fpm.conf /etc/php-fpm.conf
[root@Zabbix_Server php-5.6.3]
# vim /app/php/etc/php-fpm.conf
user = www
#设置php-fpm运行账号为www
group = www
pid = run
/php-fpm
.pid
#取消前面的分号
[root@Zabbix_Server php-5.6.3]
# cp /usr/local/Tools/php-5.6.3/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
[root@Zabbix_Server php-5.6.3]
# chmod +x /etc/rc.d/init.d/php-fpm
[root@Zabbix_Server php-5.6.3]
# chkconfig php-fpm on
[root@Zabbix_Server php-5.6.3]
# vim /app/php/etc/php.ini
#disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname #列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。我这里注释了
date
.timezone = PRC
#设置时区
expose_php = Off
#禁止显示php版本的信息
short_open_tag = ON
#支持php短标签
opcache.
enable
=1
#php支持opcode缓存
opcache.enable_cli
#php支持opcode缓存
zend_extension=opcache.so
#文末添加,开启opcode缓存功能
[root@Zabbix_Server php-5.6.3]
# vim /app/nginx/conf/nginx.conf #配置Nginx支持PHP
user www www;
#首行user去掉注释,修改Nginx运行组为www www;必须与/usr/local/php/etc/php-fpm.conf中的user,group配置相同,否则php运行出错
location / {
root html;
index index.html index.htm index.php;
#添加index.php
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
# #取消FastCGI server部分location的注释
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径
include fastcgi_params;
}
[root@Zabbix_Server php-5.6.3]
# /etc/init.d/nginx restart
[root@Zabbix_Server php-5.6.3]
# /etc/init.d/php-fpm restart
[root@Zabbix_Server php-5.6.3]
# cd /app/nginx/html/
[root@Zabbix_Server html]
# rm -rf *
[root@Zabbix_Server html]
# vim index.php
<?php
phpinfo();
?>
[root@Zabbix_Server html]
# chown www:www -R /app/nginx/html/
[root@Zabbix_Server html]
# chmod 700 /app/nginx/html/ -R
|
在浏览器中打开服务器IP地址,会看到php信息,说明配置正常
本文转自 justin_peng 51CTO博客,原文链接:http://blog.51cto.com/ityunwei2017/1845685,如需转载请自行联系原作者