Quantcast
Channel: LinOxide
Viewing all articles
Browse latest Browse all 1287

7 Steps to Install CS-Cart v4 on nginx Webserver

$
0
0

Hi all, today we'll be installing and configuring CS-Cart v4 in our Linux Operating System running Nginx web server.

CS-Cart is an Open Source PHP shopping cart software that uses MySQL to store data and Smarty template engine to build the website’s look and feel featuring hook-based modular architecture, modern design technologies, impressive flexibility . It is the best shopping cart solution for building an ecommerce website of any size: from a small web store to a virtual shopping mall. Its a ready storefront, support for many payment and shipping options, full inventory control, unlimited products, promotional tools out-of-the-box.

In CS-Cart, you'll get 30 days trial and after the trial period is over, the Free mode will be activated automatically. In this mode, you have access to a limited set of eCommerce tools suitable for small and early-stage businesses. The Full mode can be activated in CS-Cart at any time by purchasing the full commercial license.

 1. Installing LEMP Stack

First of all, we'll need a working LEMP or LAMP server. Here in this tutorial, we'll gonna use Nginx so, we'll gonna install LEMP stack which includes (Nginx, MySQL and PHP server), to install we'll gonna enter the command below in terminal or a shell on our Ubuntu Server 14.04 LTS "Trusty".

 $ sudo apt-get install nginx mysql-server php5 php5-fpm php5-mysql

install-lemp-stack

2. Downloading and Extracting CS-Cart

Now, we'll create a folder /var/www/www.linoxide.com/public_html in which we'll setup CS-Cart in.

$ sudo mkdir -p /var/www/www.linoxide.com/public_html

Then download CS-Cart version 4  from their official website into a temporary directory (for example: /tmp/cscart) then decompress and copy it to /var/www/www.linoxide.com/public_html/ :

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

extracting-cs-cart

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

$ sudo chown -R www-data:www-data /var/www/www.linoxide.com/public_html

cscart-setting-file-permission

3. Create database

This step will create a database called cs_cart and a user called cscart_user with password as cs-password

$ sudo mysqladmin -u root -p create cs_cart

If you are asked for password, please enter the password you entered while installing mysql-server (lemp stack).

$ mysql -u root -p
 GRANT ALL PRIVILEGES ON cs_cart.* TO 'cscart_user'@'localhost' IDENTIFIED BY 'cs-password';
 GRANT ALL PRIVILEGES ON cs_cart.* TO 'cscart_user'@'localhost.localdomain' IDENTIFIED BY 'cs-password';
 FLUSH PRIVILEGES;
 quit;
creating-database-mysql

Note: Here, you can replace cs_cart which is database name, cscart_user which is username and cs-password which is password for the database to anything you want. But, please don't forget it, we'll need it later to setup CS-Cart in Web Interface.

4. Configuring Nginx

Stop the nginx service :

$ sudo service nginx stop

Now, we'll gonna edit /etc/nginx/nginx.conf using the command below:

$ sudo nano /etc/nginx/nginx.conf

Replace the contents of /etc/nginx/nginx.conf with below configuration:

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”;
}

nginx-config-cscart

5. Creating vhost config

$ sudo nano /etc/nginx/sites-available/www.linoxide.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.linoxide.com linoxide.com;
location / {
root /var/www/www.linoxide.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.linoxide.com/public_html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/www.linoxide.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.linoxide.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 “Thu, 01 Jan 2014 21:47:15 GMT”;
}
location ~ /.ht {
deny all;
}
}

vhost-config-nginx-cs-cart

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

$ cd /etc/nginx/sites-enabled/
$ sudo ln -s /etc/nginx/sites-available/www.linoxide.com.vhost www.linoxide.com.vhost

test the config by using the following command:

$ nginx -t

then run

$ sudo service nginx restart

run-nginx

6. Web Based Installation

Now launch the CS-Cart installer by going to http://www.linoxide.com or http://ip-address/ and continue with the install as normal. Enter the required information like MySQL database name, username, password, email address, etc.

Note: Here please replace linoxide.com with the domain you own and wish CS-Cart to get installed.

7. After the Installation

Once the installation is complete, it is strongly recommended that you take the following steps to protect the current installation and the CS-Cart source code.

1.Remove the directory install/.
2.Change the default administrator password.
3.Remove the distribution package from the web accessible directory on your server.
4.Change the access permissions for the files as advised below.
$ sudo chmod 644 config.local.php
$ sudo chmod 644 design/.htaccess images/.htaccess
$ sudo chmod 664 var/.htaccess var/themes_repository/.htaccess
$ sudo chmod 644 design/index.php images/index.php
$ sudo chmod 664 var/index.php var/themes_repository/index.php

post-installation-permission

The chmod 644 command leaves the file readable and writeable for the file owner and makes it readable for all other system users. The file contents cannot be viewed in a browser though.

Conclusion

We have installed CS-Cart version 4  successfully in Nginx web server with essential MySQL server, Php. We downloaded the latest compressed CS-Cart from their official website. We learned how to install LEMP stack in our Ubuntu 14.04 LTS "Trusty". If you have any problem, queries or questions please comment below without hesitation so that we can update and improve our blogs and contents more.

The post 7 Steps to Install CS-Cart v4 on nginx Webserver appeared first on LinOxide.


Viewing all articles
Browse latest Browse all 1287

Trending Articles