Zen Cart Logo
Forums / Basic Configuration / Connect to storefront and database on a different server.

Connect to storefront and database on a different server.

Views: 13,231

Results 1 to 15 of 15
9 Apr 2021, 5:00 PM
#1
abcschooldr avatar

abcschooldr

New Zenner

Join Date:
Feb 2012
Posts:
77
Plugin Contributions:
0

Connect to storefront and database on a different server.

PHP 5.6.40 PHPMyAdmin version: 7.3.27 Fast and Easy Checkout

Last week my zen-cart was copied to another domain because I couldn't stop google from throwing a phishing warning on my Zen-cart storefront order page.

Both zen-carts, on 2 different domains have their own storefront, admin mgmt and database. So...I have Zen-cart fully set up on both domains.

Purchasers are still finding the old order form storefront and ordering from it.

I use Zen-cart for students to order courses, and the moodle course management system that students use to access online courses, verifies the order on the zen-cart database before it allows a student to log-in to his/her course. I switched the moodle check to find the order in the new zen-cart database, so the student can't get into the course if he/she orders on the old order form, connected to the old database. Also the student's information enters into the old admin site.

Is it possible to keep the old order form storefront operational but have it send the student order information to a Zen-cart database and admin site on another domain so that everything would gather in one spot and the student can be verified by the moodle?

9 Apr 2021, 6:17 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Connect to storefront and database on a different server.

If your database is still on the same physical server there should be no lag involved by specifying the "new" database in the "old" site's configure.php files.

9 Apr 2021, 6:21 PM
#3
abcschooldr avatar

abcschooldr

New Zenner

Join Date:
Feb 2012
Posts:
77
Plugin Contributions:
0

Re: Connect to storefront and database on a different server.

One database is on abcrealestateschools.com and 1 database is on abcrealestateschool.com. I want both storefronts to send information to the admin and database on abcrealestateschool.com. So I need to tell the storefront on abcrealestateschools.com to send the orders to the admin and database on abcrealestateschool.com and not the database and admin on its server on abcrealestateschools.com.

9 Apr 2021, 6:25 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Connect to storefront and database on a different server.

Are they actually physically separate "servers"? Or just different domains on the "same server" hardware?

Apart from security, the main concern is speed of database queries:
Fastest: both databases on the same physical server
Next fastest: both databases on servers in the same network, with proper firewall rules allowing both servers to talk to each other
Slowest: servers on different networks

Your hosting company should be able to set up the database firewall rules on the new server to allow only the IP address of the old server to "use" the new server's database.
Then in your old site's configure.php files you'd put all the DB_XXXXXX credentials copied from the new server's configure.php. Admin and non-admin.

9 Apr 2021, 6:30 PM
#5
abcschooldr avatar

abcschooldr

New Zenner

Join Date:
Feb 2012
Posts:
77
Plugin Contributions:
0

Re: Connect to storefront and database on a different server.

They are both hosted by siteground, but the database locations are different. So are there multiple config.php files to change?

9 Apr 2021, 6:32 PM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Connect to storefront and database on a different server.

abcschooldr:

So are there multiple config.php files to change?
Every Zen Cart store (at least until until v1.5.7 which is the most recent as of today) has two configure.php files: /includes/configure.php and /admin/includes/configure.php ... and both need the database details set in them.

9 Apr 2021, 6:43 PM
#7
abcschooldr avatar

abcschooldr

New Zenner

Join Date:
Feb 2012
Posts:
77
Plugin Contributions:
0

Re: Connect to storefront and database on a different server.

I am in /includes/configure.php. It looks like it lists 2 server url's and define('DIR_FS_CATALOG'. So If I change all 3, it will use courses/products from the admin on the new server, keeping it up to date?

9 Apr 2021, 7:01 PM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Connect to storefront and database on a different server.

No, this section needs to be copied from the new server to the old:

/**
 * The following settings define your database connection.
 * These must be the SAME as you're using in your admin copy of configure.php
 */
define('DB_TYPE', 'mysql'); // always 'mysql'
define('DB_PREFIX', ''); // prefix for database table names -- preferred to be left empty
define('DB_CHARSET', 'utf8mb4'); // 'utf8mb4' or older 'utf8' / 'latin1' are most common
define('DB_SERVER', 'localhost');  // IP address of your db server
define('DB_SERVER_USERNAME', 'something');
define('DB_SERVER_PASSWORD', 'something');
define('DB_DATABASE', 'somedbname');

And if the new server uses "localhost" for the DB_SERVER value, then your hosting company will need to give you the new server's IP address instead AND make sure the new server's firewall allows the old server's IP to access the database, and probably allow that IP address in the user credentials inside the database. But their tech staff (should be expert enough to) understand all that (cuz they do it everyday) so just ask them to take care of it.

9 Apr 2021, 7:03 PM
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Connect to storefront and database on a different server.

I suppose yes you could also edit the HTTP_SERVER and HTTPS_SERVER to use the new domain name, but that will only work after they first click something on your old domain. So, yes you can change those two to match the new server, but also have your hosting company set a redirect from the old domain to the new. (again, that's something they do everyday)

9 Apr 2021, 7:31 PM
#10
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,709
Plugin Contributions:
56

Re: Connect to storefront and database on a different server.

abcschooldr:

Last week my zen-cart was copied to another domain because I couldn't stop google from throwing a phishing warning on my Zen-cart storefront order page.

I really think you should spend time figuring this out, because it sounds like your site has been hacked and you haven't actually fixed the issue. (This means that sooner or later Google will be throwing phishing warnings on the new site.)

9 Apr 2021, 7:38 PM
#11
abcschooldr avatar

abcschooldr

New Zenner

Join Date:
Feb 2012
Posts:
77
Plugin Contributions:
0

Re: Connect to storefront and database on a different server.

I was never hacked. My main site is abcrealestateschool.com. I linked to abcrealestateschools.com for educational materials and the zen-cart order form. Google didn't like it that I was sending students to such a similar site to order. They are both protected and safe but they were a flag to google.

9 Apr 2021, 7:44 PM
#12
abcschooldr avatar

abcschooldr

New Zenner

Join Date:
Feb 2012
Posts:
77
Plugin Contributions:
0

Re: Connect to storefront and database on a different server.

Siteground responded:

I see. I'm afraid that this is actually down to the website configuration more than the hosting configuration. If the files are saved with the same database details this means that the websites will open the information from the same database and may not show up as two separate websites. I would recommend reaching out to a professional website developer, as this is more of a development related inquiry. As a hosting provider we focus on finding and resolving hosting related issues and as such website configuration and development does fall outside of our hosting scope of support.

I want abcrealestateschools.com to remain a usable Web site because I have students using that site for their courses, different courses for the courses on abcrealestateschool.com. I was hoping to let students use both domains to order, but have a central location for the student information to flow in to.

9 Apr 2021, 10:03 PM
#13
abcschooldr avatar

abcschooldr

New Zenner

Join Date:
Feb 2012
Posts:
77
Plugin Contributions:
0

Re: Connect to storefront and database on a different server.

I changed the 2 config files. Because the set-up is identical, there were only 7 url changes - including changing the location of the catalog. I had to change file permissions to change one of the config files. Because it wouldn't let me change the permission back to 444, after the change, and when I clicked on the page link, it was a Zen-cart message - I panicked and changed it back. Than I had to ask siteground to fix the permissions anyway.
Do you think it would have worked if I had been able to change the permissions back to 444? It is possible to have multiple storefronts, all pouring into a single database and admin just by changing those 2 files to the new database location?

10 Apr 2021, 11:10 AM
#14
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: Connect to storefront and database on a different server.

IMHO, I think google flags your site due to the fact all your sites are using http instead of https.

15 Apr 2021, 5:49 PM
#15
abcschooldr avatar

abcschooldr

New Zenner

Join Date:
Feb 2012
Posts:
77
Plugin Contributions:
0

Re: Connect to storefront and database on a different server.

Thank you DrByte Sensei! It is working. It took a change in permissions and back to 444 to fix the 2 files. In those files, I changed the database locations and a couple of URL's, did not change the catalog URL's, changed the server from localhost to the IP address of the new database. It worked but threw a 'redirect' error on occasion when I tried to access either admin. I contacted my host and they:

I was able to resolve the issue by deactivating the Dynamic cache with these directives in the .htaccess:
<IfModule mod_headers.c>
Header set Cache-Control "max-age=0,no-store"
</IfModule>

It is siteground, and they already had to give permission for one site to access the other database for my course management system. It just need the cache off and a flush and this change.
Seems to be working! Multiple order forms into 1 central database and admin.
Super!!