One Magento installation with two websites, on separate vhosts - apache

I have a client that maintains two different websites, each of which is set up as a separate virtual host in Apache. I installed and configured a Magento store within one host at domain1.com/store. They client now wants a store set up at domain2.com/store that shares products with the store on domain1.
All the instructions that I've seen to set up multiple websites within Magento require that the different websites be on the same host. Unfortunately, that isn't an option with our current setup. What's the best way to implement this?

So i think you should first think about your structure and what you're trying.
1.) Magento supports a multishop solution. For this you create many shops in one instance. Then you can set the Magento store in your vhost file with SET ENV or direct in your index.php file like this:
switch($_SERVER['HTTP_HOST']) {
case 'domain1.com':
$_SERVER["MAGE_RUN_CODE"] = "domain2";
$_SERVER["MAGE_RUN_TYPE"] = "store";
break;
default:
$_SERVER["MAGE_RUN_CODE"] = "domain1";
$_SERVER["MAGE_RUN_TYPE"] = "store";
break;
}
You have to change your index.php file that Magento know which shop the system should call (Create the shops in your Magento configuration).
2.) When you need more hosts Then make one database. Install the shop with all sites and then copy them to a new location. In the new location you can set the shop with the snippet in step 1.
Then you can build many hosts with one database but if you want with one administration and one database.
When you build the second solution you should think about that the database server should be in the same network.Otherwise you get a very bad performance.

You should point both Vhosts to the same magento install??
Then in the backend/admin section add a separate "Store"? Magento is totally designed to do this:
See Here
You can share store inventory, or keep it separated. You can also share main Template files -- Or keep them separated ... Share Skin files -- Or keep them separated. Point both vhosts to the same install directory and let Magento do the job it was designed for, without ever having to do the heavy Server Administration task of separating two installs by domain, but having the same Install.

Related

Prestashop migration procedure

I have a client who wants to move their hosting provider and we have successfully cloned exact copy of original server to the new hosting provider's server. We want to use different domain name staging.copiedsite.com to creating staging environment to check everything works fine, then we want to flicker it back to original DNS (www.actualsite.com). My question is, how do you configure the site to work with staging domain name? I am going to basically find all database record that says "www.actualsite.com" and replace it with "staging.copiedsite.com". Is that all it needs? Is there any configuration text file that I need to edit? Thanks.
You shall change the domain in BackOffice > Preferences > SEO & URLs. This will update configuration in database and your .htaccess file (For some obscure reason you might have to save this page two times so that the .htaccess file is overwritten).
Also some CMS pages and modules can use absolute URLs so changing all those values by querying the database is a good idea.
Basically that's all you need.

Openshift PHP application - Virtual Host

I have a php application on openshift. This main application is actually made of 2 different parts: Students & Employees. As I want to keep the code clear and separate for each (even though they share some common data), I need to create Virtual Host in Openshift.
After the user logs in, depending on what his setting was - I want to direct him to either the student or the employee management section. For example say my main application is https://manage.example.com, when the user logs in I want to be able to direct him to a virtual directory(host?) such as
https://manage.example.com/student OR
https://manage.example.com/employee
I am a little new to web related development but I 'assume' that Virtual host may be the right thing? If yes then any clues or leads on how to set up Virtual hosts on Openshift as I understand I have limited access to server configuration files on Openshift.
You will not be able to create more virtual hosts on OpenShift Online for one application, however, there are a couple of other routes that you can go.
You could create two separate applications (each having their own gears) and run each part of your code on a different application. If you need to share a database between them, make sure that you create one of them as scaled (the one you add the database to). Note that these two applications will not share a filesystem.
You could setup each application to run in it's own "subdirectory", something like you had proposed above, you should be able to easily setup the different routes in your application, this would also allow the applications to share a filesystem.

What's the directory structure should be for multiple domains under a single user? (apache)

I have an account on some VPS(friend's apache server with cPanel) and there I have one public_html directory.
We have in there about 5-6 websites:
/home/myusername/public_html/domain-1.name/index.php
/home/myusername/public_html/domain-2.name/index.php
but I don't like this way, I'd like to orginise it better and be able to separate and isolate some stuff for each website.
So what if I create like that:
/home/myusername/websites/domain-1.name/public_html/index.php
/home/myusername/websites/domain-2.name/public_html/index.php and so on
Would it be a correct way of structurising web directories?
And would apache work like that?
Perhaps there are out there some other conventions or common workarounds?
Thanks
This is perfectly fine. In fact I'd highly recommend against using the domain folder as the document root as typical web application will also contain data that is not publically accessable (e.g. configuration files, management scripts, version control files, etc.)
Personally I prefer the name htdocs and I keep my sites under /srv/http
For example:
/srv/http/user1/domain1/htdocs/
/srv/http/user1/domain2/htdocs/
/srv/http/user1/domain3/htdocs/
/srv/http/user2/domain4/htdocs/
/srv/http/user3/domain5/htdocs/
That way you can set the DocumentRoot to the htdocs directory and put other stuff that is not meant to be delivered by the web server in a different sub directory of the domain directory.
Ok, I want just to conclude and to outline the way I went with.
Thanks to #bikeshedder for ideas!
So having a single account(none-root) /home/myusername/ under linux VPS server, I didn't want to abstract completely from existent directory structure, but at the same time I wanted to create proper environment to isolate and separate clients and their spaces.
Main goals were:
* The new directory structure should help to keep all files and folders in a nice and clear order.
* Easy to navigate and browse.
* Each developer or client would have access only to their space.
The structure:
/home/myusername/http/client-1/domain-1/public_html/index.php
/home/myusername/http/client-1/domain-1/resources/
/home/myusername/http/client-1/domain-1/configuration.php
/home/myusername/http/client-1/domain-2/public_html/index.php
/home/myusername/http/client-1/client's_resource_dir/
/home/myusername/http/client-2/domain-3/public_html/index.php
/home/myusername/http/client-2/domain-3/subdomain/public_html/index.php
As result:
* We have isolated client's space and isolated domain space. That makes enough room for any type of web projects.
* Files and dirs are not mixed up with other projects, domains and clients anymore.
* For subdomain paths it can be
- as subdirectories /domain-3.name/subdomain/public_html/
- or additional subdomain directory /subdomain.domain-3.name/public_html/depending on requirements or size of subdomain website.
* Public_html is going to be a DocumentRoot for each website.
I did not go for srv/ and var/www dirs, cuz to me it sounds like server in the server and also I don't feel variable data var/ in current setup falls under web stuff.
Though it may make sense for our coming soon local web/file sharing server
But here now I have another question:
How would I specify new path to be a default one for cPanel? and only for my user?
Cuz now there is going to be multiple DocumentRoot directories in one user space.
Is that possible by Apache design?
I better create new question :) And then will edit my question with answer
Any suggestion welcome!
Normally go with this once hosting from 5-30++ sites, depending on complexity of content, traffic, perceived future migration strategies to more dedicated virtual or bare metal servers/instances.
/<node-serial-or-hostname-or-domain>/<#|subdomain|www|others>/index.<html|php|jsp|aspx|what-not>
/<node-serial-or-hostname-or-domain>/<#|subdomain|www|others>/assets/...
/<node-serial-or-hostname-or-domain>/<#|subdomain|www|others>/index.<html|php|jsp|aspx|what-not>
/<node-serial-or-hostname-or-domain>/<#|subdomain|www|others>/assets/...
/<node-serial-or-hostname-or-domain>/<#|subdomain|www|others>/index.<html|php|jsp|aspx|what-not>
/<node-serial-or-hostname-or-domain>/<#|subdomain|www|others>/assets/...
/<node-serial-or-hostname-or-domain>/<#|subdomain|www|others>/index.<html|php|jsp|aspx|what-not>
/<node-serial-or-hostname-or-domain>/<#|subdomain|www|others>/assets/...
/<node-serial-or-hostname-or-domain>/<#|subdomain|www|others>/index.<html|php|jsp|aspx|what-not>
/<node-serial-or-hostname-or-domain>/<#|subdomain|www|others>/assets/...

How do I allow customers to show a portion of my site at their Domain?

I have a website that contains company profiles. These profiles have many pages within my site like products, services, etc. Some of my users would like to use their profile on my site as their webpage.
eg. going to www.mycustomerswebsite.com loads their profile on my site, but doesn't redirect to my url.
I'd like to allow them to do this simply by pointing their DNS at my server. The behavior I'm looking for is similar to what one can do on hosted wordpress. I'm running Apache as my web server on Linux CentOS.
What are my options for setting this up?
With just apache serving static files, you create a wildcard virtualhost as per:
http://httpd.apache.org/docs/2.0/vhosts/mass.html
If (as is more likely) we are talking about a script generating pages on the fly, that script should be written to inspect SERVER_NAME to determine what content to produce - pseudocode:
names = {
'customer1.example.org': 1,
'customer2.example.org': 2,
};
if ($ENV[SERVER_NAME] == 'www.example.com') {
regularHome();
}
else {
produceHome(names[$ENV[SERVER_NAME]]);
}
Either way, you must make an association between mycustomerswebsite.com and your name for the same customer - perhaps they must input their domain into their settings on your site or perhaps you already have their domain set up.
After all that (and probably most difficult) is to get them to make a DNS change - they are the only ones who can do it - so that www is CNAMEd to your host. You might want to create a special host record "customers.example.com" or some-such strictly for this purpose. Create some documentation for your customers similar to wordpress's:
http://en.support.wordpress.com/domain-mapping/map-existing-domain/#instructions-for-mapping-an-existing-domain

A web application that lets users choose a domain name for the website they are about to create?

I want to create a web application that allows users to sign up, register a domain name and create their own website. This will be done in Ubuntu 9.10, Apache 2, Mysql 5 and Php 5.
At the moment, the only area of development I'm uncertain about is the domain name registration and mapping it to the web application.
I'm going to postpone developing the web interface that lets users register domains because I don't have the slightest idea how to do it. For the time being, I'll let an employee register the domain name on the user's behalf. I'll automate the process in te future (any advice on this matter would be appreciated). The employee will also input the registered domain name into my CMS, which will also update the Apache VirtualHost files with new domain information. I will have a cron job reload Apache every 5 minutes to capture the virtualhost changes.
Does this sound like the right approach? Will what I'm about to do be very disruptive to the server? Can anyone offer suggestions or point out issues I need to be aware of?
Additional details
the documentroot will remain the same at /var/www/public_html/websitemaker/ for all domains. I'll track user settings and styles based on the PHP's $_SERVER variable
I don't believe restarting apache every 5 minutes is the way to go as it won't be good for scaling.
One option would be to use logic grab the the domain name used to access the site. Verify that against your list of accounts in MySQL. If there is a match then load the users site and if not then behave like normal or send to error page.
As for registering domain names you will need to create (or use and existing) a script implenting an API to the registrar of your choice. They will provide the ability to check if a domain is available or not and to register it assigning it specific DNS values (plus other options as well) all in real time.
I think what you're looking for is Apache with mass virtual hosting so that you don't have to restart/reload Apache every 5 mins. Any specific questions about this would be more appropriate for Serverfault.