PHP7.2.13编译安装|phpredis连接测试

 黑渐神|he-jason.com   2019-01-14 18:21   103 人阅读  PHP7.2.13编译安装|phpredis连接测试已关闭评论

版本选择7.2.13

先安装如下依赖包

yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

yum -y install libxslt libxslt-devel
yum install -y gcc make libxml2-devel gd-devel libpng-devel openjpeg-devel curl-devel

配置一
./configure --prefix=/application/php7.2 \
--with-config-file-path=/application/php7.2/etc \
--with-curl \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--with-openssl \
--with-pcre-regex \
--with-pdo-sqlite \
--with-pear \
--with-xmlrpc \
--with-fpm-user=www \
--with-fpm-group=www \
--with-xsl \
--with-zlib \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip \
--enable-static \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--disable-debug \
--disable-fileinfo \
--enable-maintainer-z

配置二
./configure --prefix=/application/php7.2 \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--with-mysqli \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip

添加php.ini:
cp php.ini-production /usr/local/php7.2/php.ini

修改php.ini:
expose_php = Off
max_execution_time = 120
memory_limit = 128M
file_uploads = On
post_max_size = 8M
upload_max_filesize = 10M
date.timezone =Asia/Shanghai

opcache.enable=1
pcache.memory_consumption=128
opcache.validate_timestamps=60

zend_extension="opcache.so"

修改 php-fpm配置文件:
pid=run/php-fpm.pid
log_level = notice
error_log = log/php-fpm.log
daemonize = yes
emergency_restart_threshold = 60
emergency_restart_interval = 60s

修改www.conf配置:
listen = 127.0.0.1:9000
user = nginx
group = nginx
pm = dynamic
pm.max_children = 500
pm.start_servers = 50
pm.min_spare_servers = 50
pm.max_spare_servers = 250
pm.status_path = /status
request_terminate_timeout = 120
request_slowlog_timeout = 5s
slowlog = var/log/slow.log

复制启动脚本:
cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm

PHP启动命令:
/etc/init.d/php-fpm start
/etc/init.d/php-fpm stop
/etc/init.d/php-fpm restart

添加phpredis模块
wget https://github.com/phpredis/phpredis/archive/develop.zip
unzip develop.zip

生成config配置文件
cd phpredis-develop/
/application/php7.2/bin/phpize
编译
./configure --with-php-config=/application/php7.2/bin/php-config
make
make install

redis连接进行测试

<?php

$redis=new Redis();
$redis->connect("127.0.0.1",6379);
$redis->auth('test');
echo "Connection to redis server sucessfully";
?>
</br>
<?php
echo "Server is running:" . $redis->ping();
?>
</br>
<?php
echo "set keys:hello=world" . $redis->set("hello","world");
?>
</br>
<?php
echo "get keys:hello:" . $redis->get("hello");
?>
# php redis.php 
Connection to redis server sucessfully</br>
Server is running:+PONG</br>
set keys:hello=world1</br>
get keys:hello:world

mysql连接测试

本文地址:https://www.he-jason.com/he-jason/talkops/760.html
版权声明:本文为原创文章,版权归 黑渐神|he-jason.com 所有,欢迎分享本文,转载请保留出处!
双11拉新分百万红包

评论已关闭!