Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Running 2 stores on 1 database


Guest

Recommended Posts

Posted

We have 2 sites, both the same content (when I get the chance to DL 1 site and UL to other to update)

They are on different servers and different domain names.

 

Whats the easiest way to link the 2 together?

 

(yes I've searched for hours!!)

 

CHeers

Posted

Its there not an easier way?

As in point both stores at same database?

ABle to point both stores image directory same one also?

Posted

So long as your database permissions are set ok, this is dead simple, as you say, just connect both sites to same db. Images should be fine, so longas you arent using ssl, as this could throw up warning signs for your customers with images coming from a diff location. Just remember that if both sites use ONE db, you only need 1 admin, so delete the second sites admin folder altogether.

 

Depending on your requirements, you may want to take certain elements of the contrib mentioned above to show you which site generated the order, and control which products show on which site etc.

Posted

Thanks for the reply guys.

Just looking at mirroring the site under a differe URL.

 

ANyone if they have the time and knowledge, can they list the required changes in the configure files?

Posted

On the second store, just change the database settings in includes/configure.php to match those on the first store (last 3 or 4 lines, double check it doesnt say localhost for DB_SERVER, if it does, you will need a url or ip address in here), and for images you need DIR_WS_IMAGES changed to the full url to the original site, deleting DIR_WS_CATALOG from the path.

Posted
On the second store, just change the database settings in includes/configure.php to match those on the first store

 

Just wanted to point out that if these are different hosts, it's entirely likely that you cannot get to the mysql server from "outside." It's considered good practice to run the mysql database server on a machine that is accessible to the webserver hosting the files, but inaccessible to anyone else. If it's the same host, then this is probably workable.

 

I'd personally just make one domain name a parked domain. This way, you'd only have one code base and one server anyways. Most hosts will park a limited number of domains for free.

Contributions

 

Discount Coupon Codes

Donations

Posted
Just wanted to point out that if these are different hosts, it's entirely likely that you cannot get to the mysql server from "outside." It's considered good practice to run the mysql database server on a machine that is accessible to the webserver hosting the files, but inaccessible to anyone else. If it's the same host, then this is probably workable.

 

I'd personally just make one domain name a parked domain. This way, you'd only have one code base and one server anyways. Most hosts will park a limited number of domains for free.

 

 

The prob we have is that our .com domain is not picked up very much on Google in NZ. We need to mirror the site with a .co.nz domian to rank on Google.co.nz (as were are in NZ)

It takes about 3-5 hours to update the .co.nz site with the .com data.

Posted

If Google is your reason, then a parked domain might not work, since OSC gives a base href which would always be the one domain in your config file. I suppose you could set the OSCommerce HTTP_SERVER to $_SERVER['SERVER_NAME']. That would set the base href according to the current virtual host. (I'm not entirely certain this would work, but I believe it would. Some one else might have information to contradict me.)

Contributions

 

Discount Coupon Codes

Donations

Posted
If Google is your reason, then a parked domain might not work, since OSC gives a base href which would always be the one domain in your config file. I suppose you could set the OSCommerce HTTP_SERVER to $_SERVER['SERVER_NAME']. That would set the base href according to the current virtual host. (I'm not entirely certain this would work, but I believe it would. Some one else might have information to contradict me.)

 

 

Able to expand on this a little more?

Posted
Able to expand on this a little more?

 

When your host configures domains on their servers, they specify a domain and a directory to act as the root of that domain. To host two domains which should be the same site, they would create multiple Virtual Hosts that have the same web root directories. This way, you'd manage one set of files for what appears to be two separate domains.

 

In your includes/configure.php file, you are asked to set a HTTP_SERVER constant. If this constant is set to one domain, all pages will be created with a <base href="http://www.yourdomain.com"> tag. This means if I typed in www.yourdomain.co.nz, I would find myself at the OS Commerce site, but all subsequent links would take me back to www.yourdomain.com.

 

It should be possible to set HTTP_SERVER to $_SERVER['SERVER_NAME'] instead. The $_SERVER['SERVER_NAME'] variable contains the current Virtual Host. Therefor, if I went to www.yourdomain.co.nz, I would be directed to the same directory as www.yourdomain.com, but OSCommerce would still recognize that I am using a different domain name, and the base href tag would be created as

 

<base href="http://www.yourdomain.co.nz">

 

I am basing all of this conjecture on the following assumptions:

 

1. Your host will configure your domain (.com) and parked domain (.co.nz) as a Virtual Host. There are concievably other ways to host a parked domain, but this is the one that makes most sense as far as I know.

 

2. The value of $_SERVER['SERVER_NAME'] is reliable. Some server variables aren't completely reliable, depending on what webserver is running PHP and whether PHP is running as CGI. There's no mention in the manual about it being an unreliable variable.

Contributions

 

Discount Coupon Codes

Donations

Posted

I'm trying to do something very very similar but with minor differencs. I want/need two sites (2 different domain names) that work off the same database (It's my server so I control httpd.conf and I also have mysql on the same machine). The reason I need to do this is all about marketing to different segments of the population. So I will have a different logo on each site as well as different color scheme but the content of the site is pretty much the same (differences handled in custom code I already have).

 

I've been reading the forums like crazy to figure out the best way to do this. I read alot on the multi-store/multi-site contribution. But first, it's probably overkill for what I need to do; and second, the DESIGN of it is not well documented. My oscommerce site has been customized alot so in order to add contributions, I need to know the design of the contribution as well as the actual code changes/differences from original code.

 

KGT's suggestion is a great one. It solves one of my problems which is that I didn't want to maintain two sets of code. Hence, using virtual hosts is a great idea and setting HTTP_SERVER to $_SERVER['SERVER_NAME'] is a great way to handle this in OSC. Did anyone try this and did it work???

 

I have solutions for the logo (just customize the header.php file to call the right logo depending on what "SERVER_NAME" was called; similarly, I can do the same with the stylesheets (for the different color schemes) by having 2 differently names files - but I'll have to make a change to ALL the files that call the stylesheet file (but it's a simple change).

 

What I don't seem to have an answer for is the whole SSL issue. Both sites need to have SSL enabled. But SSL can only be configured for one domain name and not shared across both. So anyone have suggestions/ideas? This whole SSL/certificate thing has been causing my pain already in setting up my test/dev environment so trying to configure this scenario in production seems like alot more pain ahead for me. Anyone have thoughts/ideas on how to handle the SSL issue in such a configuration?

 

One thought/view I had but don't know if it's realistic (since this SSL is not my area of expertise) is to actually use 3 different certificates. One for each domain name (that's 2) and a third for the actual shopping cart that both sites share/use when checking out and interfacing to the creditcard processing company (something like a certicate to subdomain charge.domainname.com)

Posted

This is the config for the master site

<?php
/*
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

// Define the webserver and path parameters
// * DIR_FS_* = Filesystem directories (local/physical)
// * DIR_WS_* = Webserver directories (virtual/URL)
 define('HTTP_SERVER', 'http://www.japaneseperformanceparts.com'); // eg, http://localhost - should not be empty for productive servers
 define('HTTPS_SERVER', ''); // eg, https://localhost - should not be empty for productive servers
 define('ENABLE_SSL', false); // secure webserver for checkout procedure?
 define('HTTP_COOKIE_DOMAIN', '.japaneseperformanceparts.com');
 define('HTTPS_COOKIE_DOMAIN', '');
 define('HTTP_COOKIE_PATH', '/');
 define('HTTPS_COOKIE_PATH', '');
 define('DIR_WS_HTTP_CATALOG', '/');
 define('DIR_WS_HTTPS_CATALOG', '');
 define('DIR_WS_IMAGES', 'images/');
 define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/');
 define('DIR_WS_INCLUDES', 'includes/');
 define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/');
 define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');
 define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');
 define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');
 define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');

 define('DIR_WS_DOWNLOAD_PUBLIC', 'pub/');
 define('DIR_FS_CATALOG', '/var/www/html/');
 define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
 define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');

// define our database connection
 define('DB_SERVER', 'localhost'); // eg, localhost - should not be empty for productive servers
 define('DB_SERVER_USERNAME', 'japaneseperforma');
 define('DB_SERVER_PASSWORD', '*****');
 define('DB_DATABASE', 'japaneseperformanceparts_com_-_oscomm');
 define('USE_PCONNECT', 'true'); // use persistent connections?
 define('STORE_SESSIONS', ''); // leave empty '' for default handler or set to 'mysql'
?>

 

 

and this is the slave config

<?php
/*
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

// Define the webserver and path parameters
// * DIR_FS_* = Filesystem directories (local/physical)
// * DIR_WS_* = Webserver directories (virtual/URL)
 define('HTTP_SERVER', 'http://www.japaneseperformance.co.nz'); // eg http://localhost - should not be empty for productive servers
 define('HTTPS_SERVER', '');  
define('ENABLE_SSL', false); // secure webserver for checkout procedure?
 define('HTTP_COOKIE_DOMAIN', '.japaneseperformance.co.nz');
 define('HTTPS_COOKIE_DOMAIN', '');
 define('HTTP_COOKIE_PATH', '/');
 define('HTTPS_COOKIE_PATH', '');
 define('DIR_WS_HTTP_CATALOG', '/');
 define('DIR_WS_HTTPS_CATALOG', '');
 define('DIR_WS_IMAGES', 'http://www.japaneseperformanceparts.com/images/');
 define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/');
 define('DIR_WS_INCLUDES', 'includes/');
 define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/');
 define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');
 define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');
 define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');
 define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');

 define('DIR_WS_DOWNLOAD_PUBLIC', 'pub/');
 define('DIR_FS_CATALOG', '/home/japanese/public_html/');
 define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
 define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');

// define our database connection
 define('DB_SERVER', 'localhost'); // eg, localhost - should not be empty for productive servers
 define('DB_SERVER_USERNAME', 'japanese');
 define('DB_SERVER_PASSWORD', '****');
 define('DB_DATABASE', 'japanese_oscomm');
 define('USE_PCONNECT', 'true'); // use persistent connections?
 define('STORE_SESSIONS', ''); // leave empty '' for default handler or set to 'mysql'
?>

 

I have set the images to be pulled off the master, and that seems to be working ok, can sosmone help with the rest of the code pls (willing to dontate if thats what it takes) :)

Posted

Matt - it's unclear of what you have tried from the previous suggestions and what your current problems are. That is the only way to help you.

 

I have to tell you that I am trying the KGT suggestion and it is working great so far. This suggestion is exceptional since you only need to maintain 1 code base and not duplicate them and manage two configure.php files, etc. But it requires that you change your virtualhost declarations to have both domains go to the same directory for the source code;

 

So here's the key parts of my configure.php file (remember, I only have 1 configure.php file for two domains):

 

 

define('HTTP_SERVER', 'http://' . ( (strpos($_SERVER['SERVER_NAME'], 'www') === false ) ? 'www.' . $_SERVER['SERVER_NAME'] :$_SERVER['SERVER_NAME'] ) );

define('HTTPS_SERVER', 'https://' . ( (strpos($_SERVER['SERVER_NAME'], 'www') === false ) ? 'www.' . $_SERVER['SERVER_NAME'] :$_SERVER['SERVER_NAME'] ) );

 

define('ENABLE_SSL', true);

define('HTTP_COOKIE_DOMAIN', $_SERVER['SERVER_NAME']);

define('HTTPS_COOKIE_DOMAIN', $_SERVER['SERVER_NAME']);

define('HTTP_COOKIE_PATH', '/');

define('HTTPS_COOKIE_PATH', '/');

define('DIR_WS_HTTP_CATALOG', '/');

define('DIR_WS_HTTPS_CATALOG', '/');

define('DIR_WS_IMAGES', 'images/');

define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/');

define('DIR_WS_INCLUDES', 'includes/');

define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/');

define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');

define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');

define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');

define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');

 

define('DIR_WS_DOWNLOAD_PUBLIC', 'pub/');

define('DIR_FS_CATALOG', '/var/www/html/mydomainname/');

define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');

define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');

 

 

The little bit of explanation that is required are the first two lines. Instead of just getting the domain name and having it be set for HTTP_SERVER and HTTPS_SERVER, I needed to do something additional. I am checking to see how the user got to my site (what domain did they type in). Did they type "www.domainname.com" or did they just type "domainname.com" without the "www". If they didn't type the "www", I am adding that into the name.

 

The main reason I had to do that was because my certificates (I now have one for each site) included the "www" prefix in both (www.domain1.com and www.domain2.com). That way, whenever a user clicks on an SSL enabled page, the "www" prefix is already there.

 

I'm sure there is probably a different way to do this and I'm sure it has already been solved since I imagine it is a common problem. However, I did a quick forum search and didn't find anything and this is what I came up with - and it is working in my production site.

Posted

I have a multi-site account through a host where you can run multiple domains and they all will access the database through "localhost". It shouldn't be a problem there, have you looked into upgrading your hosting? PM me if you need the name of some hosts.

  • 1 month later...
Posted
Matt - it's unclear of what you have tried from the previous suggestions and what your current problems are. That is the only way to help you.

 

I have to tell you that I am trying the KGT suggestion and it is working great so far. This suggestion is exceptional since you only need to maintain 1 code base and not duplicate them and manage two configure.php files, etc. But it requires that you change your virtualhost declarations to have both domains go to the same directory for the source code;

 

So here's the key parts of my configure.php file (remember, I only have 1 configure.php file for two domains):

define('HTTP_SERVER', 'http://' . ( (strpos($_SERVER['SERVER_NAME'], 'www') === false ) ? 'www.' . $_SERVER['SERVER_NAME'] :$_SERVER['SERVER_NAME'] ) );

define('HTTPS_SERVER', 'https://' . ( (strpos($_SERVER['SERVER_NAME'], 'www') === false ) ? 'www.' . $_SERVER['SERVER_NAME'] :$_SERVER['SERVER_NAME'] ) );

 

define('ENABLE_SSL', true);

define('HTTP_COOKIE_DOMAIN', $_SERVER['SERVER_NAME']);

define('HTTPS_COOKIE_DOMAIN', $_SERVER['SERVER_NAME']);

define('HTTP_COOKIE_PATH', '/');

define('HTTPS_COOKIE_PATH', '/');

define('DIR_WS_HTTP_CATALOG', '/');

define('DIR_WS_HTTPS_CATALOG', '/');

define('DIR_WS_IMAGES', 'images/');

define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/');

define('DIR_WS_INCLUDES', 'includes/');

define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/');

define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');

define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');

define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');

define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');

 

define('DIR_WS_DOWNLOAD_PUBLIC', 'pub/');

define('DIR_FS_CATALOG', '/var/www/html/mydomainname/');

define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');

define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');

The little bit of explanation that is required are the first two lines. Instead of just getting the domain name and having it be set for HTTP_SERVER and HTTPS_SERVER, I needed to do something additional. I am checking to see how the user got to my site (what domain did they type in). Did they type "www.domainname.com" or did they just type "domainname.com" without the "www". If they didn't type the "www", I am adding that into the name.

 

The main reason I had to do that was because my certificates (I now have one for each site) included the "www" prefix in both (www.domain1.com and www.domain2.com). That way, whenever a user clicks on an SSL enabled page, the "www" prefix is already there.

 

I'm sure there is probably a different way to do this and I'm sure it has already been solved since I imagine it is a common problem. However, I did a quick forum search and didn't find anything and this is what I came up with - and it is working in my production site.

 

Hi there.

I have doen the above, and get the 2nd domain name showing as the URL when at index page, but all links on the page still show as orginal URL.

Any insight?

Posted
Hi there.

I have doen the above, and get the 2nd domain name showing as the URL when at index page, but all links on the page still show as orginal URL.

Any insight?

 

Matt - post your configure.php file (or the key parts of it) so I can see if I can help with your problem.

Posted
Matt - post your configure.php file (or the key parts of it) so I can see if I can help with your problem.

 

 

Thanks :)

 

<?php
/*
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

// Define the webserver and path parameters
// * DIR_FS_* = Filesystem directories (local/physical)
// * DIR_WS_* = Webserver directories (virtual/URL)

define('HTTP_SERVER', 'http://' . ( (strpos($_SERVER['SERVER_NAME'], 'www') === false ) ? 'www.' . $_SERVER['SERVER_NAME'] :$_SERVER['SERVER_NAME'] ) ); 
define('HTTPS_SERVER', 'https://' . ( (strpos($_SERVER['SERVER_NAME'], 'www') === false ) ? 'www.' . $_SERVER['SERVER_NAME'] :$_SERVER['SERVER_NAME'] ) ); 


// define('HTTP_SERVER', 'http://www.japaneseperformanceparts.com'); // eg, http://localhost - should not be empty for productive servers
 //define('HTTPS_SERVER', ''); // eg, https://localhost - should not be empty for productive servers
 define('ENABLE_SSL', false); // secure webserver for checkout procedure?
// define('HTTP_COOKIE_DOMAIN', '.japaneseperformanceparts.com');
define('HTTP_COOKIE_DOMAIN', $_SERVER['SERVER_NAME']);

define('HTTPS_COOKIE_DOMAIN', '');
 define('HTTP_COOKIE_PATH', '/');
 define('HTTPS_COOKIE_PATH', '');
 define('DIR_WS_HTTP_CATALOG', '/');
 define('DIR_WS_HTTPS_CATALOG', '');
 define('DIR_WS_IMAGES', 'images/');
 define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/');
 define('DIR_WS_INCLUDES', 'includes/');
 define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/');
 define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');
 define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');
 define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');
 define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');

 define('DIR_WS_DOWNLOAD_PUBLIC', 'pub/');
 define('DIR_FS_CATALOG', '/var/www/html/');
 define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
 define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');

// define our database connection
 define('DB_SERVER', 'localhost'); // eg, localhost - should not be empty for productive servers
 define('DB_SERVER_USERNAME', 'XXX');
 define('DB_SERVER_PASSWORD', 'XXX');
 define('DB_DATABASE', 'XXX);
 define('USE_PCONNECT', 'true'); // use persistent connections?
 define('STORE_SESSIONS', ''); // leave empty '' for default handler or set to 'mysql'
?>

Posted

From reviewing your configure.php file, it looks like you are not using SSL certificate. Is that really what you want to do in a real ecommerce site?

 

If so, then you really just need to simplify the configure.php file in the HTTP_SERVER setting.

 

define('HTTP_SERVER', 'http://' . $_SERVER['SERVER_NAME'] );

 

In my configure.php file, I had the complexity in there to handle the specific URL that my certificate was configured for. Hence, my certificate includes the 'www' part in my domain name so that is why I had to check whether the user entered 'www' or not and if not put the 'www' prefix in for the server name. But since you're not using SSL, then you don't have to worry about all that.

 

I still have not answered the question to your problem though. So maybe simplifying your configure.php file will help.

 

But if you still have the problem, please describe it better. From your previous post, I'm not sure I fully understand what the problem is that you're describing.

Posted
From reviewing your configure.php file, it looks like you are not using SSL certificate. Is that really what you want to do in a real ecommerce site?

 

If so, then you really just need to simplify the configure.php file in the HTTP_SERVER setting.

 

define('HTTP_SERVER', 'http://' . $_SERVER['SERVER_NAME'] );

 

In my configure.php file, I had the complexity in there to handle the specific URL that my certificate was configured for. Hence, my certificate includes the 'www' part in my domain name so that is why I had to check whether the user entered 'www' or not and if not put the 'www' prefix in for the server name. But since you're not using SSL, then you don't have to worry about all that.

 

I still have not answered the question to your problem though. So maybe simplifying your configure.php file will help.

 

But if you still have the problem, please describe it better. From your previous post, I'm not sure I fully understand what the problem is that you're describing.

 

Done that, no change.

Problem is, we have the test domain name parked on the account (test name is www.defi.co.nz)

That leads to the shop and shows in the URL bar with the page loaded.

Any link that is hihighed by mousing over or clicking, then is redirected back under the main URL (www.japaneseperformanceparts.com)

As I understand, it 'SHOULD' show all links as coming from defi.co.nz when you go there via defi.co.nz.

IE as if there are 2 seperate shops with exact sam content.

Posted
Your base href is

 

<base href="http://www.japaneseperformanceparts.com/">

 

You said the domain defi.co.nz is a parked domain. This is not the same as a Virtual Domain. You will need a virtual domain for this method to work. Read this for more information between the two:

 

http://www.pair.com/support/knowledge_base...e_services.html

 

 

Good catch!!!

 

Yeah, you'll have to setup the domain defi.co.nz to be exactly like your japaneseperformanceparts.com. Hence, if you set this up in apache, you would just recreate the same virtualhost entry you have for japaneseperformanceparts.com which points to the same folder, log files, etc...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...