VirtualHost - Server not found - apache2

I'm running different websites on my webserver using Apache VirtualHosts. Now I have troubles getting one site to work. When I browse to the site in Firefox it says "Firefox can't find the server at www.mydomain.com", even though it's spelled correctly.
Further traceroute and ping both resolve to the correct IP, so I doubt it is because of a DNS issue.
I copied the VirtualHost-config file from a working site and just changed the domains and path on the server, which is existent. Further I checked that the site is enabled (with a2ensite), restartet apache, reloaded apache, but it is still not working.
Here's my VirtualHost-File:
<VirtualHost censored_ip:80>
ServerName mydomain.com
ServerAlias mydomain.com www.mydomain.com
ServerAdmin <myemail>
DocumentRoot /var/www/efin/
<Directory /var/www/efin/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error_efin.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
I hope someone can find the error here, since I have no idea where to look for it anymore. Thanks a lot in advance. I'd be happy to provide further information if needed.
Sincerely, Michael

Related

why apache2 virtual host overridden by default

(I'm kinda new to apache). I want to serve a wiki from my server myserver.com. I've created a DNS record for wiki.myserver.com, which can be reached by ssh/http/ping (so, it exists). I have default 000-default.conf, and the following wiki.myserver.conf:
<VirtualHost *:80>
ServerAdmin me#gmail.com
DocumentRoot "/var/www/html/wiki"
ServerName wiki.myserver.com
<Directory /var/www/html/wiki/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/wiki.myserver.com-error_log
CustomLog /var/log/apache2/wiki.myserver.com-access_log common
</VirtualHost>
Output of apache2ctl -t -D DUMP_VHOSTS:
VirtualHost configuration:
*:80 is a NameVirtualHost
default server wiki.myserver.com (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost wiki.myserver.com (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost wiki.myserver.com (/etc/apache2/sites-enabled/wiki.myserver.com.conf:1)
Surfing to http://myserver.com results in default apache2 index page, as expected.
Surfing to http://myserver.com/wiki results in wiki page, as expected (I guess).
Surfing to http://wiki.myserver.com results in default apache2 index page, where I expect the wiki page.
What am I doing wrong? I can't find a difference between my setup and what is generally instructed on the internet.
Can you help by suggesting some ways for debugging?
Any help is appreciated.
Just stupid; I had set my servername in /etc/apache2/conf-available/servername.conf to the wrong default. It's working just fine now.

How to change default Apache conf file for prestashop?

How to make prestashop to use prestashop.conf file which is a clone of 000.default.conf on my local server?
When I disable 000-default.conf, prestashop don't load.
When I enable that back, the web-page loads normally.
I've enabled prestashop.conf and reloaded/restarted Apache.
I use Apache2, prestashop 1.6.1, OS is Linux Mint.
Maybe someone can give me advice what else should I change. I haven't found solution so far.
P.S. prestashop.conf is complete clone of 000-default.conf.
Have you changed the paths to match these of your website?
<VirtualHost *:80>
ServerAdmin youradminlogin#yourwebsite.com
DocumentRoot "path/of/your/website"
ServerName website-name.com
Options All Indexes FollowSymLinks
<Directory "path/of/your/website">
DirectoryIndex index.html
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
Require local
</Directory>
</VirtualHost>
Make shure it is in /etc/apache2/sites-enabled/ !
After modifying this, you'll need to restart the server (sudo apachectl restart)

Get Apache VHost to load index.html instead of web directory

I'm having no luck finding this question answered so I'm asking this myself.
To get my VHost working, I followed this answer. My (working) "httpd-vhosts.conf" file looks like this
<VirtualHost *:80>
ServerAdmin jesuscc1993#gmail.com
DocumentRoot "Z:/Projects/Web/MetalTxus Site"
ServerName metaltxus.test
ServerAlias www.metaltxus.test
<Directory "Z:/Projects/Web/MetalTxus Site">
#Options FollowSymLinks
Options Indexes FollowSymLinks
AllowOverride All
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
As far as I know, I should change "Indexes" with "-Indexes" to make the web load "index.html" instead of the web directory.
However, when I did that, my WAMPServer wouldn't start. It would if I removed "FollowSymLinks" option but then all I got was a "403 - Forbidden" page ("you don't have permission to access "/" on this server").
As looking for a solution got me nowhere, I used this as my last resource.
I'm using latest WampServer version in Windows 8.1. I want to test an AngularJS application.
If you need any more information, go ahead and ask.
Try this :-
<VirtualHost *:80>
ServerAdmin jesuscc1993#gmail.com
DocumentRoot "Z:/Projects/Web/MetalTxus Site"
ServerName metaltxus.test
ServerAlias www.metaltxus.test
<Directory "Z:/Projects/Web/MetalTxus Site">
AllowOverride All
Options Indexes FollowSymLinks
Require all granted
</Directory>
</VirtualHost>
The Require all granted is Apache 2.4 syntax where you were using Apache 2.2 syntax when using
Order deny,allow
Allow from all
Now all you need to do is place a file called index.html or index.php in the "Z:/Projects/Web/MetalTxus Site" folder.
I would suggest removing the space in the folder name MetalTxus Site its not absolutely necessary but it removes another possible complexity.
Also if you dont actually mean to give access to the site to The Universe try using
Require local
And if you want to be able to access the site just from other PC's on your internal network use
Require local
Require ip 192.168.1
ADDITIONAL SUGGESTION:
Also check httpd.con has thi sline uncommented
LoadModule dir_module modules/mod_dir.so
An has this
<IfModule dir_module>
DirectoryIndex index.php index.php3 index.html index.htm
</IfModule>

Apache2 - Error 403 forbidden

I develop projects that I've located in /home/user/projects directory. This directory is chmod 777. The problem is that I'm always getting Error 403 Forbidden when I try to access this directory or any subdirectory. This is how my /etc/apache2/sites-available/000-default.conf looks like:
<VirtualHost *:80>
ServerName localhost
ServerAdmin user#user.com
DocumentRoot /home/user/projects
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Options +FollowSymLinks
<Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
</Directory>
<Directory /home/gtakacs/projects>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
Require all granted
</Directory>
</VirtualHost>
What's wrong with this? When I used /var/www as my document root, everything worked.
EDIT : try doing chmod -R 777 /home to make sure all your home is available (note that this solution is NOT RECOMENDED, having your project in /var/www would definitely be a better solution in my opinion)
(Can't comment so post reply)
Isn't there a config file in your project where you're supposed to set who can access the app? Check if you didn't forget to add your ip adress and domain name in this file.
When using Apache2 with Django framework (python), I had the same error, and it was because I forgot to add the domain name to authorized hosts.
You can also check access.log and error.log to have more detailed informations on what caused the error.
Command out:
#Order allow,deny
I had this issue before, the problem might be that your document root does not contain the described directories.

Apache virtualhosts and default server not working as expected (serving incorrect content)

I've been playing around with this for a couple of hours and have come to the conclusion that asking someone is probably the best way forwards!
I have a fairly out-of-the-box apache install (I've added mod_security and mod_python) so not touched /etc/httpd/conf/httpd.conf
I have a number of domains all running as 's and each with its own individual config file. They are all working as expected except for the fact that any unrecognised hostname will serve the content from the first virtualhost (which I know is the expected behaviour as the content from the first virtualhost is served)
I would like to set up a default set of content to be served if someone reaches my server through an unknown hostname - but in doing so, the first site now also serves this default content which I can't seem to find a reason for.
All of the config files for the individual sites are located in /etc/httpd/conf.d/sites (so that the are not auto-included) and are then included through a file (/etc/httpd/conf.d/sites.conf) which I created - before trying to set up the default server, its content is this:
Include conf.d/sites/*.conf
I modified it to be this to try to get the default server working:
<VirtualHost _default_:80>
DocumentRoot /home/sites/DEFAULT
<Directory "/home/sites/DEFAULT">
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Include conf.d/sites/*.conf
Just to re-iterate the problem - when the second version of sites.conf is active, the first VirtualHost also serves this content; the rest are fine. All of the sites' config files are syntactically correct and have no typos in the ServerNames.
(For reference, I have included the config file for the offending site - stored in /etc/httpd/conf.d/sites/DOMAIN.clintonmontague.co.uk.conf)
<VirtualHost *:80>
DocumentRoot /home/sites/clintonmontague.co.uk/www
ServerName clintonmontague.co.uk
LogLevel emerg
CustomLog /home/sites/clintonmontague.co.uk/_logs/access_log "combined"
<Directory "/home/sites/clintonmontague.co.uk/www">
AllowOverride none
allow from all
Options +Indexes
</Directory>
</VirtualHost>
Sorry for the overly-long question!
Other info: Apache 2.2, CentOS 5, MediaTemple (dv)
If what you say in your answer is correct, then try this. Note the ServerAlias line which should work instead of the PHP code:
<VirtualHost *:80>
DocumentRoot /home/sites/clintonmontague.co.uk/www
ServerName clintonmontague.co.uk
ServerAlias www.clintonmontague.co.uk
LogLevel emerg
CustomLog /home/sites/clintonmontague.co.uk/_logs/access_log "combined"
<Directory "/home/sites/clintonmontague.co.uk/www">
AllowOverride none
allow from all
Options +Indexes
</Directory>
</VirtualHost>
Just for reference - it appears that the problem was because /etc/sysconfig/network reported my HOSTNAME as clintonmontague.co.uk (which happened to be the first domain alphabetically). Therefor, default included that domain name so the default content was being served.
Thought I'd post the answer in case anyone was having similar problems :)
Not possible to change this in MediaTemple (every time the (dv) restarts, it resets this value)
I fixed it by including this line in the default content's index.php
<?php
if ($_SERVER['SERVER_NAME'] == 'clintonmontague.co.uk' )
{
header ('Location: http://www.clintonmontague.co.uk/');
}
?>

Resources