CS-CART is an excellent shopping cart solution for your website as well as a stand-alone e-commerce solution website by itself. It comes conveniently wrapped in a compressed tarball file. In this tutorial, we will look into how to install CS-CART from scratch on your Ubuntu (or other Debian based distro) server. The installation process should take about 10 – 15 minutes.
The installation process will consist of several steps:
- Acquiring CS-CART installation files.
- Setting up the Apache server.
- Setting up the MySQL server.
- Extracting and configuring CS-CART directory.
- Following the online installation wizard.
- Finishing up.
Okay, let’s go through the steps one by one.
1. Acquiring CS-CART installation files
If you haven’t purchased CS-CART yet, visit http://cs-cart.com and buy a copy. At the time of writing this article, they offer three different versions. The installation procedure should be the same no matter which version we are about to install.
Once you purchase the product, CS-CART will send you the installation files in the form of a tgz file, such as cscart_v2.2.3-multivendor_2.tgz. Store the file on your computer and upload it to your server via scp (or rsync). In our example, let’s assume our username is pkout and our server is reachable via ssh at the domain name server.com. Of course, this will be different in your case. Here is the command to upload the CS-CART tarball:
scp cscart_v2.2.3-multivendor_2.tgz pkout@servername:~
This command uploaded our tarball to our home directory on the server. For now, we will leave the file there and setup the Apache server before anything else.
2. Setting up the Apache server
We need to create a virtual host on our Apache server and install a PHP module so that Apache serves the CS-CART webpages when visitors type the URL http://server.com (your own URL in your case) in their browsers.
If you don’t have Apache 2 along with PHP 5 installed on your system, do so by issuing:
sudo apt-get install apache2 sudo apt-get install php5 sudo apt-get install libapache2-mod-php5 sudo /etc/init.d/apache2 restart
Now the server is ready and we can configure Apache for CS-CART. Again, in the following steps, replace all occurrences of server.com with your own domain name. Execute the following command to create an Apache virtual server configuration file (the path may differ for non-Ubuntu distros):
sudo vim /etc/apache2/sites-available/server.com
If you use a different text editor than vim, replace the command vim with the one of your choice of course.
Put this text inside the file:
<VirtualHost *:80> ServerAdmin firstname.lastname@example.org ServerName server.com ServerAlias www.server.com DocumentRoot /srv/www/server.com/public_html/ ErrorLog /srv/www/server.com/logs/error.log CustomLog /srv/www/server.com/logs/access.log combined </VirtualHost>
and save the file (of course, replace the file paths with yours and enter your email and domain name). Now we need to tell Apache about this new virtual server configuration. Do so as follows:
sudo a2ensite server.com
A message confirming that the new site was added should come up. Next, we’ll setup a MySQL database for CS-CART.
3. Setting up the MySQL server
If MySQL isn’t installed on your system, install it:
sudo apt-get install mysql-server sudo apt-get install php5-mysql
Once you install MySQL, it’s highly recommended to run mysql_secure_installation, a program that secures your MySQL server. When you run the program, you will be asked a series of questions such as what should the database root password be, whether you want to remove anonymous accounts (say “yes”), disable root logins outside of localhost (say “yes”), and whether you want to remove test databases (“yes” or “no”, up to you). To run the wizard, run the following command:
Now we can setup the database for CS-CART: Login as the root user like so:
mysql -u root -p
Enter your root password created in the previous step and you’ll get a MySQL shell. Create a CS-CART database. We’ll conveniently name the database “cscartdb”:
create database cscartdb;
Now create the MySQL user for the CS-CART application. Let’s call the user “cscartusr”:
create user 'cscartusr'@'localhost' identified by '<user password here>';
Replace the <user password here> part with the user’s password (keep the quotes, though). Finally, let’s give the user a full access to the “cscartdb” database:
grant all on cscartdb.* to 'cscartusr' identified by '<user password here>'; flush privileges;
We’re done! Log out of the database and let’s install the CS-CART package files in the next step.
4. Extracting and configuring CS-CART directory
First, let’s create the directory structure necessary to run the server. We have to use the path that we entered into the server.com virtual server configuration file. In our case, it was /srv/www/server.com/public_html/. This is the so-called document root path. Further, we need to create a log directory where Apache will store its log files related to the CS-CART application. So, let’s create these directories:
sudo mkdir -p /srv/www/server.com/public_html sudo mkdir -p /srv/www/server.com/logs
Now that our directories are ready, let’s go to the public_html one:
and copy our CS-CART package from our home directory where we put it in the step 1:
sudo cp ~/cscart_v2.2.3-multivendor_2.tgz .
Now, let’s extract the file contents:
sudo tar -xzvf ./cscart_v2.2.3-multivendor_2.tgz
Finally, we need to change ownership of the public_html directory such that the www-data user – the user running Apache 2 – can read and execute the files in public_html and write to the logs directories. There are multiple ways to set the security settings, we’ll do it by setting up the ownership of the directory to us, the system user under which we are logged in (it’s the user pkout in this example), and group ownership to www-data:
sudo chown -R pkout:www-data ../public_html sudo chown -R pkout:www-data ../logs
Further, for security reasons, we want to grant a full read, write, execute access to the files to the user pkout and only read and execute access to the www-data user and other users. The logs directory has to be set writable by the www-data user, though. So,
sudo chmod -R 755 ../public_html sudo chmod -R 765 ../logs
We are almost set. Lastly, for the next step to work properly, we need to set a full read and write access to the config.local.php for all users and full access to all users to the directories skins, var, images:
chmod -R 666 config.local.php chmod -R 777 ./skins ./var ./images
Finally, restart the Apache server to make it aware of the changes and new directories:
sudo /etc/init.d/apache2 restart
If there are no error messages, we are done with the server side (for now). Keep your shell open and logged in – we’ll return one more time. Meanwhile, let’s get to our the next step – going through the CS-CART web installation wizard. This will be very easy.
5. Following the online installation wizard
sudo apt-get install php5-curl
Once you take care of all these prerequisites, refresh the browser page to see that they were all resolved and click on the “Next” button. On the next page, you will be asked for some configuration details. If you’re going to run the shopping cart directly from the main domain (e.g.: http://server.com), leave the Server Host Directory blank. If you plan to run the cart from a subdirectory, such as http://server.com/store), enter the directory name in there (e.g.: store).
Next enter the database username and password for the CS-CART user that we created above. Enter a random secret key to encrypt data. Make one up and make sure to use a mixture of all sorts of characters, e.g.: F(fjkAdf*&^DJJ(87JJI&5!__).si – don’t use this one – make your own! Fill the rest of the fields and click “Next”. CS-CART installer will install database tables to your MySQL database. Click “Next” to pick a look & feel skin for the shopping cart. Click “Next” again to install your selected skin. On the last page, write down the authentication code. You will need it if you need to reinstall the shopping cart.
The text on the last page also tell you what you should to finalize the installation. We we will cover it in the final section:
6. Finishing up
In this section, we will finish up by taking care of a few security precautions:
1. Delete the installation directory on the server. This is a safety precaution. Go back to your ssh shell and being in your public_html directory, type
rm -rf install
2. Rename the admin.php file to something else, say admincenter.php (the name is up to you – just make sure you remember it):
mv admin.php admincenter.php
Remember, now you will access your CS-CART admin panel via http://server.com/admincenter.php.
3. Finally, change permission on your config.local.php file to 644:
chmod 644 config.local.php
and also inform CS-CART about the change from admin.php to admincenter.php by opening the config.local.php file in your text editor and find the line that says:
$config['admin_index'] = 'admin.php';
and change it to
$config['admin_index'] = 'admincenter.php';
Save the file, exit, and log out of the server.
Congratulations! Your CS-CART should be successfully installed!