Multiple Virtual Hosts Subdomain 404s? - apache

I have an Apache Server running on a CentOS box running 3 websites using VirtualHosts.
The problem is, is when I go to a non-existent subdomain on the websites it always shows the files from Website #1. How do I fix this?
Thanks!
Here's my httpd.conf: http://pastebin.com/5bDgrR2W (I've replaced my email and domain names)

You have a default host configured, so whenever an unknown domain is called, the default config will be used.

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

Configure virtual host on Apache

I have a VPS with a single IP address and with Virtualmin/Webmin installed. I have created a virtual host *example.com *that will answer to www.example.com (the domain already points to the IP address of the VPS). However, when I access www.example.com I am not seeing the website I have uploaded for example.com but rather the default server:
It works!
This is the default web page for this server.
The web server software is running but no content has been added, yet.
What should I do? Do I have to configure DNS or something?
Yes, you will need to configure DNS for your www.* site if it has not been done already. This www.* alias may have been created automatically when you set up the domain in DNS, but perhaps you will need to specify it explicitly.
Seeing the message "It works!" is a common issue. Apache has a default virtual host which you may want to disable. Exactly how to do that depends on the platform of your web server (it's a good idea to mention the platform and version when asking questions).
For example, if you have shell access to a Debian or Ubuntu machine, you can use the command:
sudo a2dissite default
In virtualmin there may also be an option for this, see for example http://www.virtualmin.com/node/15854
Once you have DNS set up and the www.* domain responding correctly to pings with IP of your server, you will also need to make sure that the virtual host definition for your site includes the www.* alias.

Changing hostname of VPS - ZPanel Issue

Basically I've got a VPS setup but I incorrectly set the hostname. I left it for a while and it was fine, installed zpanel etc and now it's a 'web host' and everything was fine. Now I want to change the hostname so I logged into the hosting companies control panel for the server and changed the hostname.
The original and the new hostname are in the format of xxx.yyy.com. So nothing happend and I could still reach the zpanel login page via the 'old' host name even though in the hosting companies control panel it said it had changed.
For ease of explanation, we shall say my old hostname was xyz.example-domain.com and my new is server.another-domain.com. Both domains are controlled within this installation of zpanel.
Anyway. I deleted the dns entry for "xyz" on example-domain and, as you would expect, if you go to xyz.example-domain.com you get nothing. I created a dns A record for server.another-domain.com but now all you get is the default apache 'welcome to your server' page. To get to zpanel login, you need the IP address.
SO my question is, do I need to do something else? It seems that I need to change where this zpanel login page is getting displayed so that it can be server.another-domain.com. I'm guessing there is some file somewhere that I need to edit but I don't know what one and "the internet" isn't really helping as all I find is 'change the host name in the hosting companies control panel' which I've done.
PS It is an apache 2 server running CentOS 6
Take a look at your Apache configuration located in /etc/httpd/conf/httpd.conf. If you intend on running multiple domains off the same host, you'll need to setup Virtual Hosts. You'll see a detailed explanation of those settings toward the bottom of your configuration file.
Depending on where you've located your files, you'll want to set your DocumentRoot accordingly for each of your Virtual Hosts, and that will instruct Apache to look for the files in the proper places. By default, I believe it looks in /var/www.
NOTE: You will need to restart Apache or reload configurations whenever you alter your configuration file. You can do this by running either one of the following commands (as root):
/etc/init.d/httpd restart
/etc/init.d/httpd reload
Go to /etc/zpanel/panel/
rename: index.php -->panel.php (or any other name).
Then create index.php and let it in blank (or write a welcome message)
Finally enter to your zpanel like this: http://www.yourIP/panel.php
Works fine!
Is not necessary change any port

Home apache web server - final hurdle

Ok, so bit of noob question - having one of those days.
I have set up a home apache web server on Ubuntu. I have configured vhosts as I want to host multiple websites. These work fine in the local browser, e.g.
http://site1
http://site2
both display their various contents.
For the server side of things, I've configured port forwarding on my router to send all port 80 requests to the server IP.
When I go to an external browser and type in my servers external IP address I get the standard apache "It works!" message. When I type in ipaddress/site1 I get 404. The site1 is not in the standard apache default directory, I have it in home/username/Sites/site1 folder and httpd.conf file knows this.
How is it I can access these site1 and site2 sites externally?
Cheers
Just as you would do in your local browser. So typing in http://site1 would lead you to the first site. This is based on an assumption though, which is that you put the http://site1 address in your /etc/hosts file. When your computer looks up an URL, it first checks the hosts file (and your case will find the correct IP address there) and next will ask a global mechanism for the address.
The reason why it doesnt find anything at "ipaddress/site1" is because of the vhosts configuration. This teel Apache serve the content of a folder somewhere on your server as a separate hostname, e.g. http://site1. If you're requesting "ipadress/site1", you're actually telling Apache to look in the folder "site1" in its first root it encounters in your Vhost configuration.

Hosting not loading pages

i am new to web hosting, but i purchased a domain from namecheap.com and i purchased web hosting from ramnode.com to host my domain, i am using centOS 32bit as my server, and i have pointed my domain to ramnode nameservers that were provided to me.
The problem i am having here is that everytime i load my website, it just says
Index Of/
cgi-bin/
even though i have placed my web page files in var/www, and var/www/html like ramnode support told me too, it still does not want to work. Any suggestions?
It all depends on how your server is setup but here are a few things to check.
What are the permission levels for your files, who owns them and what group are they in? If you don't have proper permissions set they may not show. If the wrong person owns them they may not show.
Read over your httpd.conf (centos should have it in /etc/httpd/conf) see how your server is setup. It may not have a default setup, perhaps your using a virtual host?
In a nutshell we need more information to help you out.
You should have an
.htaccess or htaccess.txt file in your WWW root, whithin that file you need the following line:
DirectoryIndex index.htm index.html index.php
That is the priority order of your index page. (Your web project needs an index page)
So in otherwords your webserver will serve the first matching file that it finds in that list.
A quick fix if you cant find the htaccess file, is just make sure you have an index.html file in your var/www
I just reset my nameservers to point to ramnode's last night and am experiencing the same issue as the OP this morning.
I previously had no FQDN for the ramnode server and simply used my /etc/hosts file locally to point to the ramnode server. Through that method, I was able to make sure everything was setup just so - apache virtualhosts, .htaccess files, apache.conf, and httpd.conf files all operating as desired.
It seems to have something to do with the installation of the cpanel, which auto-fills DNS A records with a different IP than the one I was provided. changing it to ramnode's original IP simply leads to the same cgi-bin directory index. But going going to the original ip in the browser leads to my site, as I have the apache virtualhost set for the IP.
Ramnode sets subdomain a records such as cpanel.mydomain.com all set to the same new IP and those do function, so it leads me to believe a ramnode server is capturing the trafic elsewhere and should be sending it on but isn't.
It's a bit confusing where cpanel is taking me and why redirecting to my the domain.com. A record to the original IP seems to have no effect.