How to: Create a local copy with XAMPP in Mac OS¶
If you store the “dev” and “prod” websites on one server, you should understand that they both are using common resources such as CPU/RAM/Disk/etc. And if any error/issue occurs on the “dev” project, it can affect “production” aka live website. And it even may result in losing customers and revenue.
We can provide development servers for your projects, where you can enhance and improve your store.
In this article, you will learn how to set up a test copy of a store locally on your Mac computer.
You will need a computer with local development environment (a LAMP web server). There are several ways how to install it on Mac:
- Use a built-in PHP, Apache and MySQL web server
- Install a ready-to-use web server, for example, Xampp
- Use Vagrant or Docker.
Multi-Vendor and CS-Cart are not very demanding in respect to a web server, they can be launched on almost any web server, however, you should know the basics of web development.
We are going to use Xampp, as it’s the easiest way and requires minimum configuration. There’s enough instructions on how to install Xampp available on the internet, so we won’t give any detailed guides here.
We also recommend to get familiar with the official documentation of Multi-Vendor and CS-Cart, There’s a section devoted to installation: docs.cs-cart.com
STEP 1. Install XAMPP¶
Here’s the link to the official website: XAMPP Apache + MariaDB + PHP
The installation process is easy. I’m sure you will handle it.
Once you complete installation, launch Xampp with the Start button. Then go to the Volumes section and click Mount.
Now open Xampp in the browser.
STEP 2. Copy the store files¶
Copy the store files from the Amazon server to the web server directory on your PC.
There are several ways to cope the files:
- using the rsync command
- using GIT
- using archives
We’re going to describe the last option, as it’s the easiest way and it does not require knowledge of console. Feel free to contact our support for more details on the rest two options.
Connect to the server. We use Cyberduck. For more details, refer to this guide: How to: Development: Manage files (GUI)
Open the folder with the project and archive all the files.
Download the archive to your computer.
Locate the htdocs directory on the XAMPP web server. Cope the archive and unzip it. In our case, XAMPP was created as a separate disk which you can find using Finder.
It’s also possible to find the directory using a terminal. Here’s its path:
The terminal may be helpful in case you need to unzip a big archive.
That’s it. All the files were copied successfully. You can store files at any nesting level.
STEP 3. Copy the database¶
You will need to make a full copy of the database on the local web server.
Open PhpMyAdmin on your hosting using the access details to the database of your project. For more details, refer to this guide: How to: Administration: Manage MySQL database
Select the database and start export.
Open PhpMyAdmin on the local web server. Ours is located at http://192.168.64.2/phpmyadmin.
If PhpMyAdmin is closed, refer to the Xampp or Google help articles. We were lucky to find a valuable advice at www.apachefriends.org. They mention how to edit the ~/.bitnami/stackman/machines/xampp/volumes/root/etc/extra/httpd-xampp.conf file to make it work.
Create a new database.
Import the database. If the database is quite big, you may want to increase the limits of the php.ini configuration. We had to do the same for our database.
Great! The database was successfully created.
STEP 4. Preparte for the launch¶
Clear the cache. While transferring the files, you copied the old cache. Now you need to open the directory with the store files and delete the contents of the /var/cache/ folder. You can do that in two ways: using Finder or console.
Open the console and open the folder with the project:
rm -rf var/cache/*
Set the necessary permission for the files and folders.
sudo chmod -R 777 var/ design/ images/
Change configuration and connection to the database in the config.local.php file. You may also want to create a new file local_conf.php, where you would add configuration parameters for Multi-Vendor or CS-Cart.
We created local_conf.php by copying the config.local.php file. Then we removed all unnecessary while keeping parameters of connection to the database and domain parameters.
If you use https (ssl) on the live site, and you do not have https on the local xampp, disable it in the database. If you don’t, the store will not open, besides you’ll have to clear the cache once again.
Open PhpMyAdmin. Find the cscart_settings_objects table. Set secure_storefront to none, and secure_admin to N.
Open the browser and check that the store is accessible online.