You are here
shootify - Sat, 2022/10/29 - 22:59
hello, id like to know how to add a subdomain on a concrete5 or silverstripe cms,
the situation is this:
I have a static public ip that is working with my cms (mywebsite.com), however i also like to install a little application on the same server but with a subdomain (subdomain.mywebsite.com), however i dont find the tools on the webmin adminstation page to achieve this. would you please guide me .thanks
Forum:
That's easy! :)
For sure! That's easy! :)
Having said that there are lots of options on exactly how it behaves. What I'll try to provide is a fairly basic but functional setup that should broadly provide what you've asked for. If you need more advice or have specific requirements, please feel free to ask.
So what you are trying to achieve is called Name-based Virtual Hosting. The Apache docs are pretty good IMO, but I'll spell it out for you.
I'll assume that you want just basic Apache config to serve static HTML. If you have broader requirements, this will almost certainly require tweaks. This assumes that your new site will be subdomain.mywebsite.com and hosted from /var/www/subdomain, so you'll need to adjust that to your specifics.
Firstly, let's create the directory and a simple html test index file.
We'll also ensure that the webserver has access to it. FWIW I'm just granting full ownership to the webserver:
Now, we'll create a new fairly basic virtual host site config file. My example below supports HSTS and includes a redirect from http to https:
Now we'll enable the new site and restart Apache:
If you haven't already set up DNS for your subdomain you will need to set up a CNAME record (or an A record if you rather) to point to your server. FYI generally you would only have one A record per server, then additional subdomains would be CNAME records - however if you plan to move this to a different server, then an A record might be better). If you've only just done that, you'll need to wait for the change to propagate. How long that takes will depend on your DNS registrar, the TTL (Time To Live) that any existing records have and whether or not your local DNS provider honours TTLs. Best case scenario it will be instant, worst case it shouldn't take any more than 48 hours.
If you wish to test your new subdomain before DNS has propagated, you can test by adding an entry to your Desktop's hosts file (how that is done will depend on your OS).
E.g. here's the host entries I added to test this (my test server has an IP of 192.168.1.114):
Strictly speaking it shouldn't be necessary, but I generally recommend adding any domains/subdomains to the server's 127.0.0.1 (localhost) entry in it's hosts file. That way if/when the server resolves it's own domain/subdomain it will be much faster (it can skip an external DNS lookup). Here's the first line of my test server's hosts (/etc/hosts) file:
Hopefully that get's you going. If you have any issues, please post back.
thanks
i have set this up thanks to you.
however i ran on another issues, i have an web application running and seems to works fine, however when i am trying to set up smtp and sending an email test, it returns an error.
should i just run :
wanna make sure. thanks
You could, but there are better ways (IMO).
You could certainly do that and I'm sure it will work.
However, personally, I'd be inclined to just install the Debian package php-net-smtp. I.e.:
The result should essentially be the same, but in a Debian package.
The other alternative, is to just configure the whole server to use your SMTP relay. By default all TurnKey apps are pre-configured to send emails directly via postfix. But that can be pretty hit and miss (mostly miss these days). So we try to make it as easy as possible to configure postfix to use a 3rd party SMTP relay. Confconsole ships with a Mail Relay plugin that supports use of a third party SMTP relay. It should support any SMTP relay that supports SASL authentication.
If you are trying to configure this for your third party app (rather than the pre-configured TurnKey one), then there should (hopefully) be an option to use local postfix/sendmail? If you can't find it or aren't sure, please feel free to share the name of the app you're running and I'll have a poke around.
Obviously if you want to send mail via 2 different SMTP relays (for your 2 different web apps on your server) then using system settings won't support that. Although personally, I still think it's worth setting up the system wide SMTP forwarding anyway, so then you will get system emails.
that work
thanks so much.
Add new comment