Closed rstormsf closed 9 years ago
@rstormsf It doesn't look like you're running it as a privileged user. Just as you do it yourself on the server, you need to run "sudo service php5-fpm restart".
Unless you are using capistrano for provisioning (i.e. changing nginx and php conf) there should be no need for it.
There is a common gotcha with php5, opcache and atomic deploy based on symlink, so I'm gonna trow a guess that this is your problem or similar enough:
php5 opcache doesnt resolve symlinks for file paths (APC and others did), so when you deploy a new version opcache still see the same path (/srv/www/mysite/current/web/myfile.php) so it still serve the old cached file.
The best fix is to make the webserver pass the realpath to php, if you are using nginx is easy, just add this in the location that passes the request to php:
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
otherwise for apache there should be some module or you need to call on php opcache_reset();
, but it should be run within a web request because cli has a different cache than the php-fpm pool
further readings:
let me know if this solve the problem, as its probably a good idea to add it to the readme
I used bedrock-ansible to provision my DO instance. https://github.com/roots/bedrock-ansible/tree/master/roles/php/defaults sooo what should I change and run that role again against my instance
Im stuck with chef, so I cant really say on ansible, but the role file you linked its about php conf and what I proposed to change is on an nginx conf, I would guess there is a template somewhere for the nginx sites conf
Hey @francescolaffi
It looks like we are already passing the SCRIPT_FILENAME over here: https://github.com/roots/bedrock-ansible/blob/master/roles/nginx/templates/wordpress.conf.j2
So perhaps adding DOCUMENT_ROOT will bypass the need for restarting php5-fpm?
@austinpray yep, but you also have to change SCRIPT_FILENAME, the change is $realpath_root vs $document_root
this way nginx pass to php the paths with symlink resolved and opcache understand that the files are different on deploys
Cool, I'll try this out!
See https://github.com/roots/bedrock-ansible/issues/125. This isn't a Bedrock issue anyway.
Cool! Thanks for doing it!
@francescolaffi Do you mind me to point to some online material, so I could understand what was happening and how you figured it out the fix. Would really love to understand details
Great, @swalkinshaw thank you
Unfortunately I still have to manually restart nginx and php5-fpm (I'm not sure which is causing the issue) after each deploy. Otherwise I get some weird HTTP 502 Bad Gateway errors from nginx (on wp-admin) and my manual code changes on the server (e.g. test editing plugin code) are just giving me plain odd behaviour.
I also used bedrock-ansible for provisioning...
@teohhanhui would be nice if you could try and isolate which one is needed. Maybe create an issue at the bedrock-ansible project?
Whenever I do deploy, I have to manually log into the box and
sudo service php5-fpm restart
in order to pick up latest changes.if I add in
deploy.rb
it generates an error
SSHKit::Runner::ExecuteError: Exception while executing on host HOSTING.com: service php5-fpm restart exit status: 1 service php5-fpm restart stdout: Nothing written service php5-fpm restart stderr: stop: Rejected send message, 1 matched rules; type="method_call", sender=":1.120" (uid=1001 pid=18060 comm="stop php5-fpm ") interface="com.ubuntu.Upstart0_6.Job" member="Stop" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init ")
can anybody point me to the right direction how to automate it and solve it? should I hack my deploy user to allow him do sudo paswordless service management? because
nginx
reload works fine