Attempting to install D7 on nginx results in the following errors, with nothing further below them. The nginx setup I'm using has been extensively tested with D6, and works fine for roughly 20 sites.

Notice: Undefined index: SCRIPT_NAME in /var/www/nginx-default/orangehattech.com/htdocs/includes/bootstrap.inc on line 389 Notice: Undefined index: SCRIPT_NAME in /var/www/nginx-default/orangehattech.com/htdocs/includes/bootstrap.inc on line 562 Warning: Cannot modify header information - headers already sent by (output started at /var/www/nginx-default/orangehattech.com/htdocs/includes/bootstrap.inc:389) in /var/www/nginx-default/orangehattech.com/htdocs/includes/install.inc on line 882 Warning: Cannot modify header information - headers already sent by (output started at /var/www/nginx-default/orangehattech.com/htdocs/includes/bootstrap.inc:389) in /var/www/nginx-default/orangehattech.com/htdocs/includes/install.inc on line 883 Fatal error: Call to undefined function drupal_exit() in /var/www/nginx-default/orangehattech.com/htdocs/includes/install.inc on line 884 

I almost assigned this critical, as it completely disabled my use of drupal, however, I presume it's an nginx-only sort of issue, so perhaps it's not as critical as it appears to me.

Cheers!
-Dirkson

Comments

dirksonii’s picture

Version: 7.0-alpha1 » 7.x-dev
Priority: Normal » Critical

Verified that this bug occurs in the dev version as well.

Upgrading to critical, since, shucks, software not working on ~8% of all setups is pretty critical, no?

webchick’s picture

It is, indeed. Thanks for testing!

dave reid’s picture

Status: Active » Closed (duplicate)

Thanks for taking the time to report this issue.

However, I am marking this as a duplicate of #637146: HEAD install redirect fails because common.inc not loaded in _db_check_install_needed(). Please search for existing issues before submitting a new one.
You can follow up on that issue to track its status instead. If any information from this issue is missing in the other issue, please make sure you provide it over there.

This message is automatically generated. If you feel it could be improved, feel free to comment on http://drupal.org/node/467548

dirksonii’s picture

Status: Closed (duplicate) » Active

After applying the patch listed in the 'duplicate' thread, it removes the error the duplicate thread was created for, but still leaves me unable to install. Here is the new error:

Notice: Undefined index: SCRIPT_NAME in /var/www/nginx-default/orangehattech.com/htdocs/includes/bootstrap.inc on line 389 Notice: Undefined index: SCRIPT_NAME in /var/www/nginx-default/orangehattech.com/htdocs/includes/bootstrap.inc on line 562 Warning: Cannot modify header information - headers already sent by (output started at /var/www/nginx-default/orangehattech.com/htdocs/includes/bootstrap.inc:389) in /var/www/nginx-default/orangehattech.com/htdocs/includes/install.inc on line 883 Warning: Cannot modify header information - headers already sent by (output started at /var/www/nginx-default/orangehattech.com/htdocs/includes/bootstrap.inc:389) in /var/www/nginx-default/orangehattech.com/htdocs/includes/install.inc on line 884 

Again, this error is presented on an otherwise blank screen.

What's really odd is that there aren't any errors listed anymore, just notices and warnings, which generally don't stop things from running. Perhaps there's some other problem going on here that I'm not savvy enough to have picked up on.

berdir’s picture

The issue is that these notices break the forwarding that is done with an HTTP Header which can't be sent anymore.

The code that causes this is the following:

  $uri = explode('/', $_SERVER['SCRIPT_NAME'] ? $_SERVER['SCRIPT_NAME'] : $_SERVER['SCRIPT_FILENAME']);

Obviously, the check should use isset(), this is a bug. You can try to replace that line with:

  $uri = explode('/', isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : $_SERVER['SCRIPT_FILENAME']);

I don't know if nginx does provide a SCRIPT_FILENAME variable instead, you might still get a NOTICE now about SCRIPT_FILENAME. If so, you need to figure out if nginx provides anything than can be used instead of those two. (var_dump($_SERVER) and look what's there...)

dirksonii’s picture

Ah hah! After puzzling at your response for a good long time, I realized that I can simply add SCRIPT_NAME to the list of variables provided by nginx, and get rid of these errors altogether. This is a new step in making drupal 7 work with nginx, but probably not a bug itself- Just some documentation that needs updating. Perhaps I'll do a blog post about it... Should I ever manage to get my new site up ;)

However, while all the errors have gone away, I'm still left with an utterly blank screen. Going to the url in question /does/ now forward me on to install.php, but install.php appears completely blank.

-Dirkson

dirksonii’s picture

Ah! It looks like "REMOTE_ADDR", which install.php expects to be filled with something, is, of course, quite empty. What is it expecting here?

In the meantime, I removed the remote_addr requirement, and got the following errors, and, more importantly, a working install prompt. Errors include for the curious.

Notice: Undefined offset: 0 in /var/www/nginx-default/orangehattech.com/htdocs/includes/bootstrap.inc on line 1260 Warning: Cannot modify header information - headers already sent by (output started at /var/www/nginx-default/orangehattech.com/htdocs/includes/bootstrap.inc:1260) in /var/www/nginx-default/orangehattech.com/htdocs/includes/bootstrap.inc on line 1004 Warning: Cannot modify header information - headers already sent by (output started at /var/www/nginx-default/orangehattech.com/htdocs/includes/bootstrap.inc:1260) in /var/www/nginx-default/orangehattech.com/htdocs/includes/bootstrap.inc on line 1004 Warning: Cannot modify header information - headers already sent by (output started at /var/www/nginx-default/orangehattech.com/htdocs/includes/bootstrap.inc:1260) in /var/www/nginx-default/orangehattech.com/htdocs/includes/bootstrap.inc on line 1004 Warning: Cannot modify header information - headers already sent by (output started at /var/www/nginx-default/orangehattech.com/htdocs/includes/bootstrap.inc:1260) in /var/www/nginx-default/orangehattech.com/htdocs/includes/bootstrap.inc on line 1004 Warning: Cannot modify header information - headers already sent by (output started at /var/www/nginx-default/orangehattech.com/htdocs/includes/bootstrap.inc:1260) in /var/www/nginx-default/orangehattech.com/htdocs/includes/bootstrap.inc on line 1004 Notice: Undefined index: SERVER_SOFTWARE in /var/www/nginx-default/orangehattech.com/htdocs/includes/common.inc on line 2546 Warning: Cannot modify header information - headers already sent by (output started at /var/www/nginx-default/orangehattech.com/htdocs/includes/bootstrap.inc:1260) in /var/www/nginx-default/orangehattech.com/htdocs/includes/bootstrap.inc on line 1004

Looks like it expects SERVER_SOFTWARE. What does it expect THAT to be?

-Dirkson

dirksonii’s picture

After locating some really good guesses at REMOTE_ADDR and SERVER_SOFTWARE, and telling nginx to provide them, I was able to get the installer to quit complaining about those two.

Now, it has the following two errors. The first is on the normal page:

Fatal error: Class 'MergeQuery' not found in /var/www/nginx-default/orangehattech.com/htdocs/includes/database/database.inc on line 740

The second is on the install page, after getting past the "Fill in all your site/user information" stage.

Fatal error: Class 'DrupalQueue' not found in /var/www/nginx-default/orangehattech.com/htdocs/modules/update/update.install on line 74

webchick’s picture

Title: D7 alpha won't install » D7 alpha won't install with nginx

We have a new http://api.drupal.org/api/function/drupal_environment_initialize/7 function which is intended for, well, initializing environment variables like this. dirksonii, is it possible for you to modify that function so that it does so accordingly, and then post a patch? Or is this truly a mere server configuration thing?

If so, could you maybe make a page under http://drupal.org/node/346385 if it doesn't exist already, in addition to your blog post, once you get this figured out? :) That's where most people will be looking for this kind of info, I think (or somewhere under the installation guide at any rate)

dave reid’s picture

Feels like this is stuff under Stuff that you need to correct on your funky webserver configuration or software. We should add a more easily findable 'Installing Drupal on [server type x]' section.

dirksonii’s picture

Well, nginx handles these sorts of variables a little differently than apache does. With nginx, I'm talking directly to a php daemon, and I pass it various variables that it uses.

The following gives is the code snippet that tells the php daemon what to do, with D7 specific changes marked as //NEW :

        location ~ \.php {
                fastcgi_pass    127.0.0.1:9040; //IP and port of php-cgi daemon.
                fastcgi_index   index.php;
                fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_param  SCRIPT_NAME      $fastcgi_script_name;                                 //NEW
                fastcgi_param  REMOTE_ADDR      $remote_addr;                                          //NEW
                fastcgi_param  SERVER_SOFTWARE  nginx;                                                     //NEW
                fastcgi_param  QUERY_STRING     $query_string;
                fastcgi_param  REQUEST_METHOD   $request_method;
                fastcgi_param  CONTENT_TYPE     $content_type;
                fastcgi_param  CONTENT_LENGTH   $content_length;
        }

I presume all of this (and more) is provided to php by apache as a matter of course, but nginx provides nothing by default. I'll be sure to make a page where you say as well, documenting what changes I had to apply to nginx to make D7 hale and healthy : )

Unfortunately, my PHP isn't really strong enough for me to feel comfortable writing code others rely on. In case someone reads this who /can/ code the necessary changes, I feel I should mention that not all variables can just be made up by drupal, I think- REMOTE_ADDR, for example, seems to expect the remote IP address, which may have rather nasty effects if you try to fake it. However, SCRIPT_NAME can by synthesized from SCRIPT_FILENAME, and I can't imagine that you couldn't just make up an 'unknown' default value for "SERVER_SOFTWARE".

I'm still a bit lost on the other errors- the 'line 740' appears to be the major one. I found a couple other issues with this error mentioned, but at least one is definitely not related (sqlite issue), so I'm not sure if it's a duplicate or not.

-Dirkson

Coornail’s picture

Drupal 7 alpha installed and running at me on nginx without a problem.

(PHP 5.2.12-pl0-gentoo with Suhosin-Patch 0.9.7, nginx-0.8.31[+addition +aio +fastcgi +imap +pcre +perl +pop +smtp +ssl +zlib -debug -flv -ipv6 -random-index -realip -securelink -static-gzip -status -sub -webdav])

Do you want to see my configs?

chx’s picture

Priority: Critical » Normal
Status: Active » Postponed (maintainer needs more info)

I suspect a won't fix in the coming but for now (for lacking a better issue status) I set it like this. Once you identified a bug please reset to active.

dirksonii’s picture

Well, I'm still stuck with the 'line 740' problem, without any indication of how to move forward from it. It's no longer directly implicating nginx through variables, but it's also not outputting an error I can make much of an educated guess at.

Basically, you can post your configs, it certainly won't hurt, but I don't know what to look for in specific that could be causing the problem now.

dirksonii’s picture

Hey! Attempting yet another reinstall with today's dev version and a 'minimal' install results in success.

Two errors, though.

Notice: Undefined index: SERVER_NAME in minimal_form_install_configure_form_alter() (line 10 of /var/www/nginx-default/orangehattech.com/htdocs/profiles/minimal/minimal.profile).

Easy to resolve by adding the variable to the fcgi lines.

Notice: Undefined offset: 0 in request_uri() (line 1259 of /var/www/nginx-default/orangehattech.com/htdocs/includes/bootstrap.inc).

Occurs when looking at the site after the install. This appears to be another "Missing from my D6 nginx config" line; adding REQUEST_URI solves it quite nicely.

Neither errors /appears/ to have any negative effects.

MTecknology’s picture

Could I get your config? I'm having the exact same problem. If possible, maybe the whole thing so I can see if I screwed up on anything else.

MTecknology’s picture

I missed the part about REQUEST_URI; that with the other stuff mentioned seems to work great. Thanks.

chx’s picture

Title: D7 alpha won't install with nginx » Nginx configuration for D7 needs documentation
Project: Drupal core » Drupal Documentation
Version: 7.x-dev » 6.x-1.x-dev
Component: install system » Documentation
Category: bug » task
Status: Postponed (maintainer needs more info) » Active
MTecknology’s picture

Status: Active » Fixed

There's a crap ton of documentation for D7 and Nignx. The Nginx wiki documents a flawless setup of Drupal 6/7. http://wiki.nginx.org/Drupal

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

c0psrul3’s picture

i use the include directive:

in your vhost site .conf file do:

include fastcgi_params;

this will point to (usually) /etc/nginx/fastcgi_params
where you can include these nice server variables for your entire server (or at least for each vhost that is including this file).

:D