Windows 7 Localhost not working properly with XAMPP - apache

Hey there I'm running XAMPP on Windows 7 Ultimate 64bit and I'm having some issues with my localhost setup, and i've been trawling the internet for ages trying to get this fixed but to no avail.
My setup is as follows:
I've got apache and mysql running on XAMPP no problem, and I've edited my hosts file no problem, ensuring i've used admin privileges in note pad etc and that its not saved as a .txt file etc. It currently looks like this:
# Copyright (c) 1993-2006 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 handle within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 localhost
127.0.0.1 legendary-games.localhost
127.0.0.1 admin.legendary-games.localhost
127.0.0.1 shuuro.legendary-games.localhost
127.0.0.1 yearzero.legendary-games.localhost
127.0.0.1 chess.legendary-games.localhost
I've also made sure to make all the necessary changes to my vhosts file in apache and its all pointing to the correct address.
Now when I type localhost into my browser I get the page I'm meant to, however if I try any of the of the other addresses I get a page not found. I've tried pinging the addresses in the commandprompt and that comes back successful. I've tried many different things to try and get this working including flushing the dns, rebooting the dns, I've checked that the hosts file is being looked up properly by the services but to no avail.
Any help would be most appreciated.

Okay, here is the solution maybe this helps you.
Add this line or uncomment from file httpd.conf found on your apache folder -> conf
Include conf/extra/httpd-vhosts.conf
Edit httpd-vhosts.conf found on your apache folder -> conf -> extra
httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "your-htdocs-path/legendary-games-folder"
ServerName legendary-games.localhost
</VirtualHost>
Then, restart apache.

Related

Laravel Access forbidden on localhost xampp

I just got stuck in the very begining. I have installed laravel and when i run php artisan serv command then this(Laravel development server started on http://localhost:8000/) line appears but when i access it through browser(http://localhost:8000/) then the following error gets displayed.
Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server.
If you think this is a server error, please contact the webmaster.
Error 403
localhost
Apache/2.4.18 (Win32) OpenSSL/1.0.2e PHP/7.0.2
Please help me out. Any help would be greatly appreciated. I am beginner in laravel.
Follow the steps below to create a virtual host:
Change to your XAMPP installation directory (typically, C:\xampp) and open the " httpd-vhosts.conf " and " httpd-xampp.conf " files in the apache\conf\extra\ subdirectory using your favourite text editor.
Add these lines into both files with the following directives:
<VirtualHost *:80>
DocumentRoot "C:\Users\Shivam\Desktop\laravel_project\blog"
ServerName blog.dev
<Directory "C:\Users\Shivam\Desktop\laravel_project\blog">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
This contains two virtual host configuration blocks:
The first block is the default or fallback virtual host, which is used for all requests that are not matched by subsequent blocks.
The second block sets up a virtual host named wordpress.localhost. The DocumentRoot directive specifies the directory to be used when serving requests for this virtual host (in this case, the WordPress installation directory), while the ServerName directive specifies the custom domain name for the virtual host.
To add more virtual hosts, simply duplicate the second virtual host block and modify the port number, DocumentRoot and ServerName directives as per your requirements. For example, if you want to use SSL with your custom domain name, you can add a new virtual host block for port 443.
If you plan to have a large number of virtual hosts with very similar configuration, consider using wildcard-based subdomains with your virtual hosts.
Restart Apache using the XAMPP control panel for your changes to take effect.
At this point, your virtual host is configured. However, if you try browsing to the wordpress.localhost domain, your browser will show a failure notice, since this domain does not exist in reality. To resolve this, it is necessary to map the custom domain to the local IP address. To do this, open the file C:\windows\system32\drivers\etc\hosts and add the following line to it:
127.0.0.1 blog.dev
This takes care of mapping the wordpress.localhost domain name to the local machine, which always has the IP address 127.0.0.1
It seems to me that you already have Apache running on port 8000.
Try running the serve command like this:
php artisan serve --port=9000
After it's running navigate to http://localhost:9000

Enabling virtual hosts in Apache makes every host forbidden (403)

I am on Windows 8 and just now installed Wamp 2.5 (Apache 2.4.9) at C:/wamp to test my code locally. I have my source code repository at D:/workpace/project1 which I manage using GIT (GIT is one of the reasons I don't want to disturb its location).
After Installing Wamp, I just went on to enable virtual hosts by uncommenting the following line in httpd.conf.
#Include conf/extra/httpd-vhosts.conf
Then I headed to conf/extra/httpd-vhosts.conf created its backup and created the virtual host.
<VirtualHost *:80>
ServerAdmin admin#example.com
DocumentRoot "D:/workspace/project1/"
ServerName project1
ServerAlias p1
ErrorLog "logs/project1(local)-error.log"
CustomLog "logs/project1(local)-access.log" common
<Directory "D:/workspace/project1/">
Require all granted
</Directory>
</VirtualHost>
Also edited the hosts file and added the necessary lines.
127.0.0.1 project1
127.0.0.1 p1
The problem is that I get 403 Forbidden error not just when I access project1/ and p1/, but also when I access localhost/.
When I disable httpd-vhosts.conf in httpd.conf by commenting out,
Include conf/extra/httpd-vhosts.conf
I am able to access localhost/ but as expected, project1/ and p1/ too resolve to localhost/.
Surprisingly, when I re-enable httpd-vhosts.conf in httpd.conf and restore the backup of original(unchanged) httpd-vhosts.conf, I still get 403 (Forbidden) even on localhost/. But again when I disable httpd-vhosts.conf, localhost/ comes to normal.
It is furthermore surprising to note that If I change DocumentRoot to a dummy folder within c:/wamp/www, the story is the same. So this is not just happening when DocumentRoot is outside c:/wamp/www.
I feel that I have something extra to enable because there is no chance I have messed up anything as this is a fresh installation and I have made no changes except the ones above.
What may be the reason Apache is not getting along with virtual hosts?
There are a few things that you have not taken into account.
When you create Virtual Hosts Apache ignores the host defined in httpd.conf so you also need to create a Virtual Host for localhost. This explains why you cannot get to localhost when you have activated Virtual Hosts.
Apache is IPV4 and IPV6 aware, so when you create your domain names in the HOSTS file you need to do so for both the IPV4 and IPV6 stacks. So you would need to have a HOSTS file like this :-
#IPV4 Stack
127.0.0.1 localhost
127.0.0.1 project1
#IPV6 Stack
::1 localhost
::1 project1
The browser makes some arbitrary decision on whether to use the IPV4 stack or the IPV6 stack. Wish I understood why and for what reason it makes this decision better, but basically when you enter a domainname, the browser, or the networking stack, picks IPv4 or IPv6 for your first contact to a domain and then sticks to that decision, but it could use either.
Here is a post that should help you create Virtual Hosts

Apache2 and Vagrant: localhost mapping

I'm using Vagrant 1.6.3 for running Ubuntu 12.04 virtual machine. On this virtual machine I have Apache 2.4.9. For a long time Apache served only one site- there was 000-default.conf file in the /sites-available directory.
Now I want to add another site. I've created 2 files in /sites-available directory:
site1.local.conf
site2.local.conf
and I renamed 000-default.conf to default. Also I added site1.local and site2.local hosts to the ./etc/hosts file on the main machine.
Server names in Apache configs are set to site1.local and site2.local correspondently. And when I input http://site1.local:8080/ and http://site2.local:8080/ in browser everything works.
But I don't understand why http://localhost:8080/ still points to the first site? In what config should I define mapping for "localhost"? After setting up server names in apache configs I thought that http://localhost:8080/ should return "Can not connect to server" error.
Assuming you're using a name-based virtual host, site1 and site2 work because the client passes the target host in the header:
If the client provided a Host: header field the list is searched for a matching vhost and the first hit on a ServerName or ServerAlias is taken and the request is served from that vhost.
With localhost, it doesn't know how to match against the defined virtual host entries:
If no matching vhost could be found the request is served from the first vhost with a matching port number that is on the list for the IP to which the client connected (as already mentioned before).
As far as the last part of your question, you could play around with adding another virtual host entry with localhost as the name definition.

WAMP Server installed on Windows Server 2008 R2 not accessible throughout LAN

I've installed wampserver 2.5 on Windows Server 2008 R2 64 bit and made necessary changes in apache httpd.conf as bellow :
<Directory "cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
Also, inbound rule to allow 80 port is added in windows firewall. Still it is not visible to other on LAN. I'm not regular user of windows server so I googled for quick solution, please your suggestions to this problem is appreciated.
That is not actually a change and only effects the cgi-bin directory and not the DocumentRoot folder.
Locate this section of your httpd.conf file
#
# Controls who can get stuff from this server.
#
# onlineoffline tag - don't remove
Require local
Now lets assume your internal subnet ip address's are 192.168.1.*
You now have to add the instruction to tell Apache that it is allowed to accept connections from ip's in that range, like so
#
# Controls who can get stuff from this server.
#
# onlineoffline tag - don't remove
Require local
Require ip 192.168.1
Note the use of just 3 of the 4 quartiles of the ip address.
This will allow any ip address in the range 192.168.1.0 to 192.168.1.255 i.e. the whole subnet. Change the subnet to match your actual ip address in use at your site.
If you want you can be more specific like so if you actually need to be.
#
# Controls who can get stuff from this server.
#
# onlineoffline tag - don't remove
Require local
Require ip 192.168.1.10 192.168.1.11 192.168.1.12

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.