I am running LAMPP on ubuntu with PHP 5.6.23.
I decided to store my sessions in the Redis and I installed it. I also installed Predis too.
As a searched in the web I changed my php.ini to :
session.save_handler = redis
session.save_path = "127.0.0.1:6379"
But when tried create a session I am taking this error:
Warning: session_start(): Cannot find save handler 'redis' - session startup failed in /path/to/the/Untitled.php
You can think that there is a problem in Redis but it's not. It's working properly I can set something and I can check it with Redis-CLI :
My redis 'set' PHP code is :
<?php
require "predis/autoload.php";
$redis = new Predis\Client([
'scheme' => 'tcp',
'host' => '127.0.0.1',
'port' => 6379,
]);
$redis->set('x', '42');
$redis->set('name','test');
?>
Results in telnet:
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
MONITOR
+OK
KEYS *
+1471853424.389215 [0 127.0.0.1:36912] "KEYS" "*"
*2
$4
name
$1
x
Session php code:
<?php
session_start();
$count = isset($_SESSION['cont']) ? $_SESSION['cont'] : 1;
echo $count;
$_SESSION['cont'] = ++$count;
?>
It must increase the number every refresh but It just displays an error.
I re-Installed Redis again (v 3.2.3) but still no difference.
Is there any way to solve it?
Could LAMPP be the reason of problem?
EDIT:
I started to use phpredis instead of predis.
You try different things. Predis is a direct client to your Redis Server. If you want to use them as your session handler you have to install the php module.
sudo apt-get install php5-redis
or for PHP7
sudo apt-get install php7.0-redis
Then "redis" should be available as session handler.
Related
On a Nextcloud install I am receiving the error
No memory cache has been configured. To enhance performance, please configure a memcache, if available. Further information can be found in the documentation.
So I have installed APCu, Redis, redis-php and made the required settings in NCs config.php
'memcache.local' => '\OC\Memcache\APCu',
'memcache.locking' => '\OC\Memcache\Redis',
'memcache.distributed' => '\OC\Memcache\Redis',
'filelocking.enabled' => 'true',
'redis' =>
array (
'host' => '127.0.0.1',
'port' => '6379',
When I test the redis connection
redis-cli ping
I get a
PONG
(This works both w/ localhost and unix socket)
But Nextcloud obviously does not connect to Redis.
The http user is a member of the redis group.
php-redis module is activated.
Solved. The issue was with the location of the above code inside Nextcloud's config.php.
Now it is working as expected.
I’m working on Laravel 5 with postgres as database. I’ve configured postgres 9.4 and pgAdmin III and these are working normally. When I try to run migrate it is giving me error:
[PDOException]
could not find driver
This is my database.php
'default' => 'pgsql',
'pgsql' => [ 'driver' => 'pgsql',
'host' => '127.0.0.1',
'database' => 'fms',
'username' => 'postgres',
'password' => 'root',
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public', ],
Initially I though, it was due to configuration of postgres on windows 7 but I tried with plain php it works perfect
<?php
$host = "host=127.0.0.1";
$port = "port=5432";
$dbname = "dbname=fms";
$db = pg_connect( "$host $port $dbname user=postgres password=root" );
if(!$db){
echo "Error : Unable to open database\n";
} else {
echo "Opened database successfully\n";
}
?>
I’ve enabled php_pgsql and php_pdo_sql in wamp as well. I’m not sure how to fix this on laravel 5.
As you said you already choosed Default Database as Postgres SQL
'default' => 'pgsql',
It is a must that you need to uncomment the pdo and postgres shared object in your php configuration settings (php.ini)
i.e., You need to uncomment the following lines in your php.ini
extension=pdo_pgsql.so
extension=pgsql.so
Note :
Don't forget to stop and start your apache after doing this changes (or php-fpm if using that instead).
I had the same problem with Laravel-WAMP-PostgreSql driver not found exception. I even successfully established direct connection to Postgre as you have, but with no luck with the "php artisan migrate" command.
After long research I found out that there are multiple php.ini files in which "extension=php_pdo_pgsql.dll" and "extension=php_pgsql.dll" are comented out.
The solution is (of course) to uncoment the extensions in the following files:
~/wamp/bin/php/php5.5.*/php.ini
~/wamp/bin/php/php5.5.*/phpForApache
~/wamp/bin/php/php5.5.*/php.ini.install
~/wamp/bin/php/php5.5.*/php.ini-development
~/wamp/bin/php/php5.5.*/php.ini-production
and
~/wamp/bin/apache/apache2.4.9/php.ini
** You can leave off the "php.ini-development" and "php.ini-production" (don't need to uncoment these files).
Like #jeff said, this is probably caused by not setting DB_CONNECTION=pgsql in the .env-file. The .env-file has MySQL preconfigured, so you must edit this file.
You have to make DB related changes in
config/database.php
.env file
and other settings in
php.ini settings
If you are still getting error, then clear cache and config
php artisan cache:clear
php artisan config:clear
It should work now!
Run this command to easily uncomment the lines extension=pdo_pgsql.so and extension=pgsql.so from php.ini
sed -ri -e 's!;extension=pdo_pgsql!extension=pdo_pgsql!' $PHP_INI_DIR/php.ini
sed -ri -e 's!;extension=pgsql!extension=pgsql!' $PHP_INI_DIR/php.ini
If you do not have the drivers already installed, or it gives error like unable to load dynamic library PGSQL run this:
apt-get update && apt-get install -y libpq-dev && docker-php-ext-install pdo pgsql pdo_pgsql
This will install the pgsql and pdo_pgsql drivers.
you gotta modify .env file , then go to config>database.php and change the default to pgsql, and also in all your models file you need to change $protected $connection= 'pgsql'.
I'm using PHP7.3 and this worked for me, I forgot this:
apt-get install php7.3-pgsql
Everything runs smoothly afterwards. Just use whatever version of PHP you are using.
I am trying to use beanstalkd as the queue driver for my laravel app. I am getting this error when I am trying to push something on the queue.
Pheanstalk_Exception_ConnectionException
Socket error 111: Connection refused (connecting to localhost:11300)
Please note that in 'queue.php' I have just changed the default driver to 'beanstalkd' but haven't changed any settings for the driver. The settings for the driver are as follows-
'beanstalkd' => array(
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
),
Please help me with this.
Figured it out. Did these two things -
$ sudo vim /etc/default/beanstalkd
> START yes # uncomment
$ sudo service beanstalkd start
# Alternatively: /etc/init.d/beanstalkd start
Got it from this link - http://fideloper.com/ubuntu-beanstalkd-and-laravel4
The answer by #halkujabra is correct. The error is because beanstalkd is not running. To fix it you just have to start beanstalkd. For MacOS use this script https://gist.github.com/finger-berlin/1942295 to to that.
Download and save it as script.sh
Make it executable: chmod a+x script.sh
Run ./script.sh start
I am developing an laravel app using ubuntu as OS and my database is in a remote Azure Server.
After long a research I'm about to give up. Installed freetds, php5-sybase etc etc.
here is my connection file: (the default is set to sqlsrv)
....
'sqlsrv' => array(
'driver' => 'sqlsrv',
'host' => 'myhostname:myport',
'database' => 'mydatabasename',
'username' => 'myusername',
'password' => 'mypassword'
),
....
and the error that I am getting is this one:
PDOException
SQLSTATE[01002] Adaptive Server connection failed (severity 9)
Any sugestions? If you guys need more details please ask :)
Thanks in advance
I solved my problem. It was missing #domain in my query string example:
$pdo = new PDO("dblib:host=xxxx:1433;dbname=yyyy", 'username#domain', 'password');
I get solution in Read from the server failed when trying to connect to sql-azure from tsql
Edit /etc/freetds/freetds.conf file and use 8.0 TDS version.
If haven't this file install FreeTDS with
sudo apt-get install freetds-bin
Check these:
port separator is "," on windows and ":" on linux/Mac. Since you have 1433, the default one, it is better probably not to use it at all
definitely test first from command line using one of these :
$ tsql -S sectionNameInFreetdsconf -U user -P pass
$ tsql -H hostname -p port -U user -P pass
locate freetds.conf on your disk. It is possible it exists in several places and tsql uses one while PHP used another one. Best is to symlink them into one common file and test on that. Note that a common place for that file is ~/.freetds.conf beside /etc/ or /usr/local/etc/
there should be a [global] section on your freetds.conf file. Put there these lines :
tds version = 8.0
text size = 20971520
client charset = UTF-8
i have a problem with yii and storing data in memcache. For my application i use system.caching.CMemCache and the following config:
'servers' => array(
'server1' => array('host' => 'localhost', 'port' => 11211, 'weight' => 50),
'server2' => array('host' => '192.168.0.2', 'port' => 11211, 'weight' => 50)
),
if memcache on both systems is running, everything is ok and the values get spread up on the servers. but if one server fails (or if i stop the memcache manually) the application throw errors like
MemcachePool::get(): Server 192.168.0.2 (tcp 11211, udp 0) failed with: Connection refused (111)
this isn't really nice, i thought if one server failed yii would choose another server for reading and writing or at least produce some cache misses and do not throw an exeption :(
is this normal or are there some configuration issues?
I think its normal you are seeing those messages as discussed here, given you are using memcache extension
And also read this SO.
There are two version of extension for php one is memcache while the other is memcached. You can install each of them on ubuntu box like :
sudo apt-get install php5-memcache
and
sudo apt-get install php5-memcached
Memecached extension handles failover situations ,as I read from the above links and confirm by testing following settings in yii
'cache'=>array(
'class'=>'CMemCache',
'useMemcached'=>true,
'servers'=>array(
array(
'host'=>'localhost',
'port'=>11211,
'weight'=>60,
),
array(
'host'=>'192.168.33.31',
'port'=>11211,
'weight'=>30,
),
),
),
Install the memcached extension for php as described above and add 'useMemcached'=>true, setting to cache configs.As I test on my localhost, it handles the failover situation, but the page response time drops significantly.
Hope this will be helpful.
Is this variable true?
http://www.php.net/manual/en/memcache.ini.php#ini.memcache.allow-failover
Otherwise this link can also be useful:
Memcache : Confusions
(Probably this is only a notice.)