一、配置防火墙,开启80端口、3306端口,关闭SELINUX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[root@Zabbix ~]
# vim /etc/sysconfig/iptables
-A INPUT -i lo -j ACCEPT
-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
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
[root@Zabbix ~]
# vim /etc/selinux/config
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@Zabbix ~]
# reboot
|
二、软件包下载
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
[root@Zabbix ~]
# cd /usr/local/src/
[root@Zabbix src]
# ls
cmake-3.0.2.
tar
.gz MySQL编译工具
libgd-2.1.0.
tar
.gz gd库安装包
libvpx-v1.3.0.
tar
.bz2 gd库需要
openssl-1.0.1j.
tar
.gz nginx扩展
t1lib-5.1.2.
tar
.gz php扩展
zlib-1.2.8.
tar
.gz nginx扩展
freetype-2.5.4.
tar
.gz gd库需要
libmcrypt-2.5.8.
tar
.gz php扩展
mysql-5.6.21.
tar
.gz
pcre-8.36.
tar
.gz 支持nginx伪静态
tiff-4.0.3.
tar
.gz gd库需要
jpegsrc.v9a.
tar
.gz gd库需要
libpng-1.6.7.
tar
.gz gd库需要
nginx-1.6.2.
tar
.gz
php-5.6.3.
tar
.gz
yasm-1.3.0.
tar
.gz php扩展
[root@Zabbix src]
#
|
三、安装编译工具及库文件
1
2
3
4
5
6
7
8
|
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
1、安装cmake
1
2
3
4
|
[root@Zabbix src]
# tar zxvf cmake-3.0.2.tar.gz
[root@Zabbix src]
# cd cmake-3.0.2
[root@Zabbix cmake-3.0.2]
# ./configure
[root@Zabbix cmake-3.0.2]
# make && make install
|
2、安装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
29
30
31
32
33
34
35
36
|
[root@Zabbix cmake-3.0.2]
# groupadd mysql
[root@Zabbix cmake-3.0.2]
# useradd -g mysql mysql -s /sbin/nologin
[root@Zabbix cmake-3.0.2]
# mkdir -p /opt/data/mysql #MySQL数据库存放目录
[root@Zabbix cmake-3.0.2]
# chown -R mysql:mysql /opt/data/mysql/
[root@Zabbix cmake-3.0.2]
# mkdir -p /app/mysql #MySQL安装目录
[root@Zabbix cmake-3.0.2]
# cd ..
[root@Zabbix src]
# tar zxvf mysql-5.6.21.tar.gz
[root@Zabbix src]
# cd mysql-5.6.21
[root@Zabbix mysql-5.6.21]
# cmake . -DCMAKE_INSTALL_PREFIX=/app/mysql -DMYSQL_DATADIR=/opt/data/mysql -DSYSCONFDIR=/etc
[root@Zabbix mysql-5.6.21]
# make && make install
[root@Zabbix mysql-5.6.21]
# rm -rf /etc/my.cnf #删除系统默认的配置文件
[root@Zabbix mysql-5.6.21]
# cd /app/mysql/ #进入MySQL安装目录
[root@Zabbix mysql]
# ./scripts/mysql_install_db --user=mysql --basedir=/app/mysql --datadir=/opt/data/mysql #生成mysql系统数据库
[root@Zabbix mysql]
# ln -s /app/mysql/my.cnf /etc/my.cnf #添加到/etc目录的软连接
[root@Zabbix mysql]
# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld #把Mysql加入系统启动
[root@Zabbix mysql]
# chmod 755 /etc/rc.d/init.d/mysqld
[root@Zabbix mysql]
# chkconfig mysqld on
[root@Zabbix mysql]
# vim /etc/rc.d/init.d/mysqld
basedir=
/app/mysql
datadir=
/opt/data/mysql
[root@Zabbix mysql]
# service mysqld start
Starting MySQL. [ OK ]
[root@Zabbix mysql]
#
[root@Zabbix mysql]
# vim /etc/profile
export
PATH=$PATH:
/app/mysql/bin
#把mysql服务加入系统环境变量:在最后添加下面这一行
[root@Zabbix mysql]
# source /etc/profile
#把myslq的库文件链接到系统默认的位置,这样你在编译类似PHP等软件时可以不用指定mysql的库文件地址。
[root@Zabbix mysql]
# ln -s /app/mysql/include/mysql /usr/include/mysql
[root@Zabbix mysql]
# ln -s /app/mysql/lib/mysql /usr/lib/mysql
[root@Zabbix mysql]
# mkdir /var/lib/mysql
[root@Zabbix mysql]
# ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
[root@Zabbix mysql]
# mysql_secure_installation #设置Mysql密码,根据提示回车、输入Y 回车输入2次密码,一路回车
[root@Zabbix mysql]
# service mysqld restart
Shutting down MySQL. [ OK ]
Starting MySQL. [ OK ]
[root@Zabbix mysql]
#
|
五、安装Nginx
1、安装pcre
1
2
3
4
5
6
|
[root@Zabbix mysql]
# cd /usr/local/src/
[root@Zabbix src]
# mkdir /app/pcre
[root@Zabbix src]
# tar zxvf pcre-8.36.tar.gz
[root@Zabbix src]
# cd pcre-8.36
[root@Zabbix pcre-8.36]
# ./configure --prefix=/app/pcre
[root@Zabbix pcre-8.36]
# make && make install
|
2、安装openssl
1
2
3
4
5
6
7
8
9
|
[root@Zabbix pcre-8.36]
# cd ..
[root@Zabbix src]
# mkdir /app/openssl
[root@Zabbix src]
# tar zxvf openssl-1.0.1j.tar.gz
[root@Zabbix src]
# cd openssl-1.0.1j
[root@Zabbix openssl-1.0.1j]
# ./config --prefix=/app/openssl/
[root@Zabbix openssl-1.0.1j]
# make && make install
[root@Zabbix openssl-1.0.1j]
# vim /etc/profile
export
PATH=$PATH:
/app/openssl/bin
[root@Zabbix openssl-1.0.1j]
# source /etc/profile
|
3、安装zlib
1
2
3
4
5
6
|
[root@Zabbix openssl-1.0.1j]
# cd /usr/local/src/
[root@Zabbix src]
# mkdir /app/zlib
[root@Zabbix src]
# tar zxvf zlib-1.2.8.tar.gz
[root@Zabbix src]
# cd zlib-1.2.8
[root@Zabbix zlib-1.2.8]
# ./configure --prefix=/app/zlib/
[root@Zabbix zlib-1.2.8]
# make && make install
|
4、安装Nginx
1
2
3
4
5
6
7
|
[root@Zabbix zlib-1.2.8]
# cd /usr/local/src/
[root@Zabbix src]
# groupadd www
[root@Zabbix src]
# useradd -g www www -s /sbin/nologin
[root@Zabbix src]
# tar zxvf nginx-1.6.2.tar.gz
[root@Zabbix src]
# cd nginx-1.6.2
[root@Zabbix 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/src/openssl-1.0.1j --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.36
[root@Zabbix nginx-1.6.2]
# make && make install
|
注意:--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
|
[root@Zabbix nginx-1.6.2]
# cd /app/nginx/sbin/
[root@Zabbix sbin]
# ./nginx #启动
[root@Zabbix sbin]
# ps -ef|grep -i nginx
root 23408 1 0 12:21 ? 00:00:00 nginx: master process .
/nginx
www 23409 23408 0 12:21 ? 00:00:00 nginx: worker process
root 23411 2232 0 12:22 pts
/0
00:00:00
grep
-i nginx
[root@Zabbix sbin]
# ./nginx -s reload #重启
[root@Zabbix sbin]
# ./nginx -t -c /app/nginx/conf/nginx.conf #检查配置文件
nginx: the configuration
file
/app/nginx/conf/nginx
.conf syntax is ok
nginx: configuration
file
/app/nginx/conf/nginx
.conf
test
is successful
[root@Zabbix sbin]
# ./nginx -v #查版本号
nginx version: nginx
/1
.6.2
[root@Zabbix sbin]
# ./nginx -V #查编译配置
nginx version: nginx
/1
.6.2
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
TLS SNI support enabled
configure arguments: --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/src/openssl-1
.0.1j --with-zlib=
/usr/local/src/zlib-1
.2.8 --with-pcre=
/usr/local/src/pcre-8
.36
[root@Zabbix sbin]
#
|
5、设置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
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
|
[root@Zabbix sbin]
# vim /etc/rc.d/init.d/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 sbin]
# chmod +x /etc/rc.d/init.d/nginx
[root@Zabbix sbin]
# chkconfig nginx on
[root@Zabbix sbin]
# service nginx restart
Stopping nginx: [ OK ]
Starting nginx: [ OK ]
[root@Zabbix sbin]
#
|
nginx更多配置见:RHEL6编译安装nginx、开机启动脚本
六、安装php
1、安装yasm
1
2
3
4
5
|
[root@Zabbix sbin]
# cd /usr/local/src/
[root@Zabbix src]
# tar zxvf yasm-1.3.0.tar.gz
[root@Zabbix src]
# cd yasm-1.3.0
[root@Zabbix yasm-1.3.0]
# ./configure
[root@Zabbix yasm-1.3.0]
# make && make install
|
2、安装libmcrypt
1
2
3
4
5
|
[root@Zabbix yasm-1.3.0]
# cd /usr/local/src/
[root@Zabbix src]
# tar zxvf libmcrypt-2.5.8.tar.gz
[root@Zabbix src]
# cd libmcrypt-2.5.8
[root@Zabbix libmcrypt-2.5.8]
# ./configure
[root@Zabbix libmcrypt-2.5.8]
# make && make install
|
3、安装libvpx
1
2
3
4
5
|
[root@Zabbix libmcrypt-2.5.8]
# cd /usr/local/src/
[root@Zabbix src]
# tar xvf libvpx-v1.3.0.tar.bz2
[root@Zabbix src]
# cd libvpx-v1.3.0
[root@Zabbix libvpx-v1.3.0]
# ./configure --prefix=/app/libvpx --enable-shared --enable-vp9
[root@Zabbix libvpx-v1.3.0]
# make && make install
|
4、安装tiff
1
2
3
4
5
|
[root@Zabbix libvpx-v1.3.0]
# cd /usr/local/src/
[root@Zabbix src]
# tar zxvf tiff-4.0.3.tar.gz
[root@Zabbix src]
# cd tiff-4.0.3
[root@Zabbix tiff-4.0.3]
# ./configure --prefix=/app/tiff --enable-shared
[root@Zabbix tiff-4.0.3]
# make && make install
|
5、安装libpng
1
2
3
4
5
6
7
8
|
[root@Zabbix tiff-4.0.3]
# cd /usr/local/src/
[root@Zabbix src]
# tar zxvf libpng-1.6.7.tar.gz
[root@Zabbix src]
# cd libpng-1.6.7
[root@Zabbix libpng-1.6.7]
# ./configure --prefix=/app/libpng --enable-shared
configure: error: zlib not installed
[root@Zabbix libpng-1.6.7]
# export LDFLAGS="-L/app/zlib/lib"
[root@Zabbix libpng-1.6.7]
# export CPPFLAGS="-I/app/zlib/include"
[root@Zabbix libpng-1.6.7]
# make && make install
|
6、安装freetype
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
[root@Zabbix libpng-1.6.7]
# cd /usr/local/src/
[root@Zabbix src]
# tar zxvf freetype-2.5.4.tar.gz
[root@Zabbix src]
# cd freetype-2.5.4
[root@Zabbix freetype-2.5.4]
# ./configure --prefix=/app/freetype -enable-shared
make
: Nothing to be
done
for
`unix'.
[root@Zabbix freetype-2.5.4]
# cd builds/unix/
[root@Zabbix unix]
# ./configure --prefix=/app/freetype -enable-shared
[root@Zabbix builds]
# cd ../..
[root@Zabbix freetype-2.5.4]
# make
[root@Zabbix freetype-2.5.4]
# make install
rmdir
: failed to remove `
/app/freetype/include/freetype2/freetype/config
': No such
file
or directory
make
: [
install
] Error 1 (ignored)
rm
-f
/app/freetype/include/freetype2/freetype/
*
rmdir
/app/freetype/include/freetype2/freetype
rmdir
: failed to remove `
/app/freetype/include/freetype2/freetype
': No such
file
or directory
make
: [
install
] Error 1 (ignored)
[root@Zabbix freetype-2.5.4]
#
|
7、安装jpeg
1
2
3
4
5
|
[root@Zabbix freetype-2.5.4]
# cd /usr/local/src/
[root@Zabbix src]
# tar zxvf jpegsrc.v9a.tar.gz
[root@Zabbix src]
# cd jpeg-9a/
[root@Zabbix jpeg-9a]
# ./configure --prefix=/app/jpeg --enable-shared
[root@Zabbix jpeg-9a]
# make && make install
|
8、安装libgd
1
2
3
4
5
|
[root@Zabbix jpeg-9a]
# cd /usr/local/src/
[root@Zabbix src]
# tar zxvf libgd-2.1.0.tar.gz
[root@Zabbix src]
# cd libgd-2.1.0
[root@Zabbix 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 libgd-2.1.0]
# make && make install
|
9、安装t1lib
1
2
3
4
5
6
|
[root@Zabbix libgd-2.1.0]
# cd /usr/local/src/
[root@Zabbix src]
# tar zxvf t1lib-5.1.2.tar.gz
[root@Zabbix src]
# cd t1lib-5.1.2
[root@Zabbix t1lib-5.1.2]
# ./configure --prefix=/app/t1lib --enable-shared
[root@Zabbix t1lib-5.1.2]
# make without_doc
[root@Zabbix t1lib-5.1.2]
# make install
|
10、安装php
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 t1lib-5.1.2]
# cd /usr/local/src/
[root@Zabbix src]
# cp -frp /usr/lib64/libltdl.so* /usr/lib/
[root@Zabbix src]
# cp -frp /usr/lib64/libXpm.so* /usr/lib/
[root@Zabbix src]
# tar zxvf php-5.6.3.tar.gz
[root@Zabbix php-5.6.3]
# export LD_LIBRARY_PATH=/app/libgd/lib/
[root@Zabbix 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 php-5.6.3]
# make && make install
[root@Zabbix php-5.6.3]
# cp php.ini-production /app/php/etc/php.ini #复制php配置文件到安装目录
[root@Zabbix php-5.6.3]
# rm -rf /etc/php.ini #删除系统自带配置文件
[root@Zabbix php-5.6.3]
# ln -s /app/php/etc/php.ini /etc/php.ini #添加软链接到 /etc目录
[root@Zabbix php-5.6.3]
# cp /app/php/etc/php-fpm.conf.default /app/php/etc/php-fpm.conf #拷贝模板文件为php-fpm配置文件
[root@Zabbix php-5.6.3]
# ln -s /app/php/etc/php-fpm.conf /etc/php-fpm.conf #添加软连接到 /etc目录
[root@Zabbix php-5.6.3]
# vim /app/php/etc/php-fpm.conf
user = www
group = www
pid = run
/php-fpm
.pid
[root@Zabbix php-5.6.3]
# cp /usr/local/src/php-5.6.3/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm #拷贝php-fpm到启动目录
[root@Zabbix php-5.6.3]
# chmod +x /etc/rc.d/init.d/php-fpm
[root@Zabbix php-5.6.3]
# chkconfig php-fpm on
[root@Zabbix 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=1
#php支持opcode缓存
zend_extension=opcache.so
#文末添加此行,开启opcode缓存功能
[root@Zabbix php-5.6.3]
#
|
11、配置Nginx支持PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
[root@Zabbix php-5.6.3]
# cp /app/nginx/conf/nginx.conf{,bak}
[root@Zabbix php-5.6.3]
# vim /app/nginx/conf/nginx.conf
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
}
63
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
64
#取消FastCGI server部分location的注释,
65 location ~ \.php$ {
66 root html;
67 fastcgi_pass 127.0.0.1:9000;
68 fastcgi_index index.php;
69 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径
70 include fastcgi_params;
71 }
[root@Zabbix php-5.6.3]
# /etc/init.d/nginx restart
Stopping nginx: [ OK ]
Starting nginx: [ OK ]
[root@Zabbix php-5.6.3]
# /etc/init.d/php-fpm start
Starting php-fpm
done
[root@Zabbix php-5.6.3]
#
|
七、测试
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
[root@Zabbix php-5.6.3]
# cd /app/nginx/html/
[root@Zabbix html]
# ls
50x.html index.html
[root@Zabbix html]
# rm -rf *
[root@Zabbix html]
# vim index.php
<?php
phpinfo();
?>
[root@Zabbix html]
# ll -d
drwxr-xr-x 2 root root 4096 Mar 2 14:33 .
[root@Zabbix html]
# chown -R www:www .
[root@Zabbix html]
# chmod -R 700 .
[root@Zabbix html]
# ll -d
drwx------ 2 www www 4096 Mar 2 14:33 .
[root@Zabbix html]
#
|
在浏览器中打开服务器IP地址,会看到下面的界面说明安装配置正常
CentOS 6.5编译安装Nginx+MySQL+PHP
本文转自 justin_peng 51CTO博客,原文链接:http://blog.51cto.com/ityunwei2017/1745419,如需转载请自行联系原作者