XAMPP 3.2.1 Virtualhost is not working - php

I am using XAMPP 3.2.1 and creating new virtual host in http-vhosts.conf file in Apache the code below
<VirtualHost *:8080>
DocumentRoot "C:/xampp/htdocs/support/srinet"
ServerName supportcenter.sevplcorp.com
Alias /mrpdf "E:/temp"
<Directory "C:/xampp/htdocs/support/srinet">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</Directory>
When I open supportcenter.sevplcorp.com in browser windows it shows like below

You have to edit your host file located at : %WINDIR%\system32\drivers\etc\hosts.
Add a newline 127.0.0.1 supportcenter.sevplcorp.com

Probably you haven't altered your hosts file to map the host domain to server's IP address. Assuming that you're running XAMPP on your own PC, open your editor as Administrator (notepad is sufficient), then open this file:
c:\Windows\System32\Drivers\etc\hosts
...and add this line to the bottom:
127.0.0.1 supportcenter.sevplcorp.com
Save the file and, after that, visiting supportcenter.sevplcorp.com should work. Basically, by altering the hosts file you're telling the browser (and everything else that might want to access supportcenter.sevplcorp.com) that it's actually your PC.

Related

Error when setting up VirtualHost in Wamp - The ServerName has syntax error in file httpd-vhosts.conf

I am trying to move a live wordpress website to a local site on my computer so that I can make changes and try things out without messing up the live site. I am using WAMP on a Win7 PC.
I went through all the steps...installed WAMP and downloaded my Wordpress files and my database file, put the wordpress files in the D:/wamp/www/site-name folder, I created a new database in phpadmin with the same name as my downloaded datebase, and imported my database, then I updated the URLS inside the database from http://www.site-name.org to localhost/site-name using the sql queries, then I updated the database name, username and password in the wp-config.pho file to reflect what is being used on the localhost versus the live site, then because I was using apache 2.4.x, I went to create a virtual host for my wordpress site because the localhost option was suppressed in the httpd.config file...and from what I gathered, the newer version is made to use virtual host, so I was attempting to do that, instead of unsupressing the localhost option.
So, I went to the the c/windows.system32/drivers/etc/hosts file and added the following
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
::1 localhost
# site-name name resolution
127.0.0.1 site_name #local version of website
::1 site_name
( note I had already checked the httpd.config file, and this line was already active:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Then, I went to the httpd-vhost.conf file and added in my new virtual host:
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot D:/wamp/www
<Directory "D:/wamp/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
#
#
<VirtualHost *:80>
ServerName site_name
ServerAlias site_name
DocumentRoot D:/wamp/www/site_name
<Directory "D:/wamp/www/site_name">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
However, after saving that, and restarting WAMP services, I continue to get an error for Site_name under Virtual host, that says: The ServerName site_name has syntax error in file D:/wamp/bin/apache/apache2.4.23/conf/extra/httpd-vhosts.conf.
I have looked over the above code in the httpd-vhosts.conf for the site_name server, but can't find any syntax errors. The localhost virtual host works, and from what I can tell, the syntax for the site_name server is the same.
I tried running httpd.exe in the apache folder to see if it would give me more details on the syntax error, but I can't get it to run when double clicking on it, and I wasn't sure how to run it from the cmd prompt...I tried, but I kept getting some kind of socket error.
Thank you for the help.
Can someone please help be figure out what might be happening. What am I missing something?
You can't use underscore in host name.

WAMP Gives the Forbidden Error with Static IP Address [duplicate]

I know this question has been asked a lot of times
I followed Most of the answers in the internet But I still get the same Message
403 Forbidden
You don't have permission to access / on this server.
It is weird that when I access using the same PC to localhost:1234 it runs normally but if I access using my IP address 192.168.0.188:1234
Also which is really weird is that I tried to install WAMP on other PC and without any configuration I could access to that PC.
So I thought it's because McAfee and Firewall so I open port on Widows and McAfee and nothing changed also I turned off Firewall and still nothing change.
Then for no reason I opened port through the Router “port forwarding” and still nothing changed.
I don't think that it's because my configuration in WAMP since I am still able to get this 403 Forbidden Message and also by using other PC without any configuration I could access it.
Both PCs are setup like this:
Windows 8 Pro
WAMP Wampserver: 2.4
Apache Version: 2.4.4
PHP Version: 5.4.12
MySQL Version: 5.6.12
The accessible PC uses Microsoft Security Essentials.
The inaccessible PC uses McAfee Internet Security.
I tried to turn off WAMP and start IIS For Microsoft Server (I works perfectly From any PC) but WAMP is still not not working
I followed these tutorial:
How to Access WAMP Server in LAN or WAN
Install & Setup Virtual Host Guide for WAMP
Install & Setup LAN & Worldwide Access Guide for WAMP
And the Stack Overflow answers here:
Cannot access wamp server on local network
WAMP 403 Forbidden message on Windows 7
If you are using WAMPServer 3 See bottom of answer
For WAMPServer versions <= 2.5
By default Wampserver comes configured as securely as it can, so Apache is set to only allow access from the machine running wamp. Afterall it is supposed to be a development server and not a live server.
Also there was a little error released with WAMPServer 2.4 where it used the old Apache 2.2 syntax instead of the new Apache 2.4 syntax for access rights.
You need to change the security setting on Apache to allow access from anywhere else, so edit your httpd.conf file.
Change this section from :
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
Allow from localhost
To :
# onlineoffline tag - don't remove
Require local
Require ip 192.168.0
The Require local allows access from these ip's 127.0.0.1 & localhost & ::1.
The statement Require ip 192.168.0 will allow you to access the Apache server from any ip on your internal network. Also it will allow access using the server mechines actual ip address from the server machine, as you are trying to do.
WAMPServer 3 has a different method
In version 3 and > of WAMPServer there is a Virtual Hosts pre defined for localhost so you have to make the access privilage amendements in the Virtual Host definition config file
First dont amend the httpd.conf file at all, leave it as you found it.
Using the menus, edit the httpd-vhosts.conf file.
It should look like this :
<VirtualHost *:80>
ServerName localhost
DocumentRoot D:/wamp/www
<Directory "D:/wamp/www/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
Amend it to
<VirtualHost *:80>
ServerName localhost
DocumentRoot D:/wamp/www
<Directory "D:/wamp/www/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Hopefully you will have created a Virtual Host for your project and not be using the wamp\www folder for your site. In that case leave the localhost definition alone and make the change only to your Virtual Host.
Dont forget to restart Apache after making this change
For Apache 2.4.9
in addition, look at the httpd-vhosts.conf file in C:\wamp\bin\apache\apache2.4.9\conf\extra
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot C:/wamp/www
<Directory "C:/wamp/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require local
</Directory>
</VirtualHost>
Change to:
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot C:/wamp/www
<Directory "C:/wamp/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
changing from "Require local" to "Require all granted" solved the error 403 in my local network
I got this answer from here. and its works for me
Require local
Change to
Require all granted
Order Deny,Allow
Allow from all
To expand on RiggsFolly’s answer—or for anyone who is facing the same issue but is using Apache 2.2 or below—this format should work well:
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 ::1
Allow from localhost
Allow from 192.168
Allow from 10
Satisfy Any
For more details on the format changes for Apache 2.4, the official Upgrading to 2.2 from 2.4 page is pretty clear & concise. Key point being:
The old access control idioms should be replaced by the new
authentication mechanisms, although for compatibility with old
configurations, the new module mod_access_compat is provided.
Which means, system admins around the world don’t necessarily have to panic about changing Apache 2.2 configs to be 2.4 compliant just yet.
For those who may be running WAMP 3.1.4 with Apache 2.4.35 on Windows 10 (64-bit)
If you're having issues with external devices connecting to your localhost, and receiving a 403 Forbidden error, it may be an issue with your httpd.conf and the httpd-vhosts.conf files and the "Require local" line they both have within them.
[Before] httpd-vhosts.conf
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local <--- This is the offending line.
</Directory>
</VirtualHost>
[After] httpd-vhosts.conf
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
</Directory>
</VirtualHost>
Additionally, you'll need to update your httpd.conf file as follows:
[Before] httpd.conf
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
# onlineoffline tag - don't remove
Require local #<--- This is the offending line.
</Directory>
[After] httpd.conf
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
# onlineoffline tag - don't remove
# Require local
</Directory>
Make sure to restart your WAMP server via (System tray at bottom-right of screen --> left-click WAMP icon --> "Restart all Services").
Then refresh your machine's browser on localhost to ensure you've still got proper connectivity there, and then refresh your other external devices that you were previously attempting to connect.
Disclaimer: If you're in a corporate setting, this is untested from a security perspective; please ensure you're keenly aware of your local development environment's access protocols before implementing any sweeping changes.

Access virtualhost from another computer

First of all I want to say that I have read other topic where the similar problem arises, but applying solutions, none has operated what I want.
I have in my computer 1 IP: 192.168.1.217 configured a virtualhost.
C:\wamp\bin\apache\Apache2.4.4\conf\extra\httpd-vhosts.conf:
<VirtualHost *: 80>
    ServerAdmin webmaster#sfi.com
    DocumentRoot "c:/wamp/www/sfi"
    <Directory "c:/wamp/www/sfi">
        Options Indexes FollowSymLinks
        AllowOverride All
        Allow from all
    </Directory>
    ServerName sfi
    ErrorLog "logs/sfi-error.log"
    CustomLog "logs/sfi-access.log" common
</VirtualHost>
And I have added the following line:
NameVirtualHost *: 80
In the file C:\wamp\bin\apache\Apache2.4.4\conf\httpd.conf I have modified the following lines:
Include `conf/extra/httpd-vhosts.conf` (remove `#`)
<Directory /> (Grant permissions)
    AllowOverride none
    AllowOverride All
    Order deny, allow
    Allow from all
</Directory>
<Directory "c:/wamp/www"> (Grant permissions)
     Order Deny, Allow
     Deny from all
     Allow from all
</Directory>
Finally, I added to C:\Windows\System32\drivers\etc\hosts
127.0.0.1 sfi
The virtualhost works perfectly on the machine that has installed wamp server.
In the machine I want to access my project, I set to C:\Windows\System32\ drivers\etc\ hosts the following line:
192.168.1.217 sfi
But not load my project directory.
Is there something I've done wrong?
Thanks.
You simply have a firewall issue, completely outside your httpd configuration.

Php website virtual host

I'm new to php, I did installed xampp-win32-1.8.2-2-VC9-installer on my window7 desktop pc. PHP page run from C:\xampp\htdocs but when i create virtual host and tried to access php file in d:\web\ it shows access forbidden.
my host file code
127.0.0.1 localhost1
my httpd-vhost file code
NameVirtualHost *
<VirtualHost *>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost localhost1:80>
DocumentRoot "d:/web/test.php"
ServerName localhost1
<Directory "d:/web/test.php">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I don't know now where i have to change
It's a file permissions derived issue. Try changing NTFS permissions in "C:/xampp/htdocs" to allow read and execute permissions to the user that is running the web server, you should be able to see who that user is in the Apache configuration file, tipically "apache" which is the equivalent to IUSR in IIS.

Hosting multiple local sites with XAMPP

I'm new to using XAMPP so this may be simple to some people.
I have a few php projects that I would like to be able to debug locally and view in the browser (not concurrently, but without having to change config files/copy project folders each time I want to work on a different project).
On IIS, you could set up multiple sites to serve from your machine, and I'm looking for something similar in XAMPP. When using IIS, I added multiple records to the Windows hosts file so I could access the locally hosted sites by typing friendly web-style addresses (like http://myproject1.dev)
Thanks.
Greg, you're almost there--you need (like Moses said) to setup virtual hosts.
So if your Windows hosts file has
127.0.0.1 localhost
127.0.0.1 mysite-dev.com
127.0.0.1 anothersite-dev.com
Your virtual hosts file (httpd-vhosts.conf) might look like:
<VirtualHost *:80>
DocumentRoot C:/xampp/htdocs/
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName mysite-dev.com
DocumentRoot "C:/sites/mysite-dev"
<Directory "C:/sites/mysite-dev">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName anothersite-dev.com
DocumentRoot "C:/sites/anothersite-dev"
<Directory "C:/sites/anothersite-dev">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Don't forget to restart the web server after you make any changes.
I would like to make an additional in terms of up to date information.
XAMMP uses port 80 by default and we are able to publish 1 website. I also use IIS for .Net projects. In this respect, I set the port to XAMMP except the 80 port. So I avoid a conflict.
When we want to publish more than one website, we should do the following operations to httpd.conf (this is the current name).
1. Setting the ports
Find the #Listen expression in the httpd.conf file.
Change Listen 80 to Listen 8000 (or whatever else you want)
Listen 8000
If you need 3 different websites, type the others, including 1 definition on each line, as follows.
Listen 8001
Listen 8002
Listen 8003
2. Define the file paths of sites accessed through ports
Again, find in the httpd.conf file.
Identify the folders of each website as follows.
As you would see, I've created 3 directories called 8000, 8001, 8002 and 8003 under the htdocs directory within the XAMMP directory.
<VirtualHost *:8000>
 DocumentRoot "C:\XAMPP\htdocs\8000"
 ServerName localhost:8000
<\ VirtualHost>
<VirtualHost *:8001>
 DocumentRoot "C:\XAMPP\htdocs\8001"
 ServerName localhost:8001
<\ VirtualHost>
<VirtualHost *:8002>
 DocumentRoot "C:\XAMPP\htdocs\8002"
 ServerName localhost:8002
<\ VirtualHost>
<VirtualHost *:8003>
 DocumentRoot "C:\XAMPP\htdocs\8003"
 ServerName localhost:8003
<\ VirtualHost>
Restart your Apahche server on XAMMP.
You can now view your 3rd site, such as http://localhost:8003 or http://192.168.1.1:8003/.
Hope to be useful.
This question was asked almost ten years ago, and the answers above are a bit dated. Note that XAMPP has a "How-To" for virtual hosts avilable off the dashboard, when you install it.
From the "Welcome to XAMPP for Windows" page (localhost/dashboard, the default when you first load localhost) click on the "HOW-TO" Guides in the top menu bar. From there, look for the link "Configure Virtual Hosts" which will lead you to the localhost page "http://localhost/dashboard/docs/configure-vhosts.html"
In a nutshell, the process involves editing the "httpd-vhosts.conf" file (typically in C:\XAMPP\apache\conf\extra) and replacing the contents of that file with something like this:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/"
ServerName localhost
</VirtualHost>
# vhosts - note sample entry from XAMPP how-to throws an error, so try this:
<VirtualHost *:80>
DocumentRoot "C:/Users/jdoe/Documents/dev.mysite.com/htdocs"
ServerName mysite.local
<Directory "C:/Users/jdoe/Documents/dev.mysite.com/htdocs">
Require all granted
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Additional vhosts (including SSL hosts) can be had by cloning the entry, and modifying DocumentRoot and ServerName directives and port numbers (e.g. 443 for TLS (SSL)). You can find tutorials on the web for creating and signing your own certificate, if you want to go that route.
The final step is to get your Windows machine to point your browser to the Apache host for your virtual domain (e.g. above, http://mysite.local). Using a text editor (Notebook will do) as administrator append the following entry onto your hosts file, which lives here:
C:\Windows\System32\drivers\etc\hosts
Append this entry to the hosts file:
127.0.0.1 mysite.local
IMPORTANT - you must restart your Windows machine or the new host will not respond. Some documentations will tell you just to restart the browser and Apache server, but I've found that's not sufficient.
IME, the hosts system and Apache directives can be particular, so be patient. You may need to rebuild configs, restart Apache, and restart your machine more than once.

Categories