H
H
heihachi882014-11-25 20:43:58
Nginx
heihachi88, 2014-11-25 20:43:58

How to make Opencart 1.5.5 work with nginx?

Currently using the following config: (nginx 1.6.2)

server {
        listen 80;
        listen [::]:80;

        root /home/username/Development/shop.local;
        index index.php;

        server_name shop.local;

        location /image/data {
                autoindex on;
        }

        location /admin {
                index index.php;
        }

        location / {
                try_files $uri @opencart;
        }

        location @opencart {
                rewrite ^/(.+)$ /index.php?_route_=$1 last;
        }

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }


        # Make sure files with the following extensions do not get loaded by nginx because nginx would display the source code, and these files can contain PASSWORDS!
        location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ {
                deny all;
        }

        # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
        location ~ /\. {
                deny all;
                access_log off;
                log_not_found off;
        }

        location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
                expires max;
                log_not_found off;
        }

        location ~ \.php$ {
                try_files $uri =404;
                include fastcgi_params;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
}

Visiting `shop.local` opens the URL shop.local/install/index.php in the browser and a 404 not found error from nginx. What is wrong in my config?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Kolya K, 2014-11-25
@Kolyagrozamorey

Use nginx in conjunction with apache and you won't have such problems.

N
Nikita Gusakov, 2014-11-25
@hell0w0rd

I think everything is right with you, it's just that the installation is written crookedly and requires a purposeful call to the script.

S
Stanislav Chernov, 2014-11-26
@uinx

chown -R nginx /home/username/Development/shop.local
and check which user nginx is running under

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question