基本安裝流程 (在 Apache Web 平台上):
-
安裝 Memcached 套件:
#yum install memcached
-
檢查設定檔內容:
#vim /etc/sysconfig/memcached PORT="11211" ##使用埠號 11211 USER="memcached" MAXCONN="1024" ##最大連線使用數 CACHESIZE="512" ##使用 512MB 記憶體 OPTIONS=""
-
啟動 Memcached 套件:
#systemctl enable memcached #systemctl start memcached
-
開啟防火牆設定:
#firewall-cmd --permanent --add-port=11211/tcp #firewall-cmd --reload
-
讓 php 套件使用 memcached ,需安裝下列套件:
#yum -y install php-pecl-memcache
-
重新啟動 Apache Web Server:
#systemctl restart httpd
在 Ngnix 平台上的應用:
-
修改 Nginx 設定檔:
#vim /etc/nginx/conf.d/default.conf server { : (加入以下的設定值:) : location ^~ /cache/ { set $memcached_key $request_uri; memcached_pass 127.0.0.1:11211; } : : }
-
重新啟動 Nginx :
#systemctl restart nginx
※注意:參考資料~~~
- http://nginx.org/en/docs/http/ngx_http_memcached_module.html
- http://blog.octo.com/en/http-caching-with-nginx-and-memcached/
- http://www.ttlsa.com/nginx/application-of-nginx_memcached-to-construct-the-page-cache/
- http://www.icyfire.me/2014/11/30/use-nginx-and-memcached-to-cache-pages.html
安裝 phpMemcachedAdmin 套件
-
下載 phpMemcachedAdmin 套件:
#cd /var/www/html #wget http://phpmemcacheadmin.googlecode.com/files/phpMemcachedAdmin-1.2.2-r262.tar.gz
-
解壓縮 phpMemcachedAdmin 套件:
#mkdir phpMemcachedAdmin #tar zxvf phpMemcachedAdmin-1.2.2-r262.tar.gz -C phpMemcachedAdmi
-
設定相關權限:
#chown -R apache.apache phpMemcachedAdmin #restorecon -R /var/www/html #setsebool -P httpd_can_network_memcache on #setsebool -P httpd_unified on #grep httpd /var/log/audit/audit.log | audit2allow -M http #semodule -i httpd.pp
-
重新啟動 Apache Web Server:
#systemctl restart httpd
-
利用 Firefox 查看網頁:
http://127.0.0.1/phpMemcachedAdmin/
- http://www.phpini.com/php/rhel-centos-7-install-php-memcached
- http://www.liquidweb.com/kb/how-to-install-the-memcached-php-extension-on-centos-7/
- http://www.liquidweb.com/kb/how-to-install-memcached-on-centos-7/
- https://devops.profitbricks.com/tutorials/install-and-configure-memcached-on-centos-7/
- http://blog.elijaa.org/phpmemcachedadmin-installation-guide/
- http://www.techoism.com/install-phpmemcachedadmin-on-linux/