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