I am trying to set up a VM with different magento versions so it can be used for testing,

They are in the following paths :

/var/www/magento1 /var/www/magento2 /var/www/magento3

I would like to access them as https://dev.magento.com/magento1, https://dev.magento.com/magento2 and https://dev.magento.com/magento3 respectively. The configuration in my enabled site is as follows :

server {
 #listen 80 default;
 listen 443;
 server_name mage; ## Domain is here twice so server_name_in_redirect will favour the www
 ssl on;
 ssl_certificate    /etc/ssl/certs/self-signed.crt;
 ssl_certificate_key        /etc/ssl/private/self-signed.nopass.key;

root /var/www/;

location = /magento1{
    alias /var/www/magento1/;

location = /magento2{
    alias /var/www/magento2/;

location = /magento3{
    alias /var/www/magento3/;

location / {
    index index.html index.php; ## Allow a static html file to be shown first
    try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
    expires 30d; ## Assume all files are cachable

## These locations would be hidden by .htaccess normally
location ^~ /app/                { deny all; }
location ^~ /includes/           { deny all; }
location ^~ /lib/                { deny all; }
location ^~ /media/downloadable/ { deny all; }
location ^~ /pkginfo/            { deny all; }
location ^~ /report/config.xml   { deny all; }
location ^~ /var/                { deny all; }

location /var/export/ { ## Allow admins only to view export folder
    auth_basic           "Restricted"; ## Message shown in login window
    auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
    autoindex            on;

location  /. { ## Disable .htaccess and other hidden files
    return 404;

location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
    rewrite ^(.*.php)/ $1 last;

location ~ .php$ { ## Execute PHP scripts
    if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss

    expires        off; ## Do not cache dynamic content
    #fastcgi_param  HTTPS $fastcgi_https;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param  MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
    fastcgi_param  MAGE_RUN_TYPE store;
    include        fastcgi_params; ## See /etc/nginx/fastcgi_params


So now I am able to access the front end fine...However I have the following issues:

  • If I set configuration to add "store code to URL" I get a 500 internal server error.
  • When I try to access the admin as "https://dev.magento.com/magento1/admin"(on all three) I get a 500 internal server error too...However, https://dev.magento.com/magento1/index.php/admin works fine. I would like to have it without "index.php".
  • Images, media files,js shows a lot of 404 :(

    I am stuck here any help would be greatly appreciated. Thanks a lot for your time

  • you tagged this as Magento Enterprise... ask Magento for support if you are using EE... – FlorinelChis Oct 24 '13 at 9:32

I think you need a handler to work with the index.php change:

location @handler { ## Magento uses a common front handler
    rewrite / /index.php;

I am no expert with nginx having only used it once, but a good source of information can be found on the Magento Wiki

| improve this answer | |

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.