1

I have installed redis packages on my AWS ubuntu server and everything is working fine from the command line.

I have run the below things from command line and it shows me correct response.

netstat -nlpt | grep 6379
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      23504/redis-server

so my redis server is running correctly on 6379 port also I have added this port on aws security group so firewall is also not blocking.

Also when I check my redis log it also seems to be fine. below is my log.

The server is now ready to accept connections on port 6379

But when I run the below code from my PHP and I get the below error.

$redis = new Redis();
$redis->connect('localhost');
$redis->set('param',999);
echo $redis->get('param');die;

Error I am getting...

The mcook.co.in page isn’t working

mcook.co.in is currently unable to handle this request.
HTTP ERROR 500

enter image description here

I have tried the below solution mentioned in stackoverflow.com but none of are working for me.

Redis - Connect to Remote Server.

Community
  • 1
  • 1
Raj Jagani
  • 738
  • 1
  • 6
  • 21
  • What are the entries of your server error log or other logs? – Polygnome Aug 16 '16 at 18:41
  • a 500 error is a generic "something went wrong" error. But it could be a thousand things that caused it. You need to look at the server error logs to see what the issue was. That will give you more details. On debian systems (ubuntu, etc), the error logs default to `/var/log/apache2/error.log` and on centos systems (centos, redhat, etc), the logs default to `/var/log/httpd/error.log` or similar. After you find that, go look the error up on the [php error reference page](http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php). – Jonathan Kuhn Aug 16 '16 at 18:46
  • @JonathanKuhn : I have already checked the my php log which is not showing and major error or warning. that's why I am confused why redis class gives this error because the same thing on my localhost working fine. – Raj Jagani Aug 16 '16 at 19:01
  • "not showing any major error or warning". Depending on the settings of the server, even a simple warning or notice can show a 500 error, even completely unrelated to this code. You should break down the problem into the most simple/basic script and test that. You can also try turning on `error_reporting` and `display_errors` in the server config (apache htaccess would work) and see if you can get the errors displaying to the page. – Jonathan Kuhn Aug 16 '16 at 19:03
  • after enabled the errors I got this `Fatal error: Class 'Redis' not found` but I have already installed the redis with php. Any idea what i need to install ? – Raj Jagani Aug 16 '16 at 19:15
  • 1
    Depending how you installed it, you may need to add it to the php.ini file. `extension=redis.so` or something similar. If you installed it via package manager it will normally get added via a conf.d directory. But via PECL it will not. – datasage Aug 16 '16 at 19:44
  • @datasage :yes its working now as I know i need to load that module but I have added that in wrong php.ini so it was not working but now I have found this and its working fine. – Raj Jagani Aug 16 '16 at 20:20

0 Answers0