1)centos7下安装php
需要再添加一个yum源来安装php-fpm,可以使用webtatic(这个yum源对国内网络来说恐怕有些慢,当然你也可以选择其它的yum源) [[email protected] ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm 安装php7-fpm和一些其它的必要的组件 [[email protected] ~]# yum -y install php70w-fpm php70w-cli php70w-gd php70w-mcrypt php70w-mysql php70w-pear php70w-xml php70w-mbstring php70w-pdo php70w-json php70w-pecl-apcu php70w-pecl-apcu-devel 完成后,检查一下php-fpm是否已正常安装 [[email protected] ~]# php -v PHP 7.0.25 (cli) (built: Oct 29 2017 13:43:03) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies 配置php-fpm [[email protected] ~]# vim /etc/php-fpm.d/www.conf ..... user = nginx //将用户和组都改为nginx group = nginx ..... listen = 127.0.0.1:9000 //php-fpm所监听的端口为9000 ...... env[HOSTNAME] = $HOSTNAME //去掉下面几行注释 env[PATH] = /usr/local/bin:/usr/bin:/bin env[TMP] = /tmp env[TMPDIR] = /tmp env[TEMP] = /tmp 在/var/lib目录下为session路径创建一个新的文件夹,并将用户名和组设为nginx [[email protected] ~]# mkdir -p /var/lib/php/session [[email protected] ~]# chown nginx:nginx -R /var/lib/php/session/ [[email protected] ~]# ll -d /var/lib/php/session/ drwxr-xr-x. 2 nginx nginx 4096 1月 25 09:47 /var/lib/php/session/ 启动Nginx和php-fpm服务,并添加开机启动 [[email protected] ~]# systemctl start php-fpm [[email protected] ~]# systemctl enable php-fpm
1)安装php的memcached扩展模块
需要先安装依赖库 libmemcached [[email protected] src]# wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz [[email protected] src]# tar -zxf libmemcached-1.0.18.tar.gz [[email protected] src]# cd libmemcached-1.0.18/ [[email protected] libmemcached-1.0.18]# ./configure && make && make install 安装好依赖库之后,我们来安装 memcached : 从 github 克隆 memcached 后,需要手动切换到 php7 分支,不然会提示报错: fatal error : ext / standard / php_smart_str . h : No such file or directory 错误。 [[email protected] src]# git clone https://github.com/php-memcached-dev/php-memcached.git [[email protected] src]# cd php-memcached/ [[email protected] php-memcached]# git checkout php7 [[email protected] php-memcached]# phpize [[email protected] php-memcached]# ./configure --disable-memcached-sasl --with-libmemcached-die=/usr/local/libmemcached [[email protected] php-memcached]# make && make install [[email protected] ~]# find / -name memcached.so /usr/lib64/php/modules/memcached.so /usr/local/src/php-memcached/.libs/memcached.so /usr/local/src/php-memcached/modules/memcached.so [[email protected] ~]# vim /etc/php.ini ...... extension=/usr/lib64/php/modules/memcached.so [[email protected] ~]# systemctl restart php-fpm [[email protected] ~]# php -m .... memcached
原文地址:https://www.cnblogs.com/kevingrace/p/8492344.html
时间: 2024-10-07 22:58:49