memcached 설정 (Cent7,nginx,php7.2,php-fpm)
개요
사전 준비
상세
설치
# yum install epel-release
# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
$ sudo yum install memcached memcached-devel --enablerepo=epel,remi
$ sudo yum install php72-php-pecl-memcache libmemcached libmemcached-devel --enablerepo=remi,epel
$ sudo yum install php72-php-cli php72-php-devel php72-php-pdo php72-php-pecl-msgpack php72-php-pecl-msgpack-devel php72-php-pecl-memcached php72-php-pecl-redis php72-php-phpiredis php72-php-pecl-lua php72-php-pecl-apcu php72-php-pecl-apcu-bc php72-php-pecl-apcu-devel php72-php-xml --enablerepo=remi,epel
설정
htp : // bg. 노마 ds 카후. jp / 2013/12 / m m ぇ d-2. HTML 에서 확인
$ sudo cp -p /etc/sysconfig/memcached /etc/sysconfig/memcached.org
$ vim /etc/sysconfig/memcached
PORT="11211"
USER="memcached"
CACHESIZE="3024"
MAXCONN="65536"
OPTIONS=""
$ sudo systemctl start memcached
$ chmod 755 memcached-tool
$ sudo mv memcached-tool /usr/local/bin
$ which memcached-tool
$ memcached-tool localhost display
$ cat /etc/sysctl.conf|grep net.core.somaxconn
net.core.somaxconn = 2147483647
$ telnet localhost 11211
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
set testkey 0 60 7
testvalue
STORED
get testkey
VALUE mykey 0 7
testvalue
END
delete testkey
DELETED
get testkey
END
flush_all
OK
quit
Connection closed by foreign host.
$ telnet <memcached server private ip> 11211
Trying <memcached server private ip>...
Connected to <memcached server private ip>.
Escape character is '^]'.
get testkey
END
set testkey 0 60 7
myvalue
STORED
get mykey
VALUE testkey 0 7
myvalue
END
delete testkey
DELETED
flush_all
OK
quit
Connection closed by foreign host.
$ sudo vi /etc/php.ini
;; X-Powered-Byを隠す
expose_php = Off
;; PHPタイムゾーン
date.timezone = Asia/Tokyo
;; デフォルト言語
mbstring.language = Japanese
;; 内部文字エンコーディング
mbstring.internal_encoding = UTF-8
;; HTTP入力文字エンコーディング(auto:mgstring.languageの設定で展開)
mbstring.http_input = auto
;; HTTP出力文字エンコーディング(pass:変換しない)
mbstring.http_output = pass
;; HTTP入力変換有効
mbstring.encoding_translation = On
;; デフォルト文字エンコーディング検出順序
mbstring.detect_order = auto
;; 無効な文字出力しない
mbstring.substitute_character = none;
;; 動的ライブラリ格納パスをデフォルトからremi用に変更
extension_dir = "/opt/remi/php72/root/usr/lib64/php/modules"
$ sudo vi /etc/php-fpm.d/www.conf
:
;php_value[session.save_handler] = files
;php_value[session.save_path] = /var/lib/php/session
php_value[session.save_handler] = memcached
php_value[session.save_path] = "<memcached server private ip:11211>"
$ sudo systemctl restart php-fpm
$ sudo vim /etc/php-fpm.d/www.conf
:
php_value[session.save_handler] = memcached
php_value[session.save_path] = "<memcached server private ip>:11211"
$ sudo vim /etc/php.d/30-memcached.ini
extension=memcached
php_value[session.save_handler] = memcached
php_value[session.save_path] = "<memcached server private ip>:11211"
$ sudo systemctl restart php-fpm
$ php --ini | grep memcached
/etc/php.d/30-memcached.ini
# echo "extension=msgpack" > /etc/php.d/20-msgpack.ini
# echo "extension=igbinary" > /etc/php.d/20-igbinary.ini
# php -i | head
설정 확인
# grep -v '^\s*;' /etc/php.ini |grep -v '^\s*$'
:
:
$ vim /documentroot/conncheck.php
<?php
$memcache = new Memcached();
$memcache->addServer('<memcached server private ip>', 11211);
$data = 'memcached for col';
$memcache->set('key', $data, 1000);
echo $get_data = $memcache->get('key');
$ sudo tailf /var/log/nginx/app.error.log
$ sudo tailf /var/log/nginx/error.log
해결된 오류
2018/05/14 17:12:58 [error] 5024#5024: *6543 FastCGI sent in stderr: "PHP message:
PHP Fatal error: Uncaught Error:
Class 'Memcached' not found in /var/source/current/src/app/www/conncheck.php:2
Stack trace:
PHP Warning: PHP Startup: Unable to load dynamic library 'memcached.so'
(tried: /opt/remi/php72/root/usr/lib64/php/modules/memcached.so
(/opt/remi/php72/root/usr/lib64/php/modules/memcached.so: undefined symbol: php_json_decode_ex),
/opt/remi/php72/root/usr/lib64/php/modules/memcached.so.so
(/opt/remi/php72/root/usr/lib64/php/modules/memcached.so.so:
cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'memcached'
(tried: /opt/remi/php72/root/usr/lib64/php/modules/memcached
(/opt/remi/php72/root/usr/lib64/php/modules/memcached: cannot open shared object file: No such file or directory),
/opt/remi/php72/root/usr/lib64/php/modules/memcached.so
(/opt/remi/php72/root/usr/lib64/php/modules/memcached.so:
undefined symbol: igbinary_serialize)) in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'memcached'
(tried: /opt/remi/php72/root/usr/lib64/php/modules/memcached
(/opt/remi/php72/root/usr/lib64/php/modules/memcached: cannot open shared object file: No such file or directory),
/opt/remi/php72/root/usr/lib64/php/modules/memcached.so
(/opt/remi/php72/root/usr/lib64/php/modules/memcached.so:
undefined symbol: php_msgpack_serialize)) in Unknown on line 0
Reference
이 문제에 관하여(memcached 설정 (Cent7,nginx,php7.2,php-fpm)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/ezaqiita/items/e8c077c8a68af90f18ec텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)