cs-cart on nginx web server

Anybody did install cs-cart on the nginx web server? I want to try it? Are there some problems?

thnx

Yes, we did deploy cs-cart using nginx. No problems so far. You would need to change the rewrite rule slightly so it works with SEO functionality.



This is rewrite rule you need:



f (-f $request_filename) {

break;

}



if (-d $request_filename) {

break;

}



rewrite ^ /index.php?sef_rewrite=1;



Hope that helps.

[quote name=‘soft-solid’]Yes, we did deploy cs-cart using nginx. No problems so far. You would need to change the rewrite rule slightly so it works with SEO functionality.



This is rewrite rule you need:



f (-f $request_filename) {

break;

}



if (-d $request_filename) {

break;

}



rewrite ^ /index.php?sef_rewrite=1;



Hope that helps.[/QUOTE]Can you please post more detailed config that you used? For example, how you configured php? I’m also planning to migrate to nginx on my server :slight_smile:

Ok, I have found better and more elegant solution for rewrite in nginx:

```php # Deny acces to .htaccess files in case i forget to remove them.

location ~ /.ht {

deny all;

}

Main location to serve static files.

location / {
root /srv/http/mir-shin/htdocs;
index index.php;

First rewrite rule: this rule tries to access file of the request,

if failed - directory, and if that also fails - rewrites request to php.

    try_files $uri $uri/ /index.php?sef_rewrite=1;
}

Location for static catalog, which i don’t use, but decided to leave

it in my config in case I’ll decide to actually use static catalog.

location ~ /catalog {
try_files $uri/index.html /index.php?sef_rewrite=1;
}

```



If someone is interested in tutorial for nginx + php-fpm with CS-Cart, i can write one when I’ll have time.

We are looking to try out nginx. How are things going for you with cs-cart and nginx?



Do you have some time for a quick tutorial?




[quote name=‘Net-burst’]Ok, I have found better and more elegant solution for rewrite in nginx:

```php # Deny acces to .htaccess files in case i forget to remove them.

location ~ /.ht {

deny all;

}

Main location to serve static files.

location / {
root /srv/http/mir-shin/htdocs;
index index.php;

First rewrite rule: this rule tries to access file of the request,

if failed - directory, and if that also fails - rewrites request to php.

    try_files $uri $uri/ /index.php?sef_rewrite=1;
}

Location for static catalog, which i don’t use, but decided to leave

it in my config in case I’ll decide to actually use static catalog.

location ~ /catalog {
try_files $uri/index.html /index.php?sef_rewrite=1;
}

```



If someone is interested in tutorial for nginx + php-fpm with CS-Cart, i can write one when I’ll have time.[/QUOTE]

I am also interested in tutorial for nginx + php-fpm with CS-Cart, thanks.

[quote][color=#282828][font=arial, verdana, tahoma, sans-serif][size=3]f (-f $request_filename/index.html) {[/size][/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif][size=3]rewrite (.) $1/index.html [/size][/font][/color][color=#282828][font=arial, verdana, tahoma, sans-serif][size=3]break;[/size][/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif][size=3]}[/size][/font][/color]



[color=#282828][font=arial, verdana, tahoma, sans-serif][size=3]if (-f $request_filename/index.php) {[/size][/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif][size=3]rewrite (.
) $1/index.php;[/size][/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif][size=3]}[/size][/font][/color]



[color=#282828][font=arial, verdana, tahoma, sans-serif][size=3]if (-f $request_filename) {[/size][/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif][size=3]rewrite ^ /index.php?sef_rewrite=1;[/size][/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif][size=3]}[/size][/font][/color]

[/quote]

Its not working when shop is closed (cs-cart 3)

It cant open page “store_closed.html”

Error 310 (net::ERR_TOO_MANY_REDIRECTS)

I would use the try_files method as posted by ProsForPros (shown below), this will try to match the static store_closed.html file first before doing the rewrite. Using If statements is not very efficient, and the last If statement results in the request for a static file being rewritten.


location = / {
try_files $uri /index.php?sef_rewrite=1$args;
}
location / {
try_files $uri $uri/ /index.php?sef_rewrite=1$args;
}

Could anyone help me how to configure nginx.conf to work with CS-Cart 3.0.3 Ultimate?



Now nginx.conf look like this:



worker_processes 2;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 2048;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;

#
# The default server
#
server {
listen 80;

server_name www.mysite.com mysite.com ;

location / {
root /home/mysite/public_html;
index index.php;
try_files $uri $uri/ /index.php?sef_rewrite=1;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
}

}




and in error.log I found:



2012/10/08 15:58:19 [crit] 2884#0: *1 stat() “/home/mysite/public_html/favicon.ico” failed (13: Permission denied), client: 188.26.244.129, server: www.mysite.com, request: “GET /favicon.ico HTTP/1.1”, host: " www.mysite.com"

2012/10/08 15:58:19 [error] 2884#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 188.26.244.129, server: www.mysite.com, request: “GET /favicon.ico HTTP/1.1”, upstream: “fastcgi://127.0.0.1:9000”, host: " www.mysite.com"



Any help will be highly appreciated.



Thank you

This might help you



http://www.sohaib.com/2013/04/10/nginx-configuration-for-cs-cart/

Someone is running Cscart with Nginx + PHP7?

The info linked above is still valid for the latest version?

http://www.sohaib.com/2013/04/10/nginx-configuration-for-cs-cart/

Posted in CS-Cart, NGINX - April 10, 2013

Someone is running Cscart with Nginx + PHP7?

The info linked above is still valid for the latest version?

http://www.sohaib.com/2013/04/10/nginx-configuration-for-cs-cart/

Posted in CS-Cart, NGINX - April 10, 2013

Here is the latest article on how to install CS-Cart on a server with Nginx. http://docs.cs-cart.com/4.3.x/install/nginx.html

v4.3.5 is not yet officially compatible with PHP 7. v4.3.6 will be.

Thank you Sir. 8)

Thank u net-brust but can can you write clearly because where am i changing for nginx. This changing in .htaccess file ??

Hi!

No, definitely not in the .htaccess file, nginx behavior is controlled via configuration files, that can be found in the /etc/nginx/ directory of your server.

Please check our documentation on how to set up the server using nginx. Also you can check the Beginner’s Guide article directly at nginx’s documentation.

I hope it will help you.