I'm brand new to VPS hosting, so bear with me.
I recently purchased a VPS through inmotion hosting. It has Apache, cPanel and WHM installed out of box. I'm not sure if this is important, but at the top right of the WHM root login it shows: CENTOS 7.3 x86_64
I'm working on developing a system where users can sign up with me and be provided with a sub domain like so: theirUsername.mydomain.com. This will point to a directory on my server where their files will be located. People should also be allowed to have a domain name with my nameservers. I need the system to automatically detect their domain name and point it to where their directory is. It's just like if I were to manually log into cPanel and create an addon domain, but I need this process to be automated. I also need the sub domain to remain and I need to be able to install SSL certs for these domains.
My system would be VERY similar to how Squarespace works.
I've read into mass virtual hosting but cannot for the life of me figure out how to get it working or if it would even be what I'm looking for.
I've tried configuring the virtual hosting but have had no luck. Just for testing purposes I was trying a single domain. Here is my code:
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
# SSL name based virtual hosts are not yet supported, therefore no
# NameVirtualHost statement here
Listen 443
</IfModule>
<VirtualHost *:80>
DocumentRoot "/home/username/www/domain.com"
ServerName www.domain.com
ServerAlias domain.com
ErrorLog "/home/username/www/domain.com/error.log"
CustomLog "/home/username/www/domain.com/requests.log" common
</VirtualHost>
The log files are making it to that directory but visiting the domain gives me a "This site can’t be reached" error in Chrome.
Any tips would be greatly appreciated.
Thanks!
Related
I installed a VPS on Vultr running Ubuntu 16.04 and using virtual hosts.
There are two domains (abc.com & xyz.com) points to two different dictionary, and now it works fine with Let's Encrypt (SSL).
I can type domain name to access these two websites.
The virtual host file configurations in /etc/apache2/sites-available are:
abc.conf
ServerName abc.com
DocmentRoot /var/www/abc
and
XYZ.conf
ServerName xyz.com
DocumentRoot /var/www/xyz
However, this is the question I have now. Occasionally I found if I type IP address:
456.456.456.456/xyz
I thought it will point to the homepage of xyz.com, but it is not.
The webpage is showing and pointing to an error 404 pages (non-SSL) in abc.com
I want to make it to xyz.com, how do I make it right?
Why does it point to another document root?
I checked all abc.conf abc-le-ssl.conf xyz.conf xyz-le-ssl.conf configurations in /etc/apache2/sites-available.
First of all, apologies for my English.
I've been reading and reading guides last week a lot hours with no success. I bought a domain + hosting but due bad performance I've got a cheap vps to use as hosting. Currently my setup is:
A domain .com with an A record pointed to my vps ip.
A unmanaged vps with Ubuntu 14.04.2 64 bits to use as hosting for my wordpress with LAMP stack with default setup (I didn't changed any setting on apache, using default virtualhost).
My site works fine but I'm don't know how create subdomains with different directories. For example, my website.com files are in /var/www/html and I'd like to create subdomain.website.com with the files in other directory, let's say /var/www/subdomain.
I checked a lot tutorials and they say to create a virtual server on apache (I use webmin) and then an A record for the subdomain pointing to the server ip.
The problem is that when I enter to subdomain.website.com I see the content from main domain (/var/www/html) and not from "/var/www/subdomain"
I don't want ask you for a full guide step by step, I just need know where I need to start for achieve a subdomain with a different directory because usually I always used hosting services with tools like cpanel to create subdomains pointed to directories in 2 clicks.
I'm a full newbie with Apache/dns management.
Thanks a lot for your time!
Create a virtual host in Apache by creating a file at /etc/apache2/sites-available/subdomain.website.com.conf
In that file, add the following
<VirtualHost *:80>
ServerAdmin admin#example.com
ServerName subdomain.website.com
DocumentRoot /var/www/subdomain.website.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Now place your subdomain.website.com files at
/var/www/subdomain.website.com/public_html
Then enable the new virtual host by sudo a2ensite subdomain.website.com
After placing the files, if you get a 403 forbidden error, check for permissions of the DocumentRoot folder.
Refer: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts
This is for
Apache/2.4.7 (Ubuntu)
Ubuntu 14.04 LTS
I have a server with a certain IP address (example 22.22.22.22). I want to setup a DEV, a TEST and PROD environment.
for example if I go, from any computer in the world
1) to http://22.22.22.22 then I will hit the production website
2) to http://22.22.22.22/dev then I will hit the development website
3) to http://22.22.22.22/test then I will hit the testing website
How can I set this up?
Please share your suggestions and thoughts around this.
Thanks!
Not exactly what you asked for—I would take a slightly different approach. You will have a domain name, say example.com. You would have www.example.com and example.com point to your production site. Then you could have dev.example.com and test.example.com point to their respective sites. All of the DNS entries would still point to 22.22.22.22, but you would set up Apache to deal with them differently. This uses Apache named virtual hosts.
On the standard install of Apache, the site configurations should be in /etc/apache2/sites-available. To start with, there should be a configuration file named default. Create a new file prod with contents like the following:
# /etc/apache2/sites-available/prod
<VirtualHost 22.22.22.22:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/prod/html
(etc.)
</VirtualHost>
I've got the basics there, but you can look at the default for other directives you'll want there.
Next you create files for dev and test. Like so:
# /etc/apache2/sites-available/dev
<VirtualHost 22.22.22.22:80>
ServerName dev.example.com
DocumentRoot /var/www/dev/html
(etc.)
</VirtualHost>
It should be basically the same as prod, but different DocumentRoot and ServerName. The config for test will be almost the same too.
Once you have these set up, you just need to enable them. Run:
sudo a2ensite dev
...this enables dev. same thing again for test. After you run this, you should see the files are now also symlinked in /etc/apache2/sites-enabled. (The a2ensite command creates the symlink.)
Next, you just restart Apache. One way is: sudo service apache2 restart
I have set up my OVH server, installing apache2, php5, mysql, phpmyadmin etc... And configured the vhosts.
The content of my VirtualHost file :
<VirtualHost *:80>
ServerName www.abracadabook.fr
ServerAlias abracadabook.fr *.abracadabook.fr
DocumentRoot /home/abracadabook/www/
<Directory /home/abracadabook/www/>
Options -Indexes
AllowOverride All
</Directory>
</VirtualHost>
When I type the ip address of my server, it displays the apache default page. But after setting up my windows hosts file (I'm on windows but the server's on linux), when I try accessing abracadabook.fr the site is loaded and the root directory is right (/home/abracadabook/www) and it displays the normal index of my website. But the problem is that the site is not accessible from another client machine.
When I try to access to it from a PC which host file is not set up, nothing will load even when I access it with the ip address.
I searched in many boards and forum but never found the solution.
I hope you can help me.
Regardly,
(PS Sorry for my bad english)
Turns out I had not the good informations.
I followed this tutorial step by step and it works well now.
Kimsufi DNS setting Tutorial (French)
I have development server setup running Adobe Coldfusion8 (.war install) on top of Caucho Resin v3.1.9. (CentOS 5.3-64bit)
note: This is my first experience with Resin. I am trying to run Coldfusion8 on top of Resin as I was suggested that this would give me great performance gains.
My question is: how I can easily integrate multiple apache virtualhosts like my existing configuration.
On my production server, running CF8, standalone install on Adobe supplied JRun via mod_jrun22.so in apache, I have virtual hosts setup for each of my websites pointing to '/var/www/*/html/, similar to the following (simplified):
<VirtualHost 127.0.0.1:80>
DocumentRoot /var/www/www.mydomain.com/html
ServerName www.mydomain.com
ServerAlias mydomain.com
</VirtualHost>
<VirtualHost 127.0.0.1:80>
DocumentRoot /var/www/www.myotherdomain.com/html
ServerName www.myotherdomain.com
ServerAlias myotherdomain.com
</VirtualHost>
This configuration allows me to setup virtual hosts through apache pointing to '/var/www/*/html' so I can quickly deploy websites with Coldfusion Apps.
Well with Resin, it appears I have to also setup <host> tags for each one of my virtual hosts in '/opt/resin/conf/resin.conf'. Thus, having to completely duplicate apache virtual hosts.
What I really want is to be able to setup my apache virtual hosts and then have resin compensate accordingly.
I need a better solution and am completely open to entertaining any suggestion.
In the resin docs it shows an example using regex to change the root directory. Could you create a similar regex that just caught any .com site and set the document root?
From playing with resin/railo and caucho I couldn't find a way at all to just have the virtualhost configuration in apache only. You have to duplicate it to some level anyway. Either by a regex entry or as I did (only had about 10 domains) create a entry for each site.