centos7下安装php+memcached简单记录

1)centos7下安装php

需要再添加一个yum源来安装php-fpm,可以使用webtatic(这个yum源对国内网络来说恐怕有些慢,当然你也可以选择其它的yum源)
[root@nextcloud-server ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm 安装php7-fpm和一些其它的必要的组件
[root@nextcloud-server ~]# 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是否已正常安装
[root@nextcloud-server ~]# 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
[root@nextcloud-server ~]# 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
[root@nextcloud-server ~]# mkdir -p /var/lib/php/session
[root@nextcloud-server ~]# chown nginx:nginx -R /var/lib/php/session/
[root@nextcloud-server ~]# ll -d /var/lib/php/session/
drwxr-xr-x. 2 nginx nginx 4096 1月 25 09:47 /var/lib/php/session/ 启动Nginx和php-fpm服务,并添加开机启动
[root@nextcloud-server ~]# systemctl start php-fpm
[root@nextcloud-server ~]# systemctl enable php-fpm

1)安装php的memcached扩展模块

需要先安装依赖库 libmemcached
[root@nextcloud src]# wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
[root@nextcloud src]# tar -zxf libmemcached-1.0.18.tar.gz
[root@nextcloud src]# cd libmemcached-1.0.18/
[root@nextcloud 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 错误。 [root@nextcloud src]# git clone https://github.com/php-memcached-dev/php-memcached.git
[root@nextcloud src]# cd php-memcached/
[root@nextcloud php-memcached]# git checkout php7
[root@nextcloud php-memcached]# phpize
[root@nextcloud php-memcached]# ./configure --disable-memcached-sasl --with-libmemcached-die=/usr/local/libmemcached
[root@nextcloud php-memcached]# make && make install [root@nextcloud ~]# 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
[root@nextcloud ~]# vim /etc/php.ini
......
extension=/usr/lib64/php/modules/memcached.so [root@nextcloud ~]# systemctl restart php-fpm
[root@nextcloud ~]# php -m
....
memcached
上一篇:String拾遗


下一篇:一种解决Code Map与ReSharper冲突导致Visual Studio 2013 Peek Definition失效的办法