I am trying to set up memcached to work with PHP
I've installed it and confirmed that works with php -i | grep memcached
I am running a simple php file to test memcached:
<?php
session_start();
$_SESSION['some'] = 'thing';
echo session_id()."\n";
print_r($_SESSION);
When I run it I get an error:
Warning: session_start(): failed to parse session.save_path in /Applications/XAMPP/xamppfiles/htdocs/public_html/session/s.php on line 2
PHP Warning: session_start(): Failed to initialize storage module: memcached (path: tcp://localhost:11211) in /Applications/XAMPP/xamppfiles/htdocs/public_html/session/s.php on line 2
Warning: session_start(): Failed to initialize storage module: memcached (path: tcp://localhost:11211) in /Applications/XAMPP/xamppfiles/htdocs/public_html/session/s.php on line 2
I found a suggestion to set save_path to this instead:
session.save_path="tcp://localhost:11211?persistent=1&weight=1&timeout=1&retry_interval=15"
but the error remains.
This is part of my php.ini
session.save_handler=memcached
session.save_path="tcp://localhost:11211?persistent=1&weight=1&timeout=1&retry_interval=15"
memcached part
Version 3.0.4
libmemcached version 1.0.18
SASL support yes
Session support yes
igbinary support no
json support no
msgpack support no
memcached.compression_factor 1.3 1.3
memcached.compression_threshold 2000 2000
memcached.compression_type fastlz fastlz
memcached.default_binary_protocol 0 0
memcached.default_connect_timeout 0 0
memcached.default_consistent_hash 0 0
memcached.serializer php php
memcached.sess_binary_protocol 1 1
memcached.sess_connect_timeout 0 0
memcached.sess_consistent_hash 1 1
memcached.sess_lock_expire 0 0
memcached.sess_lock_max_wait not set not set
memcached.sess_lock_retries 5 5
memcached.sess_lock_wait not set not set
memcached.sess_lock_wait_max 2000 2000
memcached.sess_lock_wait_min 1000 1000
memcached.sess_locking 1 1
memcached.sess_number_of_replicas 0 0
memcached.sess_persistent 0 0
memcached.sess_prefix memc.sess. memc.sess.
memcached.sess_randomize_replica_read 0 0
memcached.sess_remove_failed_servers 0 0
memcached.sess_sasl_password no value no value
memcached.sess_sasl_username no value no value
memcached.sess_server_failure_limit 0 0
memcached.store_retry_count 2 2
port 11211 is open:
$netstat -ap tcp | grep -i "listen"
tcp4 0 0 *.11211 *.* LISTEN
tcp6 0 0 *.11211 *.* LISTEN
What should I do to fix this problem?
Related
Background
I'm given a laravel app who's queue is configured by forge. And so I'm trying to make it run now on my localhost which is OSX
This is what I did:
installed beanstalk on OSX
ran beanstalk server on my console: $ beanstalk
ran the laravel worker command
$ php artisan queue:work beanstalkd --env=local --queue=default
I then did some actions that create jobs, but they never got processed. I used telnet as a poor man's monitor for beanstalk like so:
$ telnet localhost 11300
Trying ::1...
Connected to localhost.
Escape character is '^]'.
stats
OK 923
---
current-jobs-urgent: 0
current-jobs-ready: 3
current-jobs-reserved: 0
current-jobs-delayed: 0
current-jobs-buried: 0
cmd-put: 3
cmd-peek: 0
cmd-peek-ready: 0
cmd-peek-delayed: 0
cmd-peek-buried: 0
cmd-reserve: 0
cmd-reserve-with-timeout: 652
cmd-delete: 0
cmd-release: 0
cmd-use: 1
cmd-watch: 0
cmd-ignore: 0
cmd-bury: 0
cmd-kick: 0
cmd-touch: 0
cmd-stats: 8
cmd-stats-job: 0
cmd-stats-tube: 0
cmd-list-tubes: 0
cmd-list-tube-used: 0
cmd-list-tubes-watched: 0
cmd-pause-tube: 0
job-timeouts: 0
total-jobs: 3
max-job-size: 65535
current-tubes: 2
current-connections: 2
current-producers: 0
current-workers: 1
current-waiting: 0
total-connections: 8
pid: 56692
version: 1.10
rusage-utime: 0.010171
rusage-stime: 0.031001
uptime: 2023
binlog-oldest-index: 0
binlog-current-index: 0
binlog-records-migrated: 0
binlog-records-written: 0
binlog-max-size: 10485760
id: 3620777b4ee08cdc
Question
I can see that 3 jobs are ready.. but i have no idea how to dispatch them (or for that matter, find out what jobs are exactly inside of them). What should I do?
You can use the beanstalk console web app https://github.com/ptrofimov/beanstalk_console.
I would also log some info in a separated log file, to inform me about some values and details happening within the running job. Then I tail that log file while executing the queued jobs and watching the beanstalk console interface.
I try to enable opcache on wamp but it doesnt work. I changed the settings like this :
[opcache]
zend_extension=C:/wamp/bin/php/php5.5.12/ext/php_opcache.dll
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
I always have the red exclamation mark in the extension of php for opcache
whats wrong? some help pls
And it is in the the phpinfo()
Zend OPcache
Opcode Caching Up and Running
Optimization Enabled
Startup OK
Shared memory model win32
Cache hits 0
Cache misses 1
Used memory 483608
Free memory 133734120
Wasted memory 0
Cached scripts 1
Cached keys 2
Max keys 7963
OOM restarts 0
Hash keys restarts 0
Manual restarts 0
opcache.blacklist_filename no value no value
opcache.consistency_checks 0 0
opcache.dups_fix Off Off
opcache.enable On On
opcache.enable_cli Off Off
opcache.enable_file_override Off Off
opcache.error_log no value no value
opcache.fast_shutdown 1 1
opcache.file_update_protection 2 2
opcache.force_restart_timeout 180 180
opcache.inherited_hack On On
opcache.interned_strings_buffer 8 8
opcache.load_comments 1 1
opcache.log_verbosity_level 1 1
opcache.max_accelerated_files 4000 4000
opcache.max_file_size 0 0
opcache.max_wasted_percentage 5 5
opcache.memory_consumption 128 128
opcache.mmap_base no value no value
opcache.optimization_level 0xFFFFFFFF 0xFFFFFFFF
opcache.preferred_memory_model no value no value
opcache.protect_memory 0 0
opcache.restrict_api no value no value
opcache.revalidate_freq 60 60
opcache.revalidate_path Off Off
opcache.save_comments 1 1
opcache.use_cwd On On
opcache.validate_timestamps On On
I found this If you want to know if it works : https://github.com/rlerdorf/opcache-status/blob/master/opcache.php
In PHP5.5.12 opcache is delivered as a zend extension but it is found in the standard ext folder.
You would therefore load it just like any other PHP extension, apart from using the zend_extension rather than extension paramter, so edit your php.ini file using the wampmanager menus to make sure you edit the right file like so :-
wampmanager -> PHP -> php.ini
First check that this parameter is set correctly :
extension_dir = "C:/wamp/bin/php/php5.5.12/ext/"
Now where you have loaded the OpCache dll in your example, do it like this and it will be loaded from the default extension folder just like a normal extension= would be :-
zend_extension=php_opcache.dll
You could do it like this :-
zend_extension="C:/wamp/bin/php/php5.5.12/ext/php_opcache.dll"
but there is no need to specify the full path as it is loaded from the standard ext folder.
Warning
If you are still developing you almost definitely don't what this turned on as it won't add any benefit and could add time to a standard compilation, recaching after every code change, and possibly not re-compiling and using the cached code when you don't want it to.
Since you are working on windows i think you should set the path like this
zend_extension=C:\path\to\php_opcache.dll (win) [Note the slash]
for your case:
zend_extension=C:\wamp\bin\php\php5.5.12\ext\php_opcache.dll
Note that when the path contains spaces you should wrap it in quotes:
zend_extension="C:\Program Files\PHP5.5\ext\php_opcache.dll"
Try it out and see if it helps
I am using Yii 1.1.12 and recently upgraded my PHP from 5.3 to 5.5 and have found that APC is no longer to be used because OpCache has been made part of PHP5.5. In my Yii main.config file, I have the following entry:
'cache'=>array(
'class'=>'system.caching.CApcCache',
),
Two questions:
I am not able to find what should I change the above entry to so
that Yii takes it as its cache? I am extensivly using following in my code
Yii::app()->cache->set('some data to be cached', $CACHE_VARIABLES);
$get_var=Yii::app()->cache->get($CACHE_VARIABLES);
Am I on the right track or missing
something else?
Output of PhpInfo shows following Zend Opcache variables (Local and Master values are mentioned in front of each varaible:
Zend OPcache
Opcode Caching Up and Running
Optimization Enabled
Startup OK
Shared memory model win32
Cache hits 731
Cache misses 144
Used memory 4487992
Free memory 62545312
Wasted memory 75560
Cached scripts 138
Cached keys 261
Max keys 3907
OOM restarts 0
Hash keys restarts 0
Manual restarts 0
opcache.blacklist_filename no value no value
opcache.consistency_checks 0 0
opcache.dups_fix Off Off
opcache.enable On On
opcache.enable_cli On On
opcache.enable_file_override Off Off
opcache.error_log no value no value
opcache.fast_shutdown 0 0
opcache.file_update_protection 2 2
opcache.force_restart_timeout 180 180
opcache.inherited_hack On On
opcache.interned_strings_buffer 4 4
opcache.load_comments 0 0
opcache.log_verbosity_level 1 1
opcache.max_accelerated_files 2000 2000
opcache.max_file_size 0 0
opcache.max_wasted_percentage 5 5
opcache.memory_consumption 64 64
opcache.mmap_base no value no value
opcache.optimization_level 0xFFFFFFFF 0xFFFFFFFF
opcache.preferred_memory_model no value no value
opcache.protect_memory 0 0
opcache.restrict_api no value no value
opcache.revalidate_freq 2 2
opcache.revalidate_path Off Off
opcache.save_comments 0 0
opcache.use_cwd On On
opcache.validate_timestamps On On
Thanks.
I realize there are about 10 of these questions out there but none fit me completely.
Steps completed:
Installed memcache
installed php memcache module
updated laravel config to use memcache
Restarted server
php info results:
memcache.allow_failover 1 1
memcache.chunk_size 8192 8192
memcache.default_port 11211 11211
memcache.default_timeout_ms 1000 1000
memcache.hash_function crc32 crc32
memcache.hash_strategy standard standard
memcache.max_failover_attempts 20 20
memcached-tool results:
accepting_conns 1
auth_cmds 0
auth_errors 0
bytes 0
bytes_read 14
bytes_written 1096
cas_badval 0
cas_hits 0
cas_misses 0
cmd_flush 0
cmd_get 0
cmd_set 0
cmd_touch 0
conn_yields 0
connection_structures 6
crawler_reclaimed 0
curr_connections 5
curr_items 0
decr_hits 0
decr_misses 0
delete_hits 0
delete_misses 0
evicted_unfetched 0
evictions 0
expired_unfetched 0
get_hits 0
get_misses 0
hash_bytes 524288
hash_is_expanding 0
hash_power_level 16
incr_hits 0
incr_misses 0
libevent 2.0.21-stable
limit_maxbytes 268435456
listen_disabled_num 0
lrutail_reflocked 0
malloc_fails 0
pid 12022
pointer_size 64
reclaimed 0
reserved_fds 20
rusage_system 0.043400
rusage_user 0.065101
threads 4
time 1421438137
total_connections 7
total_items 0
touch_hits 0
touch_misses 0
uptime 2607
version 1.4.21
It is in php -m as "memcache"
However, when i go into php artisan tinker and try to do any caching I get the typical Fatal error: Class 'Memcached' not found in vendor/laravel/framework/src/Illuminate/Cache/MemcachedConnector.php on line 44
TL;DR;
I have confirmed install of memcache through multiple methods. Confirmed the module for php is installed. Still not allowing me to use memcached class.
If you are in a ubuntu environment, try to install Memcached with this:
sudo apt-get install php5-memcached
After that restart your server with
sudo service lighttpd restart
or
sudo service apachectl2 restart
or
sudo service nginx restart
Memcache and Memcached are two different PHP extensions. Memcache is the older deprecated one. Memcached is a much newer and fully supported extension.
Check out http://pecl.php.net/package/memcached
You may need to also install libmemcached https://launchpad.net/libmemcached/+download
apt-get install php-memcached
Solved the issue for "Class MemCached not found" coming from Laravel.
In Laravel/Lumen 5.4 just replace the CACHE_DRIVER=file in .env file, the artisan command will work perfectly, But you will not get all the command as same as laravel.
I'm using a Mac and I've installed the Mongo Driver for PHP (5.3.1, my version). It shows up on php info but when I use it in my PHP script it wont work.
Here is what my PHP info shows:
MongoDB Support enabled
Version 1.0.11
Directive Local Value Master Value
mongo.allow_empty_keys 0 0
mongo.allow_persistent 1 1
mongo.auto_reconnect 1 1
mongo.chunk_size 262144 262144
mongo.cmd $ $
mongo.default_host localhost localhost
mongo.default_port 27017 27017
mongo.long_as_object 0 0
mongo.native_long 0 0
mongo.utf8 1 1
Thanks :)
I'm assuming that the version of mongo listed in phpinfo is 1.2 -- MongoClient class wasn't out until v1.3
if so, you need to update mongodb to the newer version.
https://bugs.launchpad.net/ubuntu/+source/php-mongo/+bug/1096587