初始工作关闭防火墙
1.yum -y install httpd mariadb-server mariadb php
2.yum install libevent libevent-deve
3.安装memcache,这里我们不要考虑对别的包有什么依赖yum会帮我们解决的,这也是yum的强悍之处
命令如下: yum -y install php-pecl-memcache(yum -y install php*memcach*)
安装软件:
4.#yum install memcached -y
修改配置文件:
# vim /etc/sysconfig/memcached
# cat /etc/sysconfig/memcached
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="1500"z
5.[root@server 1802]# systemctl start memcached.service
[root@server 1802]# ps aux | grep memca
6.vim /var/www/html/memcache.php
php测试memcached代码:
<?php
$memcache = new Memcache();
$memcache->connect('10.18.44.105',11211) or die ("could not connect");
$version = $memcache->getVersion();
echo "Server's version: ".$version."<br/>\n";
$memcache->set('key','hello everybody',false,1000) or die("Failed to save data at the server"); //1000为过期时间
echo "Store data in the cache(data will expire in 1000 seconds)<br/>\n";
$get_result = $memcache->get('key');
echo "Date from the cache:<br/>\n";
var_dump($get_result);
?>
测试
10.18.44.105/memcache.php
下面说一下我的一般排错办法
1.查看相关文件的权限时候设置正常
2.查看linux的防火墙的设置
3.动态查看apache的错误日志的提示信息
4.查看linux的SELINUX的设置