I would like to use Drupal 8 (beta) with nginx. It works correctly, except update.php. It doesn't find it.

After analysing .htaccess (which is not processed by nginx) I realized that there is no real update.php file; it is served by index.php.

Does anyone have a working nginx configuration (with php5-fpm) which works with Drupal 8 beta, and that makes also update.php work?

  • Have tried gist.github.com/JediSange/8742644 ? – Nikit Nov 14 '14 at 23:29
  • Yes, a tried - it doesn't solve the update.php problem. – havasi Nov 16 '14 at 16:25
  • I would like to escalate this one, we are also on a nginx-setup and the updates are painful as we have to reinstall Drupal 8 from scratch between the betas. Anyone got any feedback here how to access the update.php-script using nginx? – Undrium Jan 30 '15 at 9:00

You need to set your nginx config file to rewrite 404 error to index.php

Just added this:

error_page 404 = @rewrite;
location @rewrite { 
  rewrite ^ /index.php;
  • I still get a 404 not found, could you elaborate this a little bit more? – Undrium Mar 2 '15 at 13:54
  • @Undrium, do you use ISPConfig? If yes, you can unmark "Own Error-Documents" and insert my above code in options/"nginx Directives". If not, you need to edit /etc/nginx/sites-avaliable/YourSite.vhost (in CentOS) adding my above code. – TechPages Mar 8 '15 at 15:23

The change matters to Nginx config is that Drupal 7 update.php URL is like

/update.php?op=info or /update.php?op=selection

while Drupal 8 update.php URL pattern is like

/update.php/selection or /update.php/result

So, what we need to change in the existing configuration is very simple. Look for your matching condition like

location ~ \.php$ {...}

then, change it to

location ~ \.php$|^/update.php {...}

For more details, please see my blog: https://insready.com/en/blog/update-your-nginx-config-support-drupal-8

  • I do not think, this is completely working config. You have to use try_files $uri /index.php?$query_string; # For Drupal >= 7 , if not, you can run into issues like this – Juraj Nemec Dec 1 '16 at 17:09

You need to do the rewrite in your vhost for nginx. (nginx does not use .htacces and .htacces should be disabled in your config!

but here you go

    location ~ ^/(install|rebuild)\.php$ {
   # Are now present in the core location and need to be accesed directly so rewriting them. -- Lawri van Buël               
    if (!-e $request_filename) {
        rewrite  ^/(.*)$  /core$uri last;

I have tested it in a broken D8 (It had some module error) but tested the rewrite parts using nginx and its debug log.

-- Removed update as I could not find it in the latest beta (I build it against an old version of d8 I now realize)

  • There is no update.php in my core folder, it's handled by the index.php routing these days I think. – Undrium Mar 6 '15 at 11:48
  • its a 1 to 1 rewrite of the rules in the .htaccess from drupal 8 concerning these 3 mechanisms (there part of the same set) it does not matter if index.php handles it, since the default @rewrite rule would than trigger after the call to update.php , but with the correct path "/core/update.php" (this propably activates special meaning in the index.php if that is really the one handeling it) – LvB Mar 6 '15 at 13:24
  • This is where I lose you, guys, I cannot fully grasp how to get my setup using the update functionality. While index.php may take care of the update-process I cannot understand how to get it to work. Rewriting /update.php to go to index.php doesn't seem to work either. – Undrium Mar 6 '15 at 13:28
  • Undrium, you can gain more information of the rewrite mechanism using the nginx errorlog debug flag. (" errorlog <file> debug; ") what you see there is that first is the rule found (or it should be first found at least) with '^/install.php' this is then rewritten to /core/index.php' next this is processed as if its a new request, the proces than does it again, until it resolves into a specific file to serve. – LvB Mar 6 '15 at 14:24

I had the same issue. This change worked for me (Taken from https://www.drupal.org/node/2353907#comment-10567306)

location ~ ^/(index|update)\.php(/|$) {
    fastcgi_pass unix:/var/lib/php5-fpm/web1.sock; # might be different
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params; 
    fastcgi_param  SCRIPT_FILENAME  $realpath_root$fastcgi_script_name;
    fastcgi_param DOCUMENT_ROOT $realpath_root;
    fastcgi_intercept_errors on;

Hope that helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.