简体   繁体   English

Phpredis和apache

[英]Phpredis and apache

Is redis compatible with an apache server? Redis与apache服务器兼容吗? I'm trying to run redis from a php script stored in my apache servers web directory. 我正在尝试从存储在我的apache服务器Web目录中的php脚本运行redis。

<?php 
//Connecting to Redis server on localhost 
$redis = new Redis(); 
$redis->connect('127.0.0.1', 6379); 
echo "Connection to server sucessfully"; 
//check whether server is running or not 
echo "Server is running: ".$redis->ping(); 
?>

When I try loading my web page I get a 505 programming error. 当我尝试加载网页时,出现505编程错误。 Does my apache setup even matter? 我的apache设置是否重要? I'm thinking my phpredis extension might not be setup correctly. 我以为我的phpredis扩展名可能未正确设置。 I'm able to ping redis from the raspberry pi terminal. 我可以从树莓派终端ping Ping Redis。 If that is my issue does anybody have any good tutorials on adding a redis extension to php? 如果那是我的问题,那么有人在向PHP添加Redis扩展方面有任何好的教程吗?

  1. Makre sure you installed that extension... Makre确定您安装了该扩展程序...
  2. Check https://github.com/phpredis/phpredis 检查https://github.com/phpredis/phpredis
  3. Use something like Redis Desktop Manager to easily verify if your redis is running and have nice too see what's inside (if you're on localhost or access via remote is allowed) 使用Redis Desktop Manager之类的工具轻松验证您的Redis是否正在运行,并且还很高兴了解其中的内容(如果您使用的是localhost或允许通过远程访问)
  4. Read your apache logs, should be around /var/log/ (httpd or apache) on non-windows machine, they should have more detailed info on why you're getting this error. 在非Windows计算机上,请阅读您的apache日志,应该在/ var / log /(httpd或apache)附近,它们应该包含有关为什么出现此错误的详细信息。

Ok, lots of probably beginner mistakes, but I figured it out. 好的,很多可能是初学者的错误,但我发现了。 I didn't have and still don't have a start up script, so I had to start Redis from the raspberry pi terminal using this command I assume I'm going to need to do this after each restart: pi@raspberrypi:~ $ redis-server. 我没有并且仍然没有启动脚本,因此我不得不使用以下命令从raspberry pi终端启动Redis,我认为每次重启后我都需要这样做:pi @ raspberrypi:〜 $ redis服务器。 The quickstart guide on the official Redis page gave me the solution https://redis.io/topics/quickstart . Redis官方页面上的快速入门指南为我提供了解决方案https://redis.io/topics/quickstart

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM