Gavin

centos6.5配置安装php7

自从blog换了hhvm后,打开速度确实飞快,但这接近一年的时间里,也经常发现无缘无故的500,hhvm进程假死

现在php7已经出到RC6了,所以,果断抛弃hhvm,滚回php7的大营来

简单记录下安装时碰到的小问题

先从官网下好php源码包


1
2
3
4
cd /var/soft
wget https://downloads.php.net/~ab/php-7.0.0RC6.tar.gz
tar zxvf php-7.0.0RC6.tar.gz
cd /var/soft/php-7.0.0RC6.tar.gz

接下来编译安装


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
./configure \
--prefix=/usr/local/php7 \
--exec-prefix=/usr/local/php7 \
--bindir=/usr/local/php7/bin \
--sbindir=/usr/local/php7/sbin \
--includedir=/usr/local/php7/include \
--libdir=/usr/local/php7/lib/php \
--mandir=/usr/local/php7/php/man \
--with-config-file-path=/usr/local/php7/etc \
--with-mysql-sock=/var/run/mysql/mysql.sock \     #注意mysql.sock的真实路径
--with-mcrypt=/usr/include \
--with-mhash \
--with-openssl \
--with-mysqli=shared,mysqlnd \
--with-pdo-mysql=shared,mysqlnd \
--with-gd \
--with-iconv \
--with-zlib \
--enable-zip \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-freetype-dir \
--enable-opcache \
--enable-fpm \
--with-fpm-user=daemon \
--with-fpm-group=daemon \
--without-gdbm \
--disable-fileinfo

make
make install
make test

编译要很久。。耐心等

 

过程中可能会碰到各种小错误,无非是依赖的库没有装,可能遇到的是下面这些。。偷懒统一yum装一下


1
2
3
4
5
6
yum install libxml2 libxml2-devel
yum install freetype freetype-devel
yum install libcurl libcurl-devel
yum install libjpeg libjpeg-devel
yum install libpng libpng-devel
yum install libmcrypt libmcrypt-devel

接下来需要把对应的配置文件等复制到指定位置


1
2
3
4
5
6
7
8
cp php.ini-development /usr/local/php7/etc/php.ini
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
echo -e '\nexport PATH=/usr/local/php7/bin:/usr/local/php7/sbin:$PATH\n' >> /etc/profile && source /etc/profile
ln -s /usr/local/php7/etc/php.ini /etc/php.ini
cp /var/soft/php-7.0.0RC6/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm

配置php.ini,修改post、上传文件大小(看个人需要),添加mysqli扩展,开启opcache

 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
;修改post data大小
post_max_size = 128M

;修改上传文件大小
upload_max_filesize = 128M

;添加mysqli扩展
extension=mysqli.so
extension=pdo_mysql.so

;默认时区
date.timezone = Asia/Hong_Kong

;开启opcache
zend_extension=opcache.so
opcache.enble_cli=1
opcache.memory_consumption=128      //共享内存大小, 这个根据你们的需求可调
opcache.interned_strings_buffer=8   //interned string的内存大小, 也可调
opcache.max_accelerated_files=4000  //最大缓存的文件数目
opcache.revalidate_freq=60          //60s检查一次文件更新
opcache.fast_shutdown=1             //打开快速关闭, 打开这个在PHP Request Shutdown的时候
                                    //   会收内存的速度会提高
opcache.save_comments=0             //不保存文件/函数的注释

最后,再按照个人需要配置好nginx和php-fpm.conf,就可以启动了

最后,上PHP7下压wordpress ab数值


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
./ab -s10 -kc 200 -n 2000 -H 'Host: blog.bingxuecandong.com' http://127.0.0.1/
This is ApacheBench, Version 2.3 <$Revision: 1604373 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 200 requests
Completed 400 requests
Completed 600 requests
Completed 800 requests
Completed 1000 requests
Completed 1200 requests
Completed 1400 requests
Completed 1600 requests
Completed 1800 requests
Completed 2000 requests
Finished 2000 requests


Server Software:        nginx/1.6.2
Server Hostname:        127.0.0.1
Server Port:            80

Document Path:          /
Document Length:        33567 bytes

Concurrency Level:      200
Time taken for tests:   130.894 seconds
Complete requests:      2000
Failed requests:        105
   (Connect: 0, Receive: 0, Length: 105, Exceptions: 0)
Non-2xx responses:      105
Keep-Alive requests:    105
Total transferred:      64060485 bytes
HTML transferred:       63628575 bytes
Requests per second:    15.28 [#/sec] (mean)
Time per request:       13089.358 [ms] (mean)
Time per request:       65.447 [ms] (mean, across all concurrent requests)
Transfer rate:          477.94 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    4  13.0      0      66
Processing:   409 11823 12169.0   8614  101131
Waiting:      158 11650 12207.3   8434  101131
Total:        475 11827 12169.5   8615  101157

Percentage of the requests served within a certain time (ms)
  50%   8615
  66%   8839
  75%   9109
  80%   9331
  90%  12574
  95%  60008
  98%  60081
  99%  60084
 100%  101157 (longest request)

参考去年hhvm3.2下的数值


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
Benchmarking 127.0.0.1 (be patient)
Completed 200 requests
Completed 400 requests
Completed 600 requests
Completed 800 requests
Completed 1000 requests
Completed 1200 requests
Completed 1400 requests
Completed 1600 requests
Completed 1800 requests
Completed 2000 requests
Finished 2000 requests


Server Software:        nginx/1.6.2
Server Hostname:        127.0.0.1
Server Port:            80

Document Path:          /
Document Length:        39875 bytes

Concurrency Level:      200
Time taken for tests:   186.317 seconds
Complete requests:      2000
Failed requests:        0
Keep-Alive requests:    0
Total transferred:      80132000 bytes
HTML transferred:       79750000 bytes
Requests per second:    10.73 [#/sec] (mean)
Time per request:       18631.700 [ms] (mean)
Time per request:       93.158 [ms] (mean, across all concurrent requests)
Transfer rate:          420.00 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    4   9.8      0      39
Processing:   695 17716 3130.8  18519   20190
Waiting:      695 17714 3130.8  18516   20190
Total:        726 17720 3123.1  18520   20190

Percentage of the requests served within a certain time (ms)
  50%  18520
  66%  18759
  75%  18899
  80%  19012
  90%  19481
  95%  19718
  98%  19890
  99%  19997
 100%  20190 (longest request)

 

 

码字很辛苦,转载请注明来自淡兰色的海洋《centos6.5配置安装php7》

评论