Can't get wampserver 2.5 accessible from a remote machine - apache

I desesperate to get wamp working!
I've installed wampserver 2.5 on my win7 64bits machine.
In the httdp.conf file, I just commented out the line regarding vhosts:
Include conf/extra/httpd-vhosts.conf
The httpd-vhosts.conf contains:
<VirtualHost *:80>
DocumentRoot "C:/Users/Alain/Dropbox/Website/exemples/Grafikart/Petsy_alain.dev"
ServerName petsy.dev
ServerAlias www.petsy.dev
<Directory "C:/Users/Alain/Dropbox/Website/exemples/Grafikart/Petsy_alain.dev">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
<RequireAny>
Require local
Require ip 192.168.1
</RequireAny>
</Directory>
</VirtualHost>
(I also tried Require all granted)
I first installed wampserver 2.5 64 bits.
I was able, from my local machine to access http://petsy.dev
But when I tried to access to http://192.168.1.16/petsy.dev from an other machine of my LAN, I was always getting a 403 error (Forbidden):
[Thu Dec 04 14:43:08.519329 2014] [authz_core:error] [pid 11088:tid 776] [client 192.168.1.15:39975] AH01630: client denied by server configuration: C:/Users/Alain/Dropbox/Website/exemples/Grafikart/Petsy_alain.dev
[Thu Dec 04 14:43:08.635335 2014] [authz_core:error] [pid 11088:tid 776] [client 192.168.1.15:39975] AH01630: client denied by server configuration: C:/wamp/www/favicon.ico
I got access remotely to petsy.dev when I added in the remote PC hosts file the line:
192.168.1.16 petsy.dev
In that case, I was able, on my remote machine, to access to the server using 'http://petsy.dev'.
First I don't understand what does it change on the server side and secondly I cannot be satisfied by this solution as I cannot use it on a smartphone.
As I wasn't able to find an answer anywhere, I finally tried to install wampserver 2.5 32 bits!
Same problem! But with a different error:
I can ALWAYS access to my petsy.dev website locally but now, when I try to access it remotely, I get a 404 error (not Found) !!!
Here are the access logs of apache
From my local machine:
xxxx::7d1a:xxxx:9672:xxxx - - [05/Dec/2014:19:22:25 +0100] "GET / HTTP/1.1" 200 40438
From my remote machine:
192.168.1.15 - - [05/Dec/2014:19:22:30 +0100] "GET /petsy.dev/ HTTP/1.1" 404 295
httpd -T answers syntax OK
httpd -S says:
VirtualHost configuration:
*:80 is a NameVirtualHost
default server localhost (C:/wamp/bin/apache/apache2.4.9/conf/extra/httpd-vhosts.conf:23)
port 80 namevhost localhost (C:/wamp/bin/apache/apache2.4.9/conf/extra/httpd-vhosts.conf:23)
alias localhost
port 80 namevhost petsy.dev (C:/wamp/bin/apache/apache2.4.9/conf/extra/httpd-vhosts.conf:34)
alias www.petsy.dev
ServerRoot: "C:/wamp/bin/apache/apache2.4.9"
Main DocumentRoot: "C:/wamp/www/"
Main ErrorLog: "C:/wamp/logs/apache_error.log"
Mutex rewrite-map: using_defaults
Mutex authdigest-client: using_defaults
Mutex default: dir="C:/wamp/bin/apache/apache2.4.9/logs/" mechanism=default
Mutex authdigest-opaque: using_defaults
PidFile: "C:/wamp/bin/apache/apache2.4.9/logs/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: APACHE24=Apache2.4
Please, please which stupid error did I make ????

You dont need the <RequireAny> so just try this
<VirtualHost *:80>
DocumentRoot "C:/Users/Alain/Dropbox/Website/exemples/Grafikart/Petsy_alain.dev"
ServerName petsy.dev
ServerAlias www.petsy.dev
<Directory "C:/Users/Alain/Dropbox/Website/exemples/Grafikart/Petsy_alain.dev">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require local
Require ip 192.168.1
</Directory>
</VirtualHost>
Additional Info
I dont think you understand what is happening when you create Virtual Hosts.
Basically when Apache see's it has one or more Virtual Hosts configured, you are teling Apache that it is the server for more than one domain name. The important part in that sentence is more than one domain name.
This causes Apache to examine the domain name on each incoming connection. It will then match the domain name to one of its Virtual Hosts definitions and change the DocumentRoot and potentially other parameters to those set in that Virtual Host.
So the important thing is that you use a matching domain name in the browser of the other PC you are using to get to Apache with a domain name it knows about.
This would normally be done by a DNS Server on the real internet, but while you are inside your own local network i.e. safely behind your router you have to use another method. You could setup your own local DNS Server, but thats quite complicated.
So the simple solution is to use the HOSTS file on the other PC's in your network.
So on the other PC (not the PC running WAMPServer), edit the \windows\system32\drivers\etc\hosts file and add this
192.168.1.16 petsy.dev
Then either reboot or do this to reload the windows dnscache
Start a command windows using "Run as Administrator" and execute these 2 commands to reload the cache
net stop dnscache
net start dnscache
Now you can use the correct domain name from the browser on the non-wampserver pc like so
http://petsy.dev
And the browser will find that petsy.dev lives on ip address 192.168.1.16. When the connection is made with 192.168.1.16 it will be using the corretc domain name i.e. petsy.dev and apache will find the virtual host and set everything as per the VH config and server pages from the correct folder.

here is a great tutorial
Project Links do not work on Wamp Server
Answer #1 worked for me
I'm running windows 7 64 bit
I have wampserver2.5 (64 bit) installed on a hd assigned to letter A
All my dev sites are located on A:\websites
In A:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf I have this
<VirtualHost *:80>
DocumentRoot "A:/websites"
ServerName localhost
ServerAlias localhost
<Directory "A:/websites">
AllowOverride All
Require local
</Directory>
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "A:/websites/example.dev/www
ServerName example.dev
ServerAlias www.example.dev
<Directory "A:/websites/example.dev/www>
AllowOverride All
Require local
Require ip 192.168.10
</Directory>
</VirtualHost>
On the computer running wamp I adjusted the host file as follows
127.0.0.1 example.dev
::1 example.dev
On the local remote computer I've added an entry to the host file as
192.168.10.100 example.dev (this is the ip address of the computer running wamp)
next step is to clear your dns cache
open a terminal on the windows box that's not the web server
type "net stop dnscache"
type "net start dnscache"
Open a browser and point it to example.dev and it works
hope this helps

Related

Accessing local host from another machine

I have seen many answers on this with what would appear to be simple solutions, none of which are working for me at this time.
I have WAMP install with Apache 2.4.33 32bit installed on a PC. I can access the site on that PC without a problem using the alias mySite.local.
The PC's host file looks like this
127.0.0.1 mySite.local
The remote lap top's host file is
192.168.1.114 mySite.local
That is the IP of the PC on the network.
httpd.conf
Listen 80
ServerName mySite.local:80
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot "H:/Intranet/mySite_v2_www/public"
httpd-vhosts.conf
<VirtualHost *:80>
ServerName mySite.local
DocumentRoot "H:/Intranet/mySite_v2_www/public"
</VirtualHost>
I have tried disabling the windows firewall and virus checker on the PC.
The laptop appears to be getting there but being blocked. The message is..
Forbidden
You don't have permission to access / on this server.
Apache/2.4.33 (Win32) PHP/7.2.4 Server at mySite.local Port 80
So it looks like it can see Apache but is being blocked. So what else needs to be set to get access to the server?
Here are two of the links that I have been following to try and get this to work
Error message "Forbidden You don't have permission to access / on this server"
and
How do I connect to this localhost from another computer on the same network?
Thanks for any direction you can provide.
To complement the answer of Paul Neale:
Forbidden You don't have permission to access / on this server. Apache/2.4.33 (Win32) PHP/7.2.4 Server at mySite.local Port 80
That message is an answer from Apache. Disabling the windows firewall and virus checker on the PC won't have any effect, you are already reaching Apache there is not any networking problem.
Apache is receiving your request to access the root folder "public":
H:/Intranet/mySite_v2_www/public
But denies the request because, the directive Require local is enabled. This directive means, you can access to the content of public from the local server (localhost), which is the same to say 127.0.0.0 or localhost.
What you wanted is to tell apache that allows the access of certain IP address to the root directory "public".
When you changed the directive to Require all granted you are telling apache that, no matter who asks, give it access to / (root folder) in other words "public".
So, what you was searching for is "Access Control" in apache, and the directive Require can be used with IP address, here's the main document from Apache, this is an example:
Require host address
Require ip ip.address
It's important to differentiate between Network//Permissions problems. If you want to know if you are able to communicate (At network level) with Apache, you could do:
telnet <IP_APACHE_SERVER> <PORT_APACHE_SERVER>
#example: telnet 172.10.10.2 80
So after playing around will combinations for a day I found that in the httpd.conf I needed to change Require local to Require all granted in the section.
<Directory "H:/Intranet/mySite_v2_www/public/">
Options +Indexes +FollowSymLinks +Multiviews
AllowOverride all
# onlineoffline tag - don't remove
# Require local
Require all granted
</Directory>

Can't debug to fix virtual host issue on windows 10

I have problem when i try to setup virtual host on my windows 10 pc.
In my hosts file:
127.0.0.1 project.dev
In my httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster#project.dev
DocumentRoot "path to project"
ServerName project.dev
ErrorLog "logs/project.dev-error.log"
CustomLog "logs/project.dev-error-access.log" common
<Directory path to project>
Require all granted
Allowoverride All
</Directory>
</VirtualHost>
httpd.exe run without error.
I try to run:
localhost
It works but when i try to run:
project.dev
in the browser, it does not work.
This site can’t be reached
project.dev refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
I have tried to solve this issue for hours but i can't.
Windows firewall logs, System logs, Applications logs, Apache logs don't show me any infos to help me.
Could anyone help me debug this issue?
Thanks!
------------UPDATE--------
Today, i updated php and apache to newer version
https://windows.php.net/downloads/releases/php-7.2.6-Win32-VC15-x64.zip
https://www.apachehaus.com/downloads/httpd-2.4.33-o110h-x64-vc14-r2.zip
and tried to run project.dev with simple vhost:
<VirtualHost *:80>
DocumentRoot "C:/Users/0x1111/workspace"
ServerName project.dev
#ServerName www.example.com:80
</VirtualHost>
Chrome shows https error:
Your connection is not private
Attackers might be trying to steal your information from project.dev (for example, passwords, messages, or credit cards). Learn more
NET::ERR_CERT_AUTHORITY_INVALID
Running localhost it works normal.
----UPDATE -----
when i use nslookup localhost:
Server: resolver1-fs.opendns.com
Address: 208.67.222.123
Non-authoritative answer:
Name: localhost
Addresses: ::1
127.0.0.1
But when i nslookup project.dev:
Server: resolver1-fs.opendns.com
Address: 208.67.222.123
*** resolver1-fs.opendns.com can't find project.dev: Non-existent domain

Adding VirtualHost breaks all other server folders

I am trying to run designer-school.com on my server. I have added this VirtualHost
<VirtualHost *:80>
DocumentRoot /var/www/html/backendtwo
ServerName www.designer-school.com
<Directory /var/www/html/backendtwo>
Allow from all
Options +Indexes
</Directory>
</VirtualHost>
This now means I can access the domain designer-school.com
But if i try and access other folders on this server I get 404 errors for example
http://joshhornby.co.uk/typewriter
And also If i try and access a blog post on the root website
http://joshhornby.co.uk/post/web-course
Is there a way to run the domain designer-school on the server but it won't impact the other sites running on the server?
I have looked at running multiple VirtualHosts must when I restart the server I get this message
[warn] _default_ VirtualHost overlap on port 80, the first has precedence
Is there something in my .haccess file I need to change?

Apache Virtual Host Site Inaccessible

I'm setting up a dedicated server with multiple virtual hosts. The DNS is registered correctly...
$ ping mydomain.com
$ ping 8.8.8.8 (for example)
Both return the IP address as expected and it's correct.
The last line of my httpd.conf file is:
Include /etc/httpd/sites-enabled/
And the contents of mydomain.com.conf (in the above folder) are:
<VirtualHost 8.8.8.8:80>
ServerName mydomain.com
ServerAdmin jongosi#mydomain.com
# Indexes + Directory Root
VirtualDocumentRoot /var/www/html/mydomain.com
DocumentRoot /var/www/html/mydomain.com
<Directory "/var/www/html/mydomain.com">
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I suspected that the firewall was interfering with the access so I have disabled it with:
$ /etc/init.d/iptables stop
The server is running CentOS 6 64-bit with the latest LAMP stack.
Trying to go to the address http://www.mydomain.com/ or the IP address in browser both result in eventual time-out. Any suggestions would be helpful. Thank you!
EDIT 1
Running apachectl -S returns...
VirtualHost configuration:
8.8.8.8:80 mydomain.com (/etc/httpd/sites-enabled/mydomain.com.conf:6)
Syntax OK
EDIT 2
Following the request in Chrome's inspector returns a 204 header response.
204 No Content
The server successfully processed the request, but is not returning any content.
Thanks.
SOLVED
My hosting provider had configured their hardware firewall to only allow traffic through on port 22 (SSH). Why on earth would I NOT want traffic on my WEBSITE.
$_hosting_provider = "In.sane";

Ruby on Rails - etc/hosts config file

This is what I have in my "etc/hosts" file:
127.0.0.1 localhost
127.0.1.1 gotqn-System-Product-Name
127.0.0.1 depot.yourhost.com
and this is what I have added in the apache2.conf file:
<VirtualHost *:80>
ServerName depot.yourhost.com
DocumentRoot "/home/gotqn/Aptana Projects/depot/public/"
<Directory "/home/gotqn/Aptana Projects/depot/public">
AllowOverride all
Options -MultiViews
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
When I type http://localhost/ my browser lists all my files in the "var\www" folder and when I type http://depot.yourhost.com/ it displays the following error:
We're sorry, but something went wrong.
I have checked the production.log file of my rails applications and it says:
Connecting to database specified by database.yml
Started GET "/" for 127.0.0.1 at 2013-01-13 20:32:41 +0200 Processing
by StoreController#index as HTML Completed 500 Internal Server Error
in 3ms
ActiveRecord::StatementInvalid (Could not find table 'carts'):
app/controllers/application_controller.rb:46:in rescue in
current_cart' app/controllers/application_controller.rb:44:in
current_cart' app/controllers/store_controller.rb:11:in `index'
I suppose that there is something wrong with my database configuration as the table exists but it is not found.
Anyway, my questions is how the hosts file knew that "depot.yourhost.com" means to open the rails applications and "localhost" do list my "var\www" folder - I have thought that RoR is using port 3000.
Why there is no conflict for port 80?
Rails applications run under port 3000 when running with the lightweight Webrick server. Since you are running Apache with mod_passenger, the application will be available at port 80 according to your Apache configuration.
The hosts file contains an entry 127.0.0.1 depot.yourhost.com which directs that domain name to your local adapter 127.0.0.1. The hosts file should always be checked before a nameserver needs to be consulted to retrieve a name's address.
Next, your Apache configuration includes a VirtualHost which is listening on all network adapters due to the * in
<VirtualHost *:80>
Your Apache configuration must be setup to use name-based virtual hosting, after which the ServerName variable is matched against the HTTP_HOST request header which was supplied by your request to depot.yourhost.com.
Therefore, you can have as many VirtualHosts as needed all using port 80 on the same IP address, and Apache will decide which to route the request to based on the HTTP_HOST header.
Finally, mod_passenger will detect if an application is a Ruby on Rails application by inspecting the directory contents around the DocumentRoot which you have specified in the VirtualHost configuration. If it finds the public directory as its DocumentRoot and a RoR application at a level higher, Passenger will attempt to start the Rails app.
Now, as to why you are getting a directory listing from localhost... Elsewhere in your Apache configuration you must have a VirtualHost which matches the ServerName localhost and sets its DocumentRoot to /vart/www.
<VirtualHost *:80>
ServerName localhost
# or...
ServerAlias localhost
</VirtualHost>
If you are seeing the contents of the directory listed out rather than a 403 Forbidden (absent an index file like index.html), it is because the Apache server config or VirtualHost config does not include the directive:
Options -Indexes
Add that in the global httpd.conf to prevent listing directories server-wide.