I have memcached installed and working as tested by:
nc -U /var/run/memcached/memcached.sock
stats
STAT pid 16360
STAT uptime 2246
STAT time 1412217254
STAT version 1.4.14 (Ubuntu)
STAT libevent 2.0.21-stable
STAT pointer_size 64
STAT rusage_user 0.032563
//and so on...
The problem i have is that when symfony loads and invokes session_start() it throws an error:
Fatal error: Failed to initialize storage module:
user (path: /var/run/memcached/memcached.sock) in /var/www/project/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php on line 147
I have tried to configure session.save_path tons of different ways always with the same error just with the path different:
session.save_path = "/var/run/memcached/memcached.sock"
session.save_path = "unix:/var/run/memcached/memcached.sock"
session.save_path = "unix:///var/run/memcached/memcached.sock"
session.save_path = /var/run/memcached/memcached.sock
session.save_path = unix:/var/run/memcached/memcached.sock
session.save_path = unix:///var/run/memcached/memcached.sock
Does anyone have any ideas as to why i am unable to start the session?
Version Info:
Ubuntu: 14.04.1
NGINX: 1.4.6
HHVM-nightly: 3.4.0-dev+2014.10.01
memcached: 1.4.14
symfony: 2.5.5
UPDATE
I have been digging around and trying different configs. If i run symfony using apache/php5.5.17 configured with the following session parameters it works:
session.handler_name: memcached
session.save_path = "127..0.0.1:11211"
I have also tried this config with nginx/hhvm and i still get the same error.
This is because HHVM does not have an inbuilt memcache[d] session handler. It only comes with Redis and file ones.
You can either use one of those backends, or implement your own using SessionHandlerInterface and session_set_save_handler
Related
I was doing some testing with memcached using php sessions.
The following steps cause problems.
Start memcache
Login to application which creates a session
Restart memcache
Try to navigate to another page
Browser hangs for 30 seconds and logs out
Requests after logging in again take 30 seconds but works. Randomly it stops taking 30 seconds to perform actions and is back to normal speed
What is the cause of this odd behavior
Sometimes I get the following error:
A PHP Error was encountered
Severity: Warning
Message: Unknown: Failed to write session data (memcache). Please verify that the current setting of session.save_path is correct (tcp://10.181.16.192:11211?persistent=1&weight=1&timeout=1&retry_interval=15)
Filename: Unknown
Line Number: 0
EDIT:
If I restart memcache then apache the problem does not occur
I noticed TCP connections change to CLOSE_WAIT when restarting memcached.
But if I restart memcache and apache back to back without delay then it solves the problem.
It seems like there is some sort of bug in the way php handles connections to memcache where it doesn't recognize the connection is valid anymore and causes the issues described.
[root#php-pos-web ~]# netstat -natp | grep '11211'
tcp 1 0 10.181.16.33:58722 10.181.16.192:11211 CLOSE_WAIT 7574/httpd
tcp 205 0 10.181.16.33:58753 10.181.16.192:11211 ESTABLISHED 7583/httpd
tcp 1 0 10.181.16.33:58745 10.181.16.192:11211 CLOSE_WAIT 7578/httpd
tcp 1 0 10.181.16.33:58749 10.181.16.192:11211 CLOSE_WAIT 7573/httpd
There is a bug in starting in 3.0.4 of the memcache pecl extension. This does not happen on the latest stable release (2.2.7). I have reported this bug to the team. I think it has something to do with session locking. This bug does not occur in memcached extension.
I have installed Symfony 2 and I have activated the opcache (ZendOPtimizer) extension and when I intent to generate the cache of a web page O've got this error :
Warning: filemtime(): stat failed for C:/Apache24/htdocs/symfony/app/cache/dev/annotations/Acme-DemoBundle-Controller-SecuredController.cache.php in C:\Apache24\htdocs\symfony\vendor\doctrine\common\lib\Doctrine\Common\Annotations\FileCacheReader.php line 97
This is my opcache config :
zend_extension="c:\php\ext\php_opcache.dll"
opcache.enable=1
opcache.use_cwd=0
opcache.validate_timestamps=0 ; file stat
opcache.revalidate_freq=2 ; seconds
opcache.revalidate_path=0
opcache.save_comments=0
opcache.load_comments=0
opcache.dups_fix=0
opcache.inherited_hack=0
opcache.log_verbosity_level=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.enable_file_override=1
opcache.max_wasted_percentage=5 ; percent waste until restart
opcache.consistency_checks=0
opcache.force_restart_timeout=180
opcache.blacklist_filename=paypal.php
opcache.fast_shutdown=1
opcache.optimization_level=0xffffffff
opcache.enable_slow_optimizations=1
opcache.max_file_size=0
When I disable this extension, the generation of the cache works
Versions :
Symfony 2.3.3
PHP 5.5
Apache 2.4.6 For Windows
I had exactly the same problem on my Mac, using the homebrew php55 version.
As mentioned in the Optimizer documentation, the option opcache.enable_file_override=1 may break some frameworks. It seems that is the case for Symfony2. Switching the value to 0 solved the problem.
1 - Make sure you have disabled APC or it'll create conflicts.
2 - Make sure you've restarted apache entirely after activating opcache.
Some basic information:
Linux: 2.6.32 (64bit)
PHP: 5.4.15
Apache: 2.4.4
MySQL: 5.6.11
APC: 3.1.9
Wordpress: 3.5.1, with Woocommerce(2.0.10)
The problem is, when I enable APC, the following errors occur:
Warning: register_shutdown_function(): Invalid shutdown callback 'wpdb::__destruct' passed in /usr/local/httpd/htdocs/wp-includes/wp-db.php on line 537
Fatal error: Call to undefined method wpdb::init_charset() in /usr/local/httpd/htdocs/wp-includes/wp-db.php on line 542
Here is my APC config in php.ini:
[APC]
; Reference: http://www.php.net/manual/en/apc.configuration.php
extension=apc.so
apc.enabled=1
apc.shm_segments=1
; 32MB per Wordpess install. Ref: http://gregrickaby.com/the-perfect-apc-configuration/
apc.shm_size=320M
;Relative to the number of cached files (you may need to watch your stats for a day or two to find out a good number)
apc.num_files_hint=10000
;Relative to the size of WordPress
apc.user_entries_hint=10000
;The number of seconds a cache entry is allowed to idle in a slot before APC dumps the cache
apc.ttl=7200
apc.user_ttl=7200
apc.gc_ttl=3600
;Setting this to 0 will give you the best performance, as APC will
;not have to check the IO for changes. However, you must clear
;the APC cache to recompile already cached files. If you are still
;developing, updating your site daily in WP-ADMIN, and running W3TC
;set this to 1
apc.stat=1
;This MUST be 0, WP can have errors otherwise!
apc.include_once_override=0
;Only set to 1 while debugging
apc.enable_cli=0
;Allow 2 seconds after a file is created before it is cached to prevent users from seeing half-written/weird pages
apc.file_update_protection=2
;Leave at 2M or lower. WordPress does't have any file sizes close to 2M
apc.max_file_size=2M
;Ignore files
apc.filters = "/usr/local/httpd/htdocs/apc.php,/usr/local/httpd/htdocs/phpinfo.php,wp-cache-config"
apc.cache_by_default=1
apc.use_request_time=1
apc.slam_defense=0
;apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.stat_ctime=1
apc.canonicalize=1
apc.write_lock=1
apc.report_autofilter=0
apc.rfc1867=0
apc.rfc1867_prefix =upload_
apc.rfc1867_name=APC_UPLOAD_PROGRESS
apc.rfc1867_freq=0
apc.rfc1867_ttl=3600
apc.lazy_classes=0
apc.lazy_functions=0
apc.file_md5=0
Here are some combination of what I tried:
apc.stat = 0, apc.stat_ctime=0
apc.stat = 1, apc.stat_ctime=1
apc.stat = 0, apc.stat_ctime=1
apc.stat = 0, apc.stat_ctime=0
However, APC still cannot be used. Only when I disable APC, the site works properly.
Can anyone please tell me what is the problem?
Thank you in advance.
APC config in image
Probably APC does not interpret that syntaxis of register_shutdown_function correctly. There are two ways of defining static method callbacks with this function:
register_shutdown_function('someClass::someMethod');
register_shutdown_function(array('someClass', 'someMethod'));
You could refer to the documantation and commetns for more information: http://php.net/manual/en/function.register-shutdown-function.php
Wordpress also worked for me when I disabled apc from php.ini
I am using Yii as my PHP framework. I'm trying to use Gii to generate a model, the problem is I can't event get to the page to generate models because of this error:
PDO::__construct() [<a href='pdo.--construct'>pdo.--construct</a>]: [2002] No such file or directory (trying to connect via unix:///tmp/mysqld.sock)
My php.ini looks like:
upload_max_filesize = 12M
post_max_size = 12M
mysql:host=localhost;port=3306
mysql:unix_socket=/tmp/mysqld.sock
pdo_mysql.default_socket=/tmp/mysqld.sock
mysql.sock does exist in /tmp/ (installed from MySQL package via MySQL.com). MySQL is running, I'm on Mac OS X 10.6. The root password is not set.
Any ideas?
I am getting both modules listed as installed / configured when I use:
php -m
or if I use:
php -i
but when I use:
$m = new Memcache;
// or
$m = new Memcache();
// or
$m = new Memcached();
//or
$m = new Memcached;
I get the following error:
Fatal error: Class 'Memcached' not found
I am running on a Mac - OS X (10.5.7) with default install of apache & php. Additionally, I have memcached running as a daemon on 127.0.0.1:11211 and libmemcache as required by the php-memcached library. I have restarted apache tons of times and even done a machine restart.
Does anyone know why the modules/extensions show up in the command line but not in my phpinfo()? I am literally stumped, after 3 hours of googling, I am just about ready to give up.
Also, please note, my phpinfo() outputs my ini files as follows AND they are both the exact same file:
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /private/etc/php.ini
UPDATE:
Apache is failing to load the extension.
[Fri May 14 04:22:26 2010] [warn]
Init: Session Cache is not configured
[hint: SSLSessionCache] PHP Warning:
PHP Startup: Unable to load dynamic
library
'/usr/lib/php/extensions/no-debug-non-zts-20060613/memcached.so'
- (null) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load
dynamic library
'/usr/lib/php/extensions/no-debug-non-zts-20060613/memcache.so'
- (null) in Unknown on line 0
Does anyone know why or how this would happen? Both of the files referenced above DEFINITELY ARE there. Should I move this question to server fault?
Your webserver is probably using mod_php, which is a seperate bit of code from the standalone (CLI) interpreter. If they are both using the same ini file, and the memcache extension is configured in the ini file, then it sounds like for some reason, the mod_php is failing to load the extension - check your webserver error_log for startup errors.
It may be that the mod_php was compiled without memcache support (most extensions need to have a stub file linked into the php code, even though the bulk of the code is not linked until run time). Or it may be a permissions problem on the shared object file. Or your webserver may be running chroot, and unable to find the extension (which would also mean that although the ini files appear to have the same path, this is relative to different roots).
HTH
C.
because both versions use different php.ini
place your php.ini into location noted in the phpinfo() outout
I would suspect that the issue revolves around permissions. When you run php from comand line, it runs as the user invoking it. When run as an apache module, it runs as "nobody".
I would assume that the memcached.so file, or the directory it's in does not have proper permissions.
I stumpled upon this post and was having the exact same problem with an extension in my php -i but not in phpinfo(). Mine was a permissions problem because of selinux on a CentOS machine. I had to change ownership and permissions and now it is working as expected.
Set php path in environment variables as given below.
Right-click on "My Computer"
Properties
Advanced Tab > Environment Variables
Under System variables, scroll down to find "Path", select and click on Edit.
Add path to your php install on the end (make sure to precede with semi-colon ";"). Example: ";C:\php7"
Click Ok.