How Can I Host Multiple Websites Under One Amazon EC2 Instance? - apache

I've followed this guide to do this but I'm having no luck inspite of my incessant Googling. Any advice would be supremely appreciated.
https://nouveauframework.org/blog/vhosts-running-multiple-sites-on-a-single-aws-ec2-instance/
I've setup Hosted Zones for the respective domains I wish to host. I've linked them to my instance via A records pointing to the instance IP, as well as adding the new nameserver records to the domains hosted on Namecheap. Furthermore I've created a vhosts folder on my server and edited the httpd.conf file with the respective VirtualHost details and changes needed.
The default Apache page is loading when I visit my respective website domains but the actual website pages themselves are not loading.
How can I fix this?
I'm getting this error when restarting HTTPD
[warn] _default_ VirtualHost overlap on port 80, the first has precedence
The domain names in questions alphagleam.co.uk and conflictzonenorthwest.co.uk

You need to fix your httpd.conf file and make sure to include
NameVirtualHost *:80
once done make sure to restart apache and it should be ok

Related

How Apache virtual host is working actually when name based is not setup

I have started one EC2 instance
I am using http as I have not set up anything related to SSL yet.
Url I am using is suppose http://ec2-instance-domain/ which is publicly accessible
I install 2 applications on it
Apaches sites-available conf files are as follows
/etc/apache2/sites-available/zurmo.conf
/etc/apache2/sites-available/suitecrm.conf
Since I dont have any domain for any of them yet
ServerName is in actual (example is literally present) zurmo.example.com and suitecrm.example.com
In these files, document root is /var/www/html/zurmo and /var/www/html/suitecrm respectively
When I started apache, both applications are working
If I go to http://ec2-instance-domain/zurmo -> it starts zurmo application login screen
If I go to http://ec2-instance-domain/suitecrm -> it starts suitecrm application login screen
I am confused as how this is working.
What I read about name-based virtualhost was www.one.com would point virtual host having ServerName www.one.com and so on
But here domain name is of ec2-instance which is nowhere used in apache conf files.
Can someone pls explain how this is working in these case ? I tried reading many material but all explain in above www.one.com scenario, not for my scenario
Thanks in advance

New Virtualhosts load default site since Apache/Ubuntu upgrade

I upgraded our web server from Ubuntu 12.04 to 14.04, which also upgraded Apache from 2.2 to 2.4.
The upgrade was successful and all existing virtualhosts are running great.
I created a new site yesterday and noticed that it was loading the default host instead of the one it should. I checked the .conf file in /etc/apache2/sites-enabled and it does look a little different than the other ones.
I understand that Apache 2.4 has some changes like "Require all granted" which shows in the new .conf file alongside the previous "allow from all". I tried commenting it out but that didn't do anything.
I guess I could try backing up this file and copying over an existing working .conf file and just modify the paths to see if that works - but having to do this for every new site I add in the future is not a solution.
Does anyone experience this during their upgrade process?
--- UPDATE ---
I looked again at the conf file and I noticed that all my other working conf files have 2 distinct differences:
They list the IP next to the port < VirtualHost 1.2.3.4:80 >, the broken one just had an asterisk *
They duplicate the < VirtualHost >, one for port 80, another for port 443
So I added the IP in the broken file in the <VirtualHost...> and duplicated the settings for port 443, restarted apache, and the site worked.
So now it comes down to where in the Virtualmin/Webmin settings would I make adjustments to fix this?
While creating, first option is which IP you want to bind you domain to. That is very IP you have defined against your domain DNS.
But that is only needed if you have bounded IP with port in your conf file.
By default its *:80. So no need to bind.

Apache2 mod_write working for subdomain but not an IP address on same server

I have an Apache2 server running on CentOS 6.
There will be two subdomains running on this box.
sub1.domain.com
sub2.domain.com
For now the first subdomain is set up with DNS and mod_write working correctly. The second domain still has its DNS pointing to an older server and I will migrate the second domain's DNS to the new box's IP address.
Naturally I'm trying to test the new setup for sub2.domain.com before I migrate. I've configured the "default" web page for the box's IP address to have a document root which points to the future sub2.domain.com Laravel application.
mod_write rules in both .htaccess files are identical in both document roots and exactly match the recommended Laravel defaults.
Any insights appreciated as to why Apache2 would not process mod_write directives in an .htaccess file at a default document root accessed directly through an IP address much appreciated. I've combed through all the httpd.conf and vhost.conf files and nothing obvious sticks out as a likely culprit.
Thanks in advance for your help.

Host multiple domains with apache

I'm trying to set up an ubuntu server to act as a dns server and host a simple webpage, some git repos, and some software for issue tracking, code review, and the like. I settled on Phabricator as the issue tracking/ code review software of choice, since it seemed to be a good all-in-one solution. I've got my server hosting my webpage and git repos, so that part seems to be working ok. Now here's the issue I've run into (from Phabricator configuration instructions):
If you haven't already, set up a domain name to point to the host you're installing on. You can either install Phabricator on a subdomain (like phabricator.example.com) or an entire domain, but you can not install it in some subdirectory of an existing website
I have no idea where to even begin setting up another domain name on my server. How do I set up a second domain name for Phabricator to use?
I see a lot of guides online that say to modify resolv.conf to add a dns entry, however mine looks like this:
Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 192.168.1.1
and I'm not sure what I should change to get dns entries to show up here.
I'm assuming you have only one IP address, which means you should be using virtual name-based hosting. There are a number of tutorials for doing this, but in short:
Create a virtual host configuration file in:
/etc/apache2/sites-available
For example:
nano /etc/apache2/sites-available/phabricator
Run:
a2ensite phabricator (in this example, but use the configuration file name you used above)
apache2ctl restart
The configuration file (which can be named whatever you'd like) needs to contain a number of items. A simple example would look like this:
<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example.com
</VirtualHost>
DocumentRoot is the full path to the root of your site, usually where index.html, index.php, or the like is located. The default is /var/www. You could put somethig like /home/phabricator or /var/www/phabricator, but make sure you install Phabricator in the directory you specify.
ServerName is the full FQDN of your site, such as "www.google.com" or "phabricator.yourdomain.com" or even "phabricator.local". Basically it's the same value as you have set in your DNS for your A record, or in your /etc/hosts file. If you don't know about /etc/hosts, then disregard that part.
You'll probably need a few more directives in your configuration file, but you can find what's available on Google. I would suggest following some tutorials to get your configuraiton right.
But overall, you just need to create a virtual host config file, enable it, then restart the server, which is what the above instructions do. Apache will respond to the web request based on the site you put into your address bar.
P.S. Just noticed your DNS part of the question. Do you have DNS set up publicly to point a domain (example.com) or subdomain (something.example.com) to your server's IP address?

Apache2 virtualhost configuration trouble

This is my situation:
I have Redmine and Gitlab in my server which does not have a domain associated, because I will use the server IP address.
I want to configure two virtualhosts in apache2 with SSL in order to serve the above web applications, so I can access them like this:
https://x.y.z/redmine
which is located in /var/www/
https://x.y.z/gitlab
located in /home/git/github/public
I have configured apache by enabling two files in site-enabled: github.vhost and gitlab.vhost. The problem is that I cannot set gitlab to be accessible with
https://x.y.z/github
but only in
https://x.y.z
probably beacuse I do not use a domain but only the IP address of the server, and I don't know exactly how to manage it.
I would need some suggestion on how to correctly set the two vhost files.
Any suggestion?