Pages

Showing posts with label Bitnami Nginx Stack. Show all posts
Showing posts with label Bitnami Nginx Stack. Show all posts

Sunday, November 30, 2014

Installing Magento 1.9.1 on Bitnami Nginx Stack

First download the Bitnami Nginx Stack Magento.
Install the Bitnami Stack where you like, called by me root_nginx_stack.

After installation copy the demo project to the apps folder and remove htdocs folder
  1. cd root_nginx_stack
    cp -r docs/demo/ apps/magento
    rm -rf apps/magento/htdocs
    unzip magento-1.9.1.0.zip
    mv magento root_nginx_stack/magento/apps/htdocs
  2. change in root_nginx_stack/magento/*.conf all reference 'demo' to 'magento'
  3. in root_nginx_stack/nginx/conf/bitnami/bitnami-apps-prefix.conf add the line
    include "root_nginx_stack/apps/magento/conf/nginx-prefix.conf";
  4. in root_nginx_stack/magento/nginx-vhosts.conf add the lines below before the include directive
    
        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
        }
        
        location @handler { ## Magento uses a common front handler
            rewrite / /index.php;
        }
    
  5. in root_nginx_stack/magento/nginx-app.conf replace the location part with the lines below and set your root_nginx_stack path.
    location ~ \.php$ {
        if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
    
        expires        off; ## Do not cache dynamic content
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_read_timeout 300;
        fastcgi_pass unix:/root_nginx_stack/php/var/run/www.sock;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME $request_filename;
        include fastcgi_params;
    }
    
        ## These locations would be hidden by .htaccess normally
        location ^~ /magento/app/                { deny all; }
        location ^~ /magento/includes/           { deny all; }
        location ^~ /magento/lib/                { deny all; }
        location ^~ /magento/media/downloadable/ { deny all; }
        location ^~ /magento/pkginfo/            { deny all; }
        location ^~ /magento/report/config.xml   { deny all; }
        location ^~ /magento/var/                { deny all; }
    
        location /magento/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  /magento. { ## 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;
        }
    
  6. create a database for your magento installation:
    /root_nginx_stack/mysql/bin/mysql -uroot -p
    ...
    create database bitnami_magento;
    grant all privileges on bitnami_magento.* to 'bn_magento'@'localhost' identified by 'MAGENTO_PASSWORD';
    
  7. restart nginx and type in your browser: http://localhost:8080/magento/index.php
    your magento installation starts now!
I got the references for this config from Bitnami Wiki and Magento Wiki.
It's not production ready but helps as a starting point.