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

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.

Related

Can I direct a cpanel folder to a domain name hosted with a different registrar?

I'm wondering if this is possible and I'm not sure that it is. Before I explain, I found one other post [here]: Separate Domain Registrar and Host, possible to use CDN? which sounds similar to my problem, but I specifically don't want to point the Name Servers away. I only mention this because my question is going to sound very similar.
So I'm trying to help a friend who has a Domain Name registered on Site A (let's assume it's a place like Wix). He also has a hosting package on Site B (to have cpanel access for a site he had built with HTML & PHP).
for example:
1. www.yourdomain.com is hosted on Wix with a template website
2. "database" is a cpanel folder on Site B
Is there a way to have www.yourdomain.com/database link to the "database" folder on Site B's hosting -- without changing the Name Servers?
I don’t believe you can point a directory to a completely different server or hosting package.
However creating a sub domain instead could be your answer.
Is there anything stopping you from using database.yourdomain.com and creating an A record for this in your domain registrar and point it to the hosting package of database?

Point domain name to specific folder on server

I am currently working on a CMS type of site where users can create websites on my server.
I want to be able to create subdomains for the user's website for them to see the preview.
The next step would be for users to be able to point their domain name to my server, and when users go to the domain it would go to their own designated folder on my server.
How would I go about doing this automatically with php, I have been looking for solutions with no avail.
I currently have a Virtual Server with hostgator. Please advise, or point me in the right direction. Any solutions are welcome as well, I am pretty much stuck at this point.
Thank you very much.
EDIT
For example, if my domain is www.mydomain.com, when a user makes an account, the subdomain username.mydomain.com is created. Later down the line, if the user buys the domain name www.userdomain.com, I want to make it so that if www.userdomain.com is entered, it shows what is on www.mydomain.com/userdomain. The URL should still show www.userdomain.com
The answer is depends on which web server you are using ?(apache / nginx or any other)
You need to have separate directory for each sub domain you created
In your virtual host configuration you need to match the host name and get the subdomain as a parameter to set the root directory for your host name.
CNAME is also possible but if you can tell your web server there is a possibility for detailed answer.

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.

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

How to hide distributed servers under a single domain?

I currently host my company's website and blog on separate servers, reached by separate domain names - www.example.com and www.example.net. This is so I can give blog server access to our partners without compromising security on our main server. However, our SEO guy is now demanding that the blog be put on our main server, as www.example.com/blog.
I would like to maintain the current server separation rather than putting both on the same server. Is there any good way to keep them separated, but have them both under a single domain name? A subdomain would also be acceptable (blog.example.com).
My main website server is a Debian box running Apache 2, and I have full root access to it. The blog server is run by Hostgator, and I have limited access.
Edit: Thanks, all. In this particular situation I don't particularly want to transfer the blog again, and I don't have easy access to the DNS records, so i went with mod_proxy and it worked like a charm. I wish I could give you all "preferred answer" status, though, because all of your information was awesome.
A subdomain would be easy: just create an A record in DNS which maps blog.example.com to the IP address of the blog server, and have another A record in DNS which maps www.example.com to the main website server (this latter record probably already exists).
Would the SEO guy be happy with blog.example.com? It's not the same from an SEO perspective, but it might be good enough for him. I work at a company where SEO is at least 1/3 of what we do, and that's our setup: blog.example.com and www.example.com.
You could try to get fancy and proxy requests to /blog to the 2nd server, if you insist on keeping the blog off your box, but I think you can find a secure way to share space. Proxying like that could get annoying, and it basically doubles the latency to your blog.
Give the blog guys an account on your box; don't give them root/special privileges. If you can get away with it, don't even give them SSH access -- just give them a FTP login (make sure they can't access /var/www), and maybe a mysql account or something. (As you can see, this all depends on how much control/power the blog folks demand.)
Then, just make a symlink to the blog root, so they can write to a restricted area like /home/blog/www and still have it included in the website:
ln -s ~blog/www /var/www/blog
If a subdomain is for some reason not a possible way for you to go, you could use Apache's mod_proxy module to proxy requests to /blog to your second server.