? memcached是一套分布式的高速緩存系統(tǒng),運(yùn)行在內(nèi)存中。memcached缺乏認(rèn)證以及安全管制,這代表應(yīng)該將memcached服務(wù)器放置在防火墻后。
成都創(chuàng)新互聯(lián)擁有10多年成都網(wǎng)站建設(shè)工作經(jīng)驗(yàn),為各大企業(yè)提供網(wǎng)站設(shè)計(jì)制作、成都網(wǎng)站設(shè)計(jì)服務(wù),對于網(wǎng)頁設(shè)計(jì)、PC網(wǎng)站建設(shè)(電腦版網(wǎng)站建設(shè))、app軟件定制開發(fā)、wap網(wǎng)站建設(shè)(手機(jī)版網(wǎng)站建設(shè))、程序開發(fā)、網(wǎng)站優(yōu)化(SEO優(yōu)化)、微網(wǎng)站、國際域名空間等,憑借多年來在互聯(lián)網(wǎng)的打拼,我們在互聯(lián)網(wǎng)網(wǎng)站建設(shè)行業(yè)積累了很多網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、網(wǎng)絡(luò)營銷經(jīng)驗(yàn),集策劃、開發(fā)、設(shè)計(jì)、營銷、管理等網(wǎng)站化運(yùn)作于一體,具備承接各種規(guī)模類型的網(wǎng)站建設(shè)項(xiàng)目的能力。
服務(wù)器 | 角色 | 地址 |
---|---|---|
centos7-1 | 服務(wù)端 | 192.168.45.130 |
centos7-2 | 客戶端 | 192.168.45.132 |
[root@localhost libevent-2.1.8-stable]# yum install gcc gcc-c++ make -y
掛載軟件包,并到掛載目錄下解壓
[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
[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/
啟動服務(wù)
[root@localhost memcached-1.5.6]# memcached -d -m 32m -p 11211 -u root
//“-d”:以守護(hù)進(jìn)程的方式運(yùn)行(后臺運(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
#關(guān)閉防火墻和安全功能
[root@localhost memcached-1.5.6]# systemctl stop firewalld.service
[root@localhost memcached-1.5.6]# setenforce 0
[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)
詳情請見本人之前的博客,里面有詳細(xì)部署過程,這里就不在贅述了
博客地址:https://blog.csdn.net/Parhoia/article/details/102675756
博客最后的論壇架構(gòu)不用安裝
[root@localhost ~]# MySQL -uroot -p
mysql> create database sky;
mysql> grant all on sky.* to 'skyuser'@'%' identified by '123123';
mysql> flush privileges;
[root@localhost htdocs]# vim /usr/local/httpd/htdocs/index.php
Success!!!";
else echo "Fail!!";
mysql_close();
?>
[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生成啟動腳本
[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
[root@localhost memcache-2.2.7]# vim /usr/local/httpd/htdocs/index.php
connect('192.168.142.136',11211); //memached服務(wù)端地址
$memcache->set('key',Memcache test Successfull!!!',0,60);
$result = $memcache->get('key');
unset($memcache);
echo $result;
?>