Opencart Nginx Config
Jump to navigation
Jump to search
Here is the Nginx Config file for Opencart:
upstream examplecombackend { server unix:/var/run/php-fcgi-examplecom.sock; } server { listen 80; server_name example.com; root /var/www/vhosts/example.com/htdocs; index index.php index.html; access_log /var/www/vhosts/example.com/access.log; error_log /var/www/vhosts/example.com/error.log warn; location /image/data { autoindex on; } location /admin { index index.php; } location / { try_files $uri @opencart; index index.php index.html; } location @opencart { rewrite ^/(.+)$ /index.php?_route_=$1 last; } # 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$ { root /var/www/vhosts/example.com/htdocs; try_files $uri =404; fastcgi_pass examplecombackend; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }