PHP 7.2.2 + redis模块 编译

总是要编译的嘛,记录一篇PHP编译过程。

安装依赖:

1
yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel libxslt libicu-devel libxslt-devel libzip libzip-devel

官网下载包,这里下的是php-7.2.22.tar.gz。

编译安装,这里模块根据自己需要选择,记得要加–with-pear,为了后续使用pecl添加redis模块。

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
$ cd /data/software
$ tar -zxvf php-7.2.22.tar.gz
$ cd php-7.2.22
$ ./configure \
--prefix=/usr/local/php-7.2.2 \
--with-mhash \
--with-openssl \
--with-config-file-path=/usr/local/php-7.2.2/etc \
--disable-short-tags \
--enable-fpm \
--with-fpm-user=php-fpm \
--with-fpm-group=php-fpm \
--enable-xml \
--with-libxml-dir \
--enable-bcmath \
--enable-calendar \
--enable-intl \
--enable-mbstring \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-zip \
--enable-mbregex \
--enable-mysqlnd \
--enable-mysqlnd-compression-support \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-gd \
--enable-ftp \
--with-curl \
--with-xsl \
--with-iconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--enable-sysvsem \
--enable-inline-optimization \
--with-xmlrpc \
--with-gettext \
--with-pear

$ make
$ sudo make install

创建软链接,由于有多版本,这里软链接名设为php72:

1
2
ln -s /usr/local/php-7.2.2/bin/php /usr/bin/php72
ln -s /usr/local/php-7.2.2/sbin/php-fpm /usr/bin/php-fpm72

配置文件:

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
cp /data/software/php-7.2.22/php.ini-production /usr/local/php-7.2.2/etc/php.ini

$ cat /usr/local/php-7.2.2/etc/php-fpm.conf
[global]
pid = /var/run/php-fpm/php-fpm72.pid
error_log = /var/log/php-fpm/php72-error.log
daemonize = yes
include=/usr/local/php-7.2.2/etc/php-fpm.d/*.conf

$ cat /usr/local/php-7.2.2/etc/php-fpm.d/www.conf
[www]
user = apache
group = apache
listen = 127.0.0.1:9090
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
slowlog = /var/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session
php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache

安装redis模块,需要先装igbinary模块:

1
2
3
cd /usr/local/php-7.2.2/bin
./pecl install igbinary
./pecl install redis

启用模块,把以下内容添加到/usr/local/php-7.2.2/etc/php.ini生效:

1
2
extension=igbinary.so
extension=redis.so

查看模块:

1
php -m

看到有redis就完成了。

安装mongodb也是一样,pecl install mongodb再添加extension=mongodb.so到php.ini。


- - END - -


腾讯云
0%