1

I'm trying to setup Nginx to evaluate its potential running Mangento on a multistore plateform.

After disabling apache, and enabling Nginx (correctly installed and configured), running the website leads to the Magento installation page (insted of the store), with the following error :

Fatal error: Call to a member function getCode() on a non-object in /app/code/core/Mage/Customer/Model/Session.php on line 71

Looks like the getCode() method is failing, because the previous object is NULL.

Any help would be reaaaaaally appreciated.

Thanks. Sorcy

2
  • If it leads to the installer, your app/etc/local.xml has a syntax error, is not readable our you are missing SimpleXML. Solve that first.
    – user4351
    May 22, 2014 at 18:43
  • Hi Melvyn. Actualy I was thinking the same as you. Therefore I checked that my local.xml had good permissions and whatever. I don't think there are any syntax problem there because when I stop nginx and start apache2 instead (which redirect on the same Magento install), it does work perfectly. The strange thing is : There are no log anywhere to help :( Do you think there's something else I might have missed, that would work with apache2 but not with nginX ?
    – Sorcy
    May 23, 2014 at 10:38

2 Answers 2

1

I have something like that in my Nginx configuration file (clipping off unrelated stuff):

location ~ .php$ {
  --- 8< ---
  fastcgi_param MAGE_RUN_CODE base;
  fastcgi_param MAGE_RUN_TYPE website;
  --- 8< ---
}

This should do the trick and initialise the environment variable Magento uses to recognise which store to run.

UPDATE:

However, in this case the solution was a bit different: Magento will usually forward browser to installation page when it isn't able to open /app/etc/local.xml file. The reason for such behavior could be that a) the file is missing b) Apache and NginX run under different user credentials and NginX is not able to access local.xml

In this case, Nginx was executed as wrong user.

8
  • Hi Pronto, Thanks for your help. I already have these lines in my nginx website conf file. When checking the logs, I can see that the correct parameters are passed to index.php because I can see the Mage::run('mywebsite_code', 'website');
    – Sorcy
    May 23, 2014 at 10:35
  • This code should match the code in Manage Stores under Magento System area. Are this ok as well?
    – Pronto
    May 23, 2014 at 11:21
  • Sure they are. I even tried to edit index.php to specify it manualy inside, because I thought the fastcgi_param command may not be working correctly. So yes It's exactly the same Website Code. :(
    – Sorcy
    May 23, 2014 at 11:49
  • Alright here's list of additional things to check: The code is for website and not for a view (sometimes people mix them up)? Under System > Configuration > Web you have correct domains set? Use scope drop-down to select correct website and uncheck "Use default" before changing the value of secured and unsecured web server name to appropriate one.
    – Pronto
    May 23, 2014 at 12:02
  • Thanks for your help. I'm familiar with magento configuration and I can say for sure that the code I'm using is the one for the Website, not the Store. Moreover, Everything is working perfectly with Apache2, and not with NginX. So I guess it's something Nginx is not managing the same way Apache does.
    – Sorcy
    May 23, 2014 at 12:10
2

I've been experiencing the exact same issue as above. Randomly. The site has been operating fine for months and I couldnt put my finger on what triggered it. I initially thought it was related to setting SOAP up. Anyhow, changing the file permissions on the local.xml file to 755 (from 666) seems to have done the trick (for now) but I intend to keep digging.

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.