With our Ansible playbooks it only takes a few commands and adjustments to the configuration file to set up the environment for CS-Cart or Multi-Vendor. The playbooks will configure the web server for you automatically.
Note
If you don’t want to use Ansible playbooks, configure your server manually to meet CS-Cart system requirements.
Important
Our playbooks don’t handle package conflicts—if a package can’t be installed, you’ll get an error. That’s why we advise using the playbooks on clean OS installations only.
Depending on your server’s operating system, run the following commands one by one to install Ansible:
On CentOS 7:
sudo yum -y install epel-release
sudo yum install -y gcc git openssl-devel libffi-devel libselinux-python python-crypto python-jinja2 python-paramiko sshpass PyYAML python-setuptools
sudo rpm -ihv https://releases.ansible.com/ansible/rpm/release/epel-7-x86_64/ansible-2.4.6.0-1.el7.ans.noarch.rpm
On Ubuntu 18.04:
sudo apt update
sudo apt install ansible
Note
CentOS 6, Ubuntu older than 18.04 version are no longer supported.
Once you have installed Ansible, you can download and run one of our playbooks to configure the server. Follow these steps:
Clone the repository with our playbooks, so that you can run them:
mkdir ~/playbooks && git clone https://github.com/cscart/server-ansible-playbooks ~/playbooks
The command above creates a copy of this repository in the home directory on your server. That way you’ll always be able to find the directory with the playbooks by simply using the cd ~/playbooks
command.
Create main.json, a file that will be used by our playbooks to configure the environment.
cp ~/playbooks/config/advanced.json ~/playbooks/config/main.json
The command above simply copies an existing file called advanced.json and pastes it as main.json in the same directory (~/playbooks/config). At this point, the file contains only the example configuration that you’ll need to change.
Edit the main.json file in the ~/playbooks/config/ directory on your server according to your needs. By default, the file looks like this:
{
"stores_dir": "/var/www/html",
"stores":
{
"example.com":
{
"cart":
{
"storefronts": ["example.org", "example.ru"]
},
"database":
{
"name": "cscart",
"user": "cscart",
"password": "cscart"
}
}
}
}
stores_dir
—the directory that will contain the folders with your CS-Cart installations.
stores
—an array with the data of your CS-Cart installations.
example.com
—the domain name of your CS-Cart installation. It is also the name of the folder where that installation will be located. In this example we’ll have one CS-Cart installation located in /var/www/html/example.com.
storefronts
—an array with the domain names of additional CS-Cart storefronts. If there are no additional storefronts, leave the array empty. For example: "storefronts": []
.
database
—the credentials of the MySQL database that will be created by the playbook for that particular CS-Cart installation:
name
—the name of the database.
user
—the name of the MySQL user account that will work with the database.
Warning
DON’T set root
as a user, or else root
won’t be able to access or create any other databases.
password
—the password of the MySQL user specified above.
If you work with your server via SSH (for example, if you are following our guide to install CS-Cart on DigitalOcean), then you can use a command-line text editor to modify main.json according to your needs. We recommend nano, because it’s the easiest to use:
On CentOS you’ll need to install nano first. Run the following command:
yum install nano
Open the file you want to edit (if you use Ubuntu, you just start with this command, without installing nano):
nano ~/playbooks/config/main.json
Now you’ll be able to edit the file. Navigate around it with arrow keys and work with the file like you usually do in a text editor. The example below is what we got after editing main.json for installing CS-Cart on DigitalOcean. That configuration is intended for a single CS-Cart or Multi-Vendor installation with no additional storefronts.
Important
Replace the domain name with your own and change the database credentials that will be created.
{
"stores_dir": "/var/www/html",
"stores":
{
"doctorzoid.tk":
{
"cart":
{
"storefronts": []
},
"database":
{
"name": "doctorzoid_tk",
"user": "doctorzoid_tk",
"password": "0NkpV5t9VcUYpKtM"
}
}
}
}
Press Ctrl + X to exit the editor. You’ll be asked if you want to save the changes. Press the Y button to do so, then press Enter to confirm the name of the file that you want to modify.
Depending on the PHP version and the web server you want to use, run one of the playbooks by using a command below. If the playbook runs without errors, you will be able to install CS-Cart or Multi-Vendor after that.
lemp7.yml: nginx + mysql + php7.1
cd ~/playbooks/ && ansible-playbook -e @config/main.json -c local -i inventory_php7 lemp7.yml
lvemp7.yml: varnish + nginx + mysql + php7.1
cd ~/playbooks/ && ansible-playbook -e @config/main.json -c local -i inventory_varnish lvemp7.yml
lemp73.yml: nginx + mysql + php7.3
cd ~/playbooks/ && ansible-playbook -e @config/main.json -c local -i inventory_php73 lemp73.yml
lvemp73.yml: varnish + nginx + mysql + php7.3
cd ~/playbooks/ && ansible-playbook -e @config/main.json -c local -i inventory_varnish73 lvemp73.yml
lemp74.yml: nginx + mysql + php7.4
cd ~/playbooks/ && ansible-playbook -e @config/main.json -c local -i inventory_php74 lemp74.yml
lvemp74.yml: varnish + nginx + mysql + php7.4
cd ~/playbooks/ && ansible-playbook -e @config/main.json -c local -i inventory_varnish74 lvemp74.yml
Questions & Feedback
Have any questions that weren't answered here? Need help with solving a problem in your online store? Want to report a bug in our software? Find out how to contact us.