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.
Related
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?
I got a very weird problem. My wordpress previously was working fine but recently and suddenly it turned very slow and the nginx returns 502 bad gateway sometimes. So I did some investigation, then I noticed the PHP-FPM processes consume all the CPU even there's no request. Everytime I restarted the wordpress the idle CPU usage just jumped to 0% instantly, and I can see several PHP-FPM processes were working with high CPU consumption, and the MySQL process consumed a lot CPU resource too, no matter if there is a request.
I tried to stop all the plugins - didn't work, same symptom.
I tried to update the wordpress to the latest version but DIDN't
connect to database - CPU usage is normal.
I tried to update the wordpress to the latest version and only keep the file wp-config.php (database username + pwd) - didn't work, same symptom.
This is so weird but seems it's related to the mysql database? But why?
Thanks in advance.
top - 02:08:12 up 56 min, 1 user, load average: 10.18, 9.41, 8.68
Tasks: 115 total, 11 running, 104 sleeping, 0 stopped, 0 zombie
Cpu(s): 36.6%us, 10.4%sy, 0.0%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.1%si, 53.0%st
Mem: 766112k total, 682116k used, 83996k free, 239696k buffers
Swap: 1572860k total, 2664k used, 1570196k free, 125412k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
23854 www 20 0 59952 30m 4688 R 44.5 4.1 3:56.99 php-fpm
24337 www 20 0 60204 32m 4520 R 44.2 4.3 3:53.83 php-fpm
24300 www 20 0 52004 23m 4448 R 42.9 3.2 3:48.47 php-fpm
24287 www 20 0 54324 27m 5140 R 37.6 3.7 3:54.34 php-fpm
23855 www 20 0 54824 26m 4504 R 35.6 3.5 3:57.25 php-fpm
24323 www 20 0 46108 19m 4856 R 35.6 2.6 3:57.73 php-fpm
24274 www 20 0 56356 28m 4548 R 35.2 3.9 3:56.55 php-fpm
24374 www 20 0 55080 26m 4524 R 33.9 3.5 3:52.03 php-fpm
24385 www 20 0 63820 33m 4428 R 33.2 4.5 3:51.53 php-fpm
24394 www 20 0 57900 29m 4444 R 30.6 3.9 3:50.09 php-fpm
24250 mysql 20 0 214m 29m 5860 S 23.9 3.9 1:35.21 mysqld
6 root RT 0 0 0 0 S 1.7 0.0 0:01.31 watchdog/0
216 root 20 0 0 0 0 S 1.0 0.0 0:02.96 kjournald
23850 www 20 0 18624 11m 868 S 0.3 1.6 0:01.89 nginx
23851 www 20 0 18812 12m 876 S 0.3 1.6 0:03.61 nginx
27889 root 20 0 2712 1136 880 R 0.3 0.1 0:00.81 top
It turned out it's caused by an XML RPC attack. It's resolved now.
For more information:
https://medium.com/#tturnbull/throttle-xmlrpc-php-attacks-on-wordpress-with-nginx-3cc4a12b7f76
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 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'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