This may be a server question, but I'm asking how to do this system in PHP before you vote to close as off-topic.
I'm setting up a custom cloning site system, where paid users can have their own software but on a custom subdomain build, e.g. user1.domain.com. I want to allow them to have their own paid domain pointing to my server replacing their built subdomain. However, I don't know how to do this kind of process in raw PHP.
For example, on an administration page, they can input their paid domain and I want the domain to be added to BIND DNS/nginx on my server, but I need to know what I need take from there (except URL validation) such as checking if the domain is pointing my server when they enter the nameservers of my server from their domain manager (GoDaddy, 123-reg, etc) and so on and making sure the domain is properly active and can be taken well when accessing the new domain that replaces the built domain (nginx can do this?)
What steps should I take into making this kind of system? Is there any server support I need to take into such as cron jobs or such.
My server is running Ubuntu 11.10 with nginx 1.0.6.
EDIT: I already have a wildcard A record in BIND.
Just point *.domain.com to your server. Assuming you are running Apache, you just define your VirtualDocumentRoot in httpd.conf and you're off and running. Nothing to do in PHP or anything else.
Check out the documentation here: http://httpd.apache.org/docs/2.0/vhosts/mass.html
UPDATED
Didn't catch you were using nginx, sorry about that - looks very similar to Apache:
root /PATH/TO/WEBROOT/$host;
in your server { config. http://wiki.nginx.org/VirtualHostExample
Edit your configuration file (nginx.conf) and change the server section beneath http as shown in the VirtualHostExample at the link above, replacing the server name and paths with your server's info.
Related
I have a site say abc.com and a user account is accessed at abc.com/user. Now I want to add functionality that user can link his site say user.com to abc.com/user. Can u please give me an overview that how this process can be done dynamically via php?
Set up DNS to point the host name at the server
Set up the server configuration so the site is the default virtual host (so if an unrecognised domain name is used to request it, the right site will be loaded)
Use $_SERVER['HTTP_HOST'] instead of the path.
If I understood correctly - you want that a person who is entering user.com will see the content from abc.com/user.
I would recommend checking out launchrock.com they do exactly this, and it involves adding a CNAME dns record as I remember, another way to do this is to create a Proxy flag rule in httpd (mod_proxy must be enabled for this), so that you won't have to restart the server, you can always the .htaccess in your www dir.
doing so dynamically will be easy if you go the proxy route, as you just need to append a new proxypass every time a new site is deployed, or create a parameterized rule, like a regular htaccess, as far as automating DNS records creation, I'm sure that's possible and maybe DNS provider such as godaddy or AWS have api for those kinds of things, but more research is required.
Am sure there's answer on Google but I don't know how to formulate my question:
A php website is hosted on server like this: http://sub.realserver.com/website/index.php
Now I want to link the real domain name to it: http://therealwebsite.com
Problem is, when user visits:http://therealwebsite.com, he will see http://sub.realserver.com/website/index.php as he browse through other pages.
Question is how do I hide this realserver path and replace it with the domain name?
Thanks
edit: the website is hosted on a different server as the real domain name
I presume the domain name and the web site are pointing to the same server.
Although you could use URL rewriting (works with almost all popular web servers), the better solution is to set up your web server to provide that web site for the root of that domain name. How to do that completely depends on what server software you are using.
In apache, you need to create a so-called Virtual Host, configure it to respond to your domain name and set its DocumentRoot directive to the directory where your site is located.
See http://httpd.apache.org/docs/2.0/vhosts/examples.html for an example.
EDIT: I just read your comment. I'm afraid your options are rather limited. The easiest solution, but also the most dirty one, is to create one page with an IFRAME on it, that loads the site from the real server. You could also host a PHP proxy and on the server that hosts your domain name, and let it proxy the site on your
http://sourceforge.net/projects/php-proxy/
(I never used this, nor am I affiliated with this project, but it seems to claim to do what you want.)
I highly recommend though that you update your DNS records on your domain name so that it points to your server that hosts your site, and that you add a virtual host there.
you can do this with asp, there is a good resource on it here -
http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
I have acquired a PHP application that has a system class encoded with Ion Cube PHP Encoder.
I copied the files and moved them to a new server, a development one. The first thing that got me was the application was to only work on the domain it was on, so obviously not from localhost or any other server.
I'm guessing somewhere in the encoded code is a string comparison from a hardcoded string to where the site is running from.
I'm not looking to do anything illegal or against the software license - just I want to do all the development on a different server, and then push the files back to the original domain.
Basically, minimise downtime for the production site.
Is there any tricks I can do? Can I stuff with my hosts file to do it?
Thanks
Update
Forgot to mention that I have tried changing $_SERVER before the PHP checks. There is also a config file which asks for the URL. Leaving it on the old domain doesn't work, and changing it results in the invalid domain error.
It would depend on how exactly Ion Cube checks the host - if it uses hostname or equivalent then you would need to modify config on the server to think it has the same name as the production server, this is unlikely to be a good idea, but still maybe better than a developmestruction environment.
If it just checks the host HTTP header then you can just modify your hosts file back and forth
what operating system are you using ?
add the domain name to your host file as 127.0.0.1 (localhost)
e.g:
under linux
add this to file /etc/hosts
127.0.0.1 thedomainname.com
checkthis link to find other OS hosts file link text
this should make the apps running on your localhost to refer to it's self
I own the a domain like "www.example.com". How do I setup ownership over "api.example.com"?
And I have all my files hosted on a php server (at a hosting provider) and when I login to the file system I can see stuff like:
/index.php
/help/index.php
etc.
How do I map stuff like: api.example.com/v1/getAnimalNames.php
to a file in my file system?
Thanks
Presumably, your domain is "mysite.com" and not "www.mysite.com" .
As owner of that domain, you own every possible sub-domain. Your hosting provider probably set up a subdomain "www" for you to hang your Web server off. People are kind of used to seeing Web sites having a "www" subdomain.
To control subdomains, you need to control the name servers that give out your domain information to the Web. The name server configuration file gets a little stanza (a so-called "A record") for every subdomain you want to officially support. The bonus is that you can route each sub-domain to a specific server, i.e. host computer.
If the root of your domain is already configured to point at your main (and perhaps only) server, (you can test this using NSLOOKUP with the bare domain name), then there's a simpler alternative. If your Web server is Apache, you can define virtual servers for subdomains in Apache's configuration, and everything sort of works. Reverse name resolution isn't fully clean but close enough for most purposes.
I need to direct multiple domains to a single set of (PHP) files. So I point a domain at my server, which then goes to a single index.php file. This index.php file then detects the domain accessing it and returns the appropriate content. I do not want to add domains or set-up sites manually though as this is for a content management service. So it should be a case of a user signing up and it immediately works without me having to manually do anything. The file set must also exist only once, so updates can easily be applied to everyone.
I am currently on shared hosting, but I believe I may need to move to a VPS (running Apache) to achieve this.
How do I go about doing this?
Thanks
Unless I'm missing something about what you're trying to do, a simple CNAME DNS record may work. Just CNAME the new domain to your existing 'main' domain.
However, if you need to know what domain was requested using shared hosting this very well may not work. The catch is you would also have to setup the hosting account to accept requests from the new domain. This seems to be what you're trying to avoid.
If this is the case, you'll need a static IP, and Apache setup to accept wildcard domains and pass them to your application (index.php in this case). You may not need a VPS for this, just a relatively configurable shared hosting account.
Update: To get this working on shared hosting, check out the Apache VirtualHost directive. That's what Apache uses to setup a (wait for it) 'virtual' web server (document root, logs, etc) allowing a single server to host multiple sites. Also checkout Named Based Virtual Hosting, you'll need an account that doesn't do virtual hosting that way.
"So it should be a case of a user signing up and it immediately works without me having to manually do anything"... So you want magic. Anyways domains point to a directory so that is easy just point all domains to the same directory. PHP can examine the full URL so you can use that to select the content.
If you are using something like Joomla you might be able to customize the starting extension. For example all joomla content is stored in tables named jos_XXX.
It should theoretically be modifyable to the base table is domain_com_XXX
Maybe, but you really need to find a good programmer for this, I don't know of any systems that will do this out of the box. Maybe someone else might know of one.