Install CS-Cart v4 on nginx

How to install and run CS-Cart version 4 on NGINX, for the purposes of this how-to we are installing CS-Cart on sitename.com, it assumes you have a working LEMP installation.

Step one: Install CS-Cart

The document root for www.sitename.com will be /var/www/www.sitename.com/public_html – if this folder doesn’t exist you need to create it:

mkdir -p /var/www/www.sitename.com/public_html

Then download CS-Cart version 4 to your computer, upload it into a temporary directory (for example: /tmp/install) then decompress:

cd /tmp/cscart
tar xvfz cscart_v4.2.2.tgz
rm -f cscart_v4.2.2.tgz
mv * .htaccess /var/www/www.sitename.com/public_html/

You need to make the document root and CS-Cart files writable by the nginx daemon:

chown -R www-data:www-data /var/www/www.sitename.com/public_html

Step two: Create database

This step will create a database called cs-cart and a user called cscart_user with password xyz123

mysqladmin -u root -p create cs_cart 
mysql -u root -p
GRANT ALL PRIVILEGES ON cs_cart.* TO 'cscart_user'@'localhost' IDENTIFIED BY 'xyz123';
GRANT ALL PRIVILEGES ON cs_cart.* TO 'cscart_user'@'localhost.localdomain' IDENTIFIED BY 'xyz123';
FLUSH PRIVILEGES;
quit;

Step three: nginx config

Stop the nginx service :

$ service nginx stop

Replace the contents from /etc/nginx/nginx.conf with the below:

user www-data;
worker_processes 8;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
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;
tcp_nodelay on;
keepalive_timeout 65;
server_tokens off;
gzip on;
gzip_vary on;
gzip_disable “msie6?;
gzip_http_version 1.0;
gzip_comp_level 8;
gzip_proxied any;
gzip_types text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
client_body_temp_path /tmp/client_temp;
# proxy_temp_path /tmp/proxy_temp;
# proxy_cache_path /var/cache/nginx/proxy_cache levels=2 keys_zone=nginx:100m inactive=200m max_size=5000m;
include /etc/nginx/conf.d/*.conf;
fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=cache:10m max_size=1000m inactive=60m;
fastcgi_cache_key “$scheme$request_method$host$request_uri”;
}

Step three: Create vhost config

vi /etc/nginx/sites-available/www.sitename.com.vhost
server {
listen 80;
listen 443 default ssl;
ssl_certificate /etc/nginx/certs/server.crt;
ssl_certificate_key /etc/nginx/certs/server.key;
server_name www.www.sitename.com sitename.com;
location / {
root /var/www/www.sitename.com/public_html;
index index.php;
try_files $uri $uri/ /index.php?sef_rewrite=1&$args;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ .php$ {
root /var/www/www.sitename.com/public_html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/www.sitename.com/public_html$fastcgi_script_name;
include fastcgi_params;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_cache_valid 200 302 10m;
fastcgi_cache_valid 301 1h;
fastcgi_cache_valid any 1m;
}
location ~* .(css|js|jpg|jpeg|png|swf|gif|svg|ttf|eot)$ {
root /var/www/www.sitename.com/public_html;
try_files $uri http://backend$1;
expires max;
add_header X-CDN “WCWS INTERNET”;
add_header ETag “”;
log_not_found off;
add_header Cache-Control “public”;
add_header Last-Modified “Sat, 30 Mar 2013 21:47:15 GMT”;
}
location ~ /.ht {
deny all;
}
}

To enable this vhost, create a symlink to it from the /etc/nginx/sites-enabled/ directory:

cd /etc/nginx/sites-enabled/
ln -s /etc/nginx/sites-available/www.sitename.com.vhost www.sitename.com.vhost

test the config by using the following command:

nginx -t

then run

service nginx restart

Step Four : Web Based installer

Now launch the CS-Cart installer by going to http://www.sitename.com and continue with the install as normal

About The Contributor

Steve is an e-commerce developer at Pixel by Pixel an e-commerce developer specialising in CS-Cart.

Share this page:

0 Comment(s)