LNMP+memcached

 29  yum -y install  mamcached
   30  yum -y install  memcached
   31  rpm -qa memcached
   32  ps -C memcached
   33  systemctl start memcached
   34  systemctl status memcached
   35  ss -ntulp | grep memcached
   36  ps -C memcached
   37  ss -ntulp  | grep nginx
   38  nginx
   39  nginx -s reload
   40  ss -ntulp  | grep nginx
   41  systemctl  restart  php-fpm
   42  systemctl  restart  mariadb
   43  ss -ntulp | grep php-fpm
   44  ss -ntulp | grep mysql
   45  cd /usr/local/nginx/conf/
   46  ls
   47  cp nginx.conf.default  nginx.conf
   48  cd ~


   49  vim /usr/local/nginx/conf/nginx.conf
 65         location ~ \.php$ {
 66             root           html;
 67             fastcgi_pass   127.0.0.1:9000;
 68             fastcgi_index  index.php;
 69        #     fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
 70             include        fastcgi.conf;
 71         }
43         location / {
 44             root   html;
 45             index  index.php index.html index.htm;
 46         }
 47 
:wq


   50  nginx -s reload
   51  ss -ntulp | grep nginx


创建PHP页面,使用PHP语言测试memcached服务
创建PHP首页文档/usr/local/nginx/html/index.php,测试页面可以lnmp_soft/php_scripts/mem.php:
[root@proxy ~]# ls lnmp_soft/php_scripts/
mem.php  mysql.php  php-memcached-demo.tar.gz  test.php
[root@proxy ~]# cp -r lnmp_soft/php_scripts/mem.php   /usr/local/nginx/html/
[root@proxy ~]# ls /usr/local/nginx/html/
50x.html  index.html  mem.php
[root@proxy ~]# mv /usr/local/nginx/html/mem.php  /usr/local/nginx/html/test.php
[root@proxy ~]# ls/usr/local/nginx/html/
-bash: ls/usr/local/nginx/html/: 没有那个文件或目录
[root@proxy ~]# ls /usr/local/nginx/html/
50x.html  index.html  test.php
[root@proxy ~]# vim /usr/local/nginx/html/test.php 
<<?php
$memcache=new Memcache;
$memcache->connect('localhost',11211) or die ('could not connect!! ');
$memcache->set('key', 'test');
$get_values=$memcache->get('key');
echo $get_values;
?>>

2)客户端测试(结果会失败)
[root@clent ~]# firefox  http://192.168.4.5/test.php

注意:这里因为没有给PHP安装扩展包,默认PHP无法连接memcached数据库,需要给PHP安装扩展模块才可以连接memcached数据库。

3)为PHP添加memcache扩展
[root@proxy ~]# yum -y install  php-pecl-memcache
[root@proxy ~]# systemctl  restart  php-fpm

4)客户端再次测试(结果会成功显示数据结果)
  1. [root@client ~]# firefox http://192.168.4.5/test.php












  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

运维螺丝钉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值