How to install Magento 1.9.0.1 on Nginx

September 6, 2014 29.3k views

Hi,
Does someone know where to find a good tutorial how to install magento 1.9.0.1 on Ubuntu 14.04 with LEMP?

My problem is that whatever I do I get a 404 when I try to install magento.

  1. I unpack magento to my www directory. 2. Give it correct permissions (755 for directories and 644 for files). 3. Hit my IP adress in the browser. 4. Gives me a 404.

I tried to create other files and place them in the same directory as magento install.php and they work just fine... for instance the info.php file with information about PHP works just fine. I follow this guide, but it's from 2012, maybe it's not up to date?
http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/configuring_nginx_for_magento

its really easy to install Magento on Apache, why so complicated on nginx? Maybe I'm just missing out something obvious here...

3 comments
  • FYI, I've already googled this question... for 2 days! The answer is not out there... All tutorials on how to configure nginx to work properly with magento is for someone who knows what the code does, what files to look for etc etc. I just cant ride my bike on one wheel before I learn how to walk... ;)

  • I have the same question.

  • magento uses files called .htaccess
    these are hidden files placed in site root directory, that tell apache how to work with this very site
    nginx however doesn't suppost these files, so you need to tell him how to work with magento all by yourself
    it requires some manual changes in nginx configuration files
    for instance the 404 error is triggered because nginx doesn't know how to handle /index.php/install like adresses
    although the config files placement differs between linuxes (so the paths are not exactly correct for ubuntu), there is an article on nginx configuration in magento's wiki - https://wiki.magento.com/pages/viewpage.action?pageId=9502843

2 Answers

Can you post your nginx domain configuration please?

  • Thanks for helping! now I managed to NOT get a 404 when trying to reach magentos install.php, I've installed magento and everything works... I dont know if I did everything correct but it's running :)
    this is how I did it:

    1. ofcourse, install Ubuntu 14.04 with LEMP and all initial for Ubuntu.

    2. mysql -u username -ppassword

    3. create database mymagentodatabase;

    4. cd /

    5. cd /var/www/mymagentostore (or whatever category you want your store to be at)
      standard category is /usr/share/nginx/html

    5.1 Standard category can be changed here: sudo nano /etc/nginx/sites-available/mymagentostore. I'll come to that file in step 15.

    1. sudo wget http://www.magentocommerce.com/downloads/assets/1.9.0.1/magento-1.9.0.1.tar.gz

    2. tar -zxvf magento-1.9.0.1.tar.gz

    3. rm magento-1.9.0.1.tar.gz (removes the downloaded file)

    4. mv magento/* magento/.htaccess .

    5. chmod -R o+w media var
      chmod o+w app/etc

    6. sudo chown www-data:www-data * -R

    7. sudo usermod -a -G www-data magento (my username is magento)

    8. cd /

    9. cd etc/nginx/sites-available

    10. sudo vi mymagentostore

    11. Add the following to the file:

    server {
    listen 80;

    root /var/www/mymagentostore;
    index index.php index.html index.htm;

    server_name myIPadress;

    location / {
    try_files $uri $uri/ /index.php?q=$uri&$args;
    }

    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root /usr/share/nginx/www;
    }

    pass the PHP scripts to fpm socket

    location ~ .php$ {

    fastcgi_pass 127.0.0.1:9000; With php5-fpm:

    fastcgipass unix:/var/run/php5-fpm.sock;
    fastcgi
    index index.php;
    include fastcgi_params;
    }

    location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
    expires 1y;
    lognotfound off;
    }

    location ~* .(htm|html)$ {
    expires 1m;
    lognotfound off;
    }

    }

    1. cd /

    2. sudo ln -s /etc/nginx/sites-available/mymagentostore /etc/nginx/sites-enabled/mymagentostore

    3. sudo service nginx restart

    4. sudo service php5-fpm restart

    and that's it, I typed my IP adress in the browser and the magento installationfile is working.

    So, is this correct? I ran GTmetrix and pagespeed was 37, so not that good. enabled gzip in etc/nginx/nginx.conf and it jumped to 86

    What more could I do to easily improve performance and stability? varnish is too advanced for me at this stage so not that...

Hi
Follow the instruction given in the below link:
https://magento2.atlassian.net/wiki/display/m1wiki/Configuring+nginx+for+Magento+1.x

I too had the same issue and got fixed it.
Hope this helps.

Regards,
Dinesh Arumugam

Have another answer? Share your knowledge.