apache vhost setup doesnt work - apache

First things first .. im pretty new to apache configuration.
I'm trying to configure vhosts locally for an apache
(Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.6.3 according to phpinfo()).
Its set up via XAMPP (xampp-win32-5.6.3-0).
Operating system is Windows 7 Home Premium SP1.
So i already read some articles about setting up vhosts (also some in this forum).
My host file looks as follows:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# ::1 localhost
127.0.0.1 localhost
127.0.0.1 test.local
My C:\xampp56\apache\conf\extra\httpd-vhosts.conf contains the following code:
<VirtualHost *:80>
ServerName test.local
ServerAlias test.local
DocumentRoot "C:/xampp56/htdocs/test.local"
DirectoryIndex app.php
</VirtualHost>
It is loaded in the C:\xampp56\apache\conf\httpd.conf file.
Include conf/extra/httpd-vhosts.conf
The Module mod_log_config.so is also loaded in the httpd.conf
LoadModule log_config_module modules/mod_log_config.so
(After all editing in the config files i saved them and restarted apache.)
When I type test.local (or http://test.local) in FireFox it always says "test.local was not found". When i call up localhost however its working.
I havn't found any answers yet except to check if the vhost and the host file are set up correctly (which seems to be the case here to me).
Sorry for the long post and I am sorry in case it's just some stupid mistake i made here.
Thx for any help!
EDIT:
Here is also the output from the httpd -S command:
VirtualHost configuration:
*:80 test.local (C:/xampp56/apache/conf/extra/httpd-vhosts.conf:44)
*:443 www.example.com (C:/xampp56/apache/conf/extra/httpd-ssl.conf:80)
ServerRoot: "C:/xampp56/apache"
Main DocumentRoot: "C:/xampp56/htdocs"
Main ErrorLog: "C:/xampp56/apache/logs/error.log"
Mutex ssl-cache: using_defaults
Mutex default: dir="C:/xampp56/apache/logs/" mechanism=default
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
PidFile: "C:/xampp56/apache/logs/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG

I found the solution.
It was Avira blocking access to my host file .. disabled that option in avira and vhosts work fine now.
Beside that i needed admin rights which were not set for the account i was working with ..

Related

Error setting up a virtual host in Apache/Ubuntu

I am trying to configure a virtual host on a dedicated server for one of domains - I have never set up a server before, so unsurprisingly I have gotten stuck. I have been following a couple of tutorials and it looks like I have actually succeeded in setting up the virtual host, however after making the changes my test index page will not load and the standard "Ubuntu" page will not load now either when I enter the server's IP into my address bar.
I have created the subdirectory for the domain files as "/var/www/mysite.com/public_html" and have copied and edited the default ".conf" file so that it looks like this:
<VirtualHost *:80>
ServerAdmin me#mysite.com
ServerName mysite.com
ServerAlias mysite.com
DocumentRoot /var/www/mysite.com/public_html
<Directory /var/www/mysite.com/public_html>
Options -Indexes
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
After this I ran the "sudo a2ensite mysite.com.conf" command and restarted apache. When I check run "apache2ctl -S" I get the following response:
VirtualHost configuration:
*:80 is a NameVirtualHost
default server mastnew.com (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost mastnew.com (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost mysite.com (/etc/apache2/sites-enabled/ibeka.xyz.conf:1)
alias www.mysite.com
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
It looks like everything when exactly as the tutorial expected. As I said though, when I navigate to my domain the browser just hangs from thirty seconds or so and then tells me it cannot open the page. If I remove the "mysite.com.conf" file and try again, I land on the "Ubuntu" page. So something is going on with my new ".conf" file or there is some other conflict that is causing the server to freak out.
Any help would be appreciated. Thanks.
This may not be a useful answer if anyone is looking at this later, but it's worth trying if you're stuck. I really don't understand why it worked, but my domain was available after I tried this:
So I disabled the site using "sudo a2dissite mysite.com.conf" and then restarted apache. I checked that it was disabled and that my root index was up online (I'll be hiding/deleting this later). Then I re-enabled the site with "sudo a2ensite mysite.com.conf" and again restarted apache. After this, for some reason, the site became available online and all of my public files are now accessible.

Apache Apache/2.4.7 (Ubuntu) ProxyPass

I'm trying to configure a simple ProxyPass using this file (as simple as possible) linked in /etc/apache2/sites-enable form sites-avalable (same file seems to work on apache 2.2 but may be i have done other configuration on previous installation and i canìt remember those configuration)
Note i use an IPADDRESS and not a Server Name but i think this is not the problem.
Note 2: i'm not an apache web server expert :)!
ServerName IP_SERVER_ADDRESS
# Redmine
ProxyPass /redmine http://IP_SERVER_ADDRESS:8555/redmine
# test1
ProxyPass "/test1" "http://IP_SERVER_ADDRESS:9180/test1/"
ProxyPassReverse "/test1" "http://IP_SERVER_ADDRESS:9180/test1/"
# test2
ProxyPass /test2 http://IP_SERVER_ADDRESS:8880/test2
ProxyPassReverse /test2 http://IP_SERVER_ADDRESS:8880/test2
DocumentRoot /var/www
But it didn't work, so the url
http://IP_SERVER_ADDRESS:8880/test2
work fine , but the proxied url
http://IP_SERVER_ADDRESS/test2
did not work , with the error
Not Found
The requested URL /redmine was not found on this server
Output of apache2ctl -S seems strange as apparently no VirtualHost configuration is used (?)
VirtualHost configuration:
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex proxy: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
Quite sure i'm missing some simple thing but i can't find it!
This answer is tested in Apache Apache/2.4.7 (Debian) ProxyPass.
See /etc/apache2/apache2.conf:
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
previous version was
# Include the virtual host configurations:
Include sites-enabled/
So basically in apache 2.4 (Debian and derivated) you must use file with a .conf extension to limit headache....
In Apache 2.2 the .conf extension in file name is not needed.
Other Details:
In sites-enabled configuration files (a soft link to sites-available) MUST be have an extension .conf so WHATEVER_YOU_WANT.conf
You MUST use a2ensite to enable a configuration, because if the file in sites-available did not have the "right" extension ".conf" it say "ERROR: Site WHATEVER_YOU_WANT does not exist!". So for example if you use a file named mysite and try to enable the configuration mysite with the command "a2ensite mysite" you receive an error. If you use a file named myfile.conf same command will work fine... If you manually create a soft link in sites-enabled to a conf file without the "conf" extension , the site will not work!!
You can create a soft link in sites-available with the right extension (.conf) to a file WITHOUT the right extension alredy peresent in sites-available. In such a case the configuration will work but if you use a2dissite to disable the site it will say "ERROR: Site WHATEVER_YOU_WANT does not exist!"
After finding the solution i found some link around
https://www.linode.com/docs/security/upgrading/updating-virtual-host-settings-from-apache-2-2-to-apache-2-4

Apache reverse proxy config always returning same site

Situation: ubuntu server 14.04 with apache and bugzilla installed on a dedicated vm.
Everything works well, on bugzilla.myexternal.com, bugzilla.myinternal.xyz and on LAN IP address
Now I want to make other internal servers available on the same external IP, by host name based forwarding, with the same apache instance. DNS records added and resolving correctly for other1.myexternal.com, other2.myexternal.com, etc
(internal DNS already covers/resolves internal names of otherX to local ip addresses for internal use)
After reading through the atricles here and on apache, I thinck I was able to distill the bugzila site-conf and add the other site-conf as intended. However, there are so many contradicting articles with different 'solutions', and in the end I can't make it work. Whatever host is called, I always end up with the initial bugzila site. When I a2dissite bugzilla, then I always get forwarded to the first reverse proxy site (showing that the proxying actually works)
Here is what the site-conf looks like.
bugzilla:
<VirtualHost *:80>
ServerName bugzilla.myexternal.com
ServerAlias 192.168.aaa.bbb
DocumentRoot /var/www/html
<Directory /var/www/html>
AddHandler cgi-script .cgi
Options +ExecCGI
DirectoryIndex index.cgi index.html
AllowOverride Limit FileInfo Indexes Options
</Directory>
</VirtualHost>
other1: (and similar for otherX, all having static internal ip)
<VirtualHost *:80>
ProxyPreserveHost On
ServerName other1.myexternal.com
# ProxyRequests off ->also tried without commenting out
ProxyPass / http://192.168.aaa.ccc/
ProxyPassReverse / http://192.168.aaa.ccc/
</VirtualHost>
apache reload without errors/warnings.
When looking with 'apache2ctl -S' I see that they are loaded correctly. But in all cases (when disabling certain virtual hosts), the site that gets shown is always the default server mentionned by ' apache2ctl -S':
VirtualHost configuration:
*:80 is a NameVirtualHost
default server bugzilla.myexternal.com (/etc/apache2/sites-enabled/bugzilla2.conf:1)
port 80 namevhost bugzilla.myexternal.com (/etc/apache2/sites-enabled/bugzilla2.conf:1)
alias 192.168.aaa.bbb
port 80 namevhost other1.myexternal.com (/etc/apache2/sites- enabled/comfoway.conf:2)
port 80 namevhost other2.myexternal.com (/etc/apache2/sites- enabled/spcway.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex proxy: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex watchdog-callback: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: MODPERL2
Define: ENABLE_USR_LIB_CGI_BIN
User: name="www-data" id=33
Group: name="www-data" id=33
Question: what to do to make this work and not always show the default server?
I found the cause, and I'm embarrased to say, but it's down to prescribing the wrong domain and TLD for the other serverNames. We have several doamin names with only different TLD that I mixed up. But they do resolve, due to how our DNS is set up with CNAME records.
As a result, no matching serverName is found by apache and the default is shown.
The good news is (for other users) that the above configuration works, so if you need a reverse proxy and local server combination on this unubtu and apache 2.4, then this is the way forward.
regards,
Christof

WAMP server name not found for virtual host in apache

System: Windows7 64-bit
WAMP server 32-bit version: Apache : 2.4.9 MySQL : 5.6.17 PHP : 5.5.12 PHPMyAdmin : 4.1.14 SqlBuddy : 1.3.3 XDebug : 2.2.5
My issue is that when I navigate to my project "local.blamo1.com" - via WAMP "Localhost" chrome returns: "Oops! Google Chrome could not find local.blamo1.com"
I am able to access my project folder with "localhost/local.blamo1.com" - But as I understand it, this is bad practice as it will throw off server mapping by one directory. I would like to be able to access the project with the designated server alias. I have implemented the following...
httpd-vhosts.conf
Location: "C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.config"
# Virtual Hosts
#
# Required modules: mod_log_config
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
<VirtualHost *:80>
DocumentRoot "c:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "c:/wamp/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/local.blamo1.com"
ServerName local.blamo1.com
ServerAlias local.blamo1.com
<Directory "c:/wamp/www/local.blamo1.com">
AllowOverride All
Require local
</Directory>
</VirtualHost>
hosts file
Location: "C:\Windows\System32\drivers\etc\hosts"
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
127.0.0.1 localhost
127.0.0.1 local.blamo1.com
#::1 localhost
#::1 local.blamo1.com
httpd.conf
Location: "C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf
I have un-commented these lines
Include conf/extra/httpd-vhosts.conf
LoadModule vhost_alias_module modules/mod_vhost_alias.so
Current Diagnosis
Apache httpd -t return: "Syntax OK"
I think this has something to do with my DNS or ports, or whatev - as I do not have enough experience with this level or how the DNS is not able to resolve the domain:
after I tried to ping the project:
ping local.blamo1.com
"Ping request could not find host local.blamo.com. Please check the name and try again.
Please help me understand why I am getting this issue. I have been working on this for a day and a half. Apologies if there is not adequate information for your to make a diagnosis of the problem. I will provide more information as necessary.
All my best.
I was able to solve this issue - props to this post: http://www.tweaksforgeeks.com/windows7/2011/02/windows-7-hosts-file-ignored
The issue appeared to be a corrupted "hosts" files - all I know for sure was that the solution was to delete the hosts file and create a new one with raw text from the old. The causality is inexplicable.
This solve my problem. After hours of making it work. Turns out I was careless about the host file. Saving as txt and then just removing the extension to replace the original file.

XAMPP, Can't access htdocs

I have problem accessing << localhost/htdocs >>
URLs tried: localhost/htdocs
localhost:80/htdocs
ip:80/htdocs
Always same error
ERROR:
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
All services are running correctly I am using port :80
I looked into apache conf :
Here is Doc Root
DocumentRoot: The directory out of which you will serve your
documents. By default, all requests are taken from this directory, but
symbolic links and aliases may be used to point to other locations.
DocumentRoot "C:/xampp/htdocs"
Please help I can't find the solution..
Thanks
Command Line:
Setting environment for using XAMPP for Windows.
c:\xampp
httpd -S
VirtualHost configuration:
*:443 is a NameVirtualHost
default server www.example.com (C:/xampp/apache/conf/extra/httpd-ssl.co
nf:83)
port 443 namevhost www.example.com (C:/xampp/apache/conf/extra/httpd-ss
l.conf:83)
port 443 namevhost www.example.com (C:/xampp/apache/conf/extra/httpd-ss
l.conf:83)
ServerRoot: "C:/xampp/apache"
Main DocumentRoot: "C:/xampp/htdocs"
Main ErrorLog: "C:/xampp/apache/logs/error.log"
Mutex ssl-cache: using_defaults
Mutex default: dir="C:/xampp/apache/logs/" mechanism=default
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: using_defaults
PidFile: "C:/xampp/apache/logs/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Does that seam correct?
DocumentRoot points to the root directory for a given virtual host. So you don't need to append htdocs to the URI if it is already specified in the DocumentRoot. Try:
http://localhost
Also, make sure you restart apache every time you edit a virtualhost/configuration file, since they are only checked/loaded once and that is on server startup.
If you still cannot get it to work, then httpd -S in command line to ensure the respective vhost is correctly loaded.
I think this is a port issue, I faced same kind of issue and I solved it following way
I opened the xampp control panel and clicked on the cofig button for apache service, opened the first link, Apache(httpd.conf) - this can be found in xampp\apache\conf directory also.
Then searched '80'(without quoatation) and changed them to 81 and saved the file.
Restarted the apache service.
Typed 'localhost:81/project_folder/' in the browser.
Then it worked fine.
I have been facing the same problem of late. It is because I have been including htdocs in the URI but it unnecessary thats why the error occurs.
Try this Working with XAMPP
Under XAMPP root directory there is a folder called htdocs. That is where you should put your web site related stuff. For each web site you create, it is better to create a folder inside htdocs folder and then put content inside that to avoid conflicts.
For an example, you can create a folder called learnphp inside htdocs folder and put welcome.php inside that. Then you can access it via the URL
http://localhost/learnphp/welcome.php.
Hope it helps.
You need to configure the VHosts Config file to point at your htdocs folder
Read the docs at:
http://127.0.0.1/dashboard/docs/configure-vhosts.html