memcached是一套分布式的高速緩存系統(tǒng),運(yùn)行在內(nèi)存中。memcached缺乏認(rèn)證以及安全管制,這代表應(yīng)該將memcached服務(wù)器放置在防火墻后。
十多年的高陽網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。全網(wǎng)整合營銷推廣的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整高陽建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)建站從事“高陽網(wǎng)站設(shè)計(jì)”,“高陽網(wǎng)站推廣”以來,每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。
名稱 | 角色 | 地址 |
---|---|---|
centos7-1 | 服務(wù)端 | 192.168.142.66 |
centos7-2 | 客戶端 | 192.168.142.77 |
安裝環(huán)境包
[root@localhost libevent-2.1.8-stable]# yum install gcc gcc-c++ make -y
安裝Libevent軟件本體
[root@localhost memcached]# tar zxf libevent-2.1.8-stable.tar.gz -C /opt/
[root@localhost memcached]# cd /opt/libevent-2.1.8-stable/
//配置并編譯安裝
[root@localhost libevent-2.1.8-stable]# ./configure \
--prefix=/usr/local/libevent
[root@localhost libevent-2.1.8-stable]# make && make install
配置、安裝Memcached
[root@localhost memcached]# tar zxf memcached-1.5.6.tar.gz -C /opt/
[root@localhost memcached]# cd /opt/memcached-1.5.6/
[root@localhost memcached-1.5.6]# ./configure \
--prefix=/usr/local/memached \
--with-libevent=/usr/local/libevent/
[root@localhost memcached-1.5.6]# make && make install
//建立軟鏈接
[root@localhost memcached-1.5.6]# ln -s /usr/local/memached/bin/* /usr/local/bin/
啟動(dòng)服務(wù)
[root@localhost memcached-1.5.6]# memcached -d -m 32m -p 11211 -u root
//“-d”:以守護(hù)進(jìn)程的方式運(yùn)行(后臺(tái)運(yùn)行)
//“-m”:指定最大使用內(nèi)存大小
//“-p”:指定端口
//“-u”:指定用戶
[root@localhost memcached-1.5.6]# netstat -atnp | grep 11211
tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN 12591/memcached
tcp6 0 0 :::11211 :::* LISTEN 12591/memcached
[root@localhost memcached-1.5.6]# systemctl stop firewalld.service
[root@localhost memcached-1.5.6]# setenforce 0
安裝Telent用于連接Memcached
[root@localhost memcached-1.5.6]# yum install telnet -y
//連接memcached
[root@localhost memcached-1.5.6]# telnet 192.168.142.66 11211
Trying 192.168.142.66...
Connected to 192.168.142.66.
Escape character is '^]'.
安裝LAMP架構(gòu)
詳情請(qǐng)見本人之前的博客,里面有詳細(xì)部署過程,這里就不在贅述了
博客地址:
數(shù)據(jù)庫中進(jìn)行提權(quán)
[root@localhost ~]# mysql -uroot -p
mysql> create database sky;
mysql> grant all on sky.* to 'skyuser'@'%' identified by '123123';
mysql> flush privileges;
測(cè)試PHP工具能否連接數(shù)據(jù)庫
```php+HTML
[root@localhost htdocs]# vim /usr/local/httpd/htdocs/index.php
$link=mysql_connect('192.168.142.132','skyuser','123123');
if($link) echo "
**安裝、配置memcache客戶端**
```java
[root@localhost memcached]# tar zxf memcache-2.2.7.tgz -C /opt/
[root@localhost memcached]# cd /opt/memcache-2.2.7/
[root@localhost memcache-2.2.7]# /usr/local/php5/bin/phpize //為memcache生成啟動(dòng)腳本
[root@localhost memcache-2.2.7]# ./configure \
--enable-memcache \
--with-php-config=/usr/local/php5/bin/php-config
//編譯&安裝
[root@localhost memcache-2.2.7]# make && make install
修改PHP的配置文件
[root@localhost memcache-2.2.7]# vim /usr/local/php5/php.ini
//736行后添加
extension_dir = "/usr/local/php5/lib/php/extensions/no-debug-zts-20131226/"
extension = memcache.so
建立測(cè)試頁面
```php+HTML
[root@localhost memcache-2.2.7]# vim /usr/local/httpd/htdocs/index.php
$memcache = new Memcache();
$memcache->connect('192.168.142.136',11211); //memached服務(wù)端地址
$memcache->set('key',Memcache test Successfull!!!',0,60);
$result = $memcache->get('key');
unset($memcache);
echo $result;
?>