Set up xampp server on office lan - xampp

Im looking to set up a server using xampp within a small office. I will ofcourse secure xampp but in order to make my webapp available to the other 4 PCs on the network do i just create a virtual host? Is there a way to ensure that access to the webapp is only available on the lan?
The current setup includes 4 pcs sharing an internet connection via a router. How can i set this up as a lan which i can provide access to my webapp?

Use an .htaccess file or set up permissions in the VirtualHost tags in httpd.conf. All you have to do is put this in a file named .htaccess inside of the folder holding your webpages:
order deny,allow
deny from all
allow from <ip you want>
allow from <ip you want>
allow from <ip you want>
etc...

Perhaps you can try.
open and make sure C:/xampp/apache/conf/httpd.conf
DocumentRoot “C:/xampp/htdocs”
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Allow from all
and open C:/xampp/apache/conf/extra/httpd-vhost.conf add ..
NameVirtualHost name_site:80
<VirtualHost name_site:80>
DocumentRoot C:/xampp/htdocs/folder_site/
ServerAdmin root#gmail.com
ServerName xxx.xxx.xxx.xxx
</VirtualHost>
note: xxx.xxx.xxx.xxx is xampp computer ip.
This work on win 7.
If still dosn't work. Try to disable youe windows firewall.

Related

publish xampp publically from home laptop

I'm trying to publish a locally installed WordPress website - publically.
Had to reformat my laptop, so now running Windows 10 from my laptop at home.
I can already RDP to it from e.g. work PC, externally, etc.
I used to have Windows 8, WAMP installed and used to publish websites to my domain - www.site01.co.uk
site01.co.uk has been pointing to my fixed IP since I had Windows 8 and still is pointing. The fixed IP address hasn't changed.
I now opened up XAMPP httpd.conf and placed below "code" at the bottom:
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs\wp"
servername http://www.site01.co.uk
<Directory "C:\xampp\htdocs\wp">
Allow from all
Require all granted
Options Indexes
</Directory>
</VirtualHost>
This didn't work .
WordPress is installed in htdocs\wp folder.
You have a couple of problems with your Virtual Hosts definition. Virtual Hosts is definitely the way to go though.
When you create a Virtual Host Apache ignores the default definition of localhost in your httpd.conf file so its always a good idea to include a VH definition for that as the first VH defined, with access limited to Require local this helps stop drive-by ip address access attempts as the Require local will return an Access denied if you/they just use your WAN ip to try and see whats on your web server.
This should go in the \xampp\apache\conf\extra\httpd-vhosts.conf file. Remove all the example stuff from that file when you add this definition.
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
<Directory "C:\xampp\htdocs">
AllowOverride All
Options Indexes FollowSymLinks
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs\wp"
ServerName site01.co.uk
ServerAlias www.site01.co.uk
<Directory "C:\xampp\htdocs\wp">
AllowOverride All
Options Indexes FollowSymLinks
Require all granted
</Directory>
</VirtualHost>
Apache 2.4 uses the Require parameter and not the Allow/Deny which was Apache 2.2 syntax.
You now edit the httpd.conf file and find the
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
and remove the # comment like so
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Then make sure that the Port Forwarding on your router is forwarding port 80 to the correct ip address for your PC.

VirtualBox Shared Folder Not Accessible By Apache2

I know there are a lot of posts on this issue but none of them address the issue I'm having. I am trying to set up a virtual machine following a tutorial on Lynda.com.
Host is a Surface Pro 2 running Windows 10, guest is Virtual Box 5.0.4 with Ubuntu 14.04.3 LTS. People have had a lot of issues with VirtualBox on Windows 10 but mine installed just fine, I have made it all the way to installing Apache, MySQL etc and I'm able to access the Apache2 server status page on my local browser. I don't seem to be having any port issues and I've followed the tutorial's instructions which were step by step.
The issue I'm having is that I can't access the shared folder. I'm ready to configure PHP and I can't access a file placed in the shared folder, even though I've followed all the directions exactly. The shared folder shows up in the VM manager console with the correct path, but when I place a file in the shared folder and try to hit it through the browser on the host machine I get a 404 error. I've gone over the steps to configure the apache server several times, and it looks like I have everything correct:
**blakers**#sandbox:~$ cd /media/**sf_vbsandbox**
blakers#sandbox:/media/sf_vbsandbox$ id
uid=1000(blakers) gid=1000(blakers) groups=1000(blakers),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin), 109(sambashare),**999(vboxsf)**
blakers#sandbox:/media/sf_vbsandbox$ **getent group vboxsf
vboxsf:x:999:blakers,www-data**
This is from sites-available/vboxsf.conf:
<VirtualHost *:80 *:8282>
ServerName sandbox
ServerAlias *.dev
LogLevel info
ErrorLog ${APACHE_LOG_DIR}/dev-error.log
CustomLog ${APACHE_LOG_DIR}/dev-access.log combined
RewriteEngine On
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /media/>
Order allow,deny
Allow from all
Require all granted
<Location /server-status>
SetHandler server-status
Order allow,deny
Allow from all
Require all granted
</Location>
UseCanonicalName Off
VirtualDocumentRoot /media/sf_%1
</VirtualHost>
Any help would be awesome!!
hi the problem is in this line :
VirtualDocumentRoot /media/sf_%1 , change this folder to be named like the folder that you are sharing. if its called "vbsandbox" then sf_vbsandbox.
you can confirm by:
ls -la /media/
then the folder name will be there.
you will have to restart apache at the end
sudo service apache2 restart

Xampp virtual host - access denied

I'm running a XAMPP server on my laptop and I'm trying to setup a virtual host.
My hosts-file looks like this:
127.0.0.1 localhost
127.0.0.1 localhost.com
127.0.0.1 ehc.local
127.0.0.1 bal.local
The httpd-vhosts.conf file looks like this:
NameVirtualHost *:80
<VirtualHost ehc.local:80>
DocumentRoot "C:/wamp/EHC/src/main/php/www"
ServerName ehc.local
SetEnv APPLICATION_ENV "local"
<Directory "C:/wamp/EHC/src/main/php/www">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog "logs/ehc.dev-error_log"
CustomLog "logs/ehc.dev-access_log" common
</VirtualHost>
When I browse to 'ehc.local', I only get the default 403-error page.
How can I fix this?
Thanks!
This is for osx but must be the same (or similar) in windows:
Because Apache runs as the ‘nobody’ user by default, it may not have adequate permission to browse your [OSX/Win] user directory or some of its subdirectories, in which case you’ll see a 403 ‘access forbidden’ error when you try and view your development site. Similarly, you may find that although you can view your dev site, PHP throws errors when you attempt to write files or make directories on the filesystem.
To fix this you can configure Apache to run as your [OSX/Win] user. Open httpd.conf and look for the following lines:
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User nobody
Group nogroup
Change User to your [OSX/Win] username, and save the file:
User yourusername
Restart Apache and you should now be able to navigate your site without any issues, including manipulating files and folders using PHP.
Source
I Hope it will be helpful, Greetings!
Changing user didn't work.
For me it was this answer that did the trick:
Adding VirtualHost fails: Access Forbidden Error 403 (XAMPP) (Windows 7)
Just add Require all granted to your <Directory> setup and it should work as expected.
you should try this:
-> go to XAMPP folder,
-> open apache-conf-extra folder
-> open httpd-xampp.conf with the text-editor of your choice
Scroll all the way down until you find Deny from all and change that too Allow from all

Access virtual host from another machine over LAN

I am using Windows 7 with Wamp 2.2 server.
I have setup 2 virtual hosts: www.project1.com and www.project2.com.
I have modified the "hosts", the httpd.conf, and the httpd-vhosts.conf files, to the changes I mentioned below.
Using my browser, when I type www.project1.com or www.project2.com, I successfully get my web pages opened on the laptop that has the server installed on.
Changes in the "hosts file": I've appended the followings to the end of the file:-
127.0.0.1 localhost
127.0.0.1 www.project2.com
127.0.0.1 www.project1.com
Changes in the httpd.conf file:-
Include conf/extra/httpd-vhosts.conf
Changes in httpd-vhosts file:-
NameVirtualHost *:80
<Directory "D:/websites/">
AllowOverride All
Order Deny,Allow
Allow from all
</Directory>
<VirtualHost 127.0.0.1>
DocumentRoot "D:/websites/wamp/www/"
ServerName localhost
</VirtualHost>
<VirtualHost 127.0.0.1>
DocumentRoot "D:/websites/project1/"
ServerName www.project1.com
</VirtualHost>
<VirtualHost 127.0.0.1>
DocumentRoot "D:/websites/project2/"
ServerName www.project2.com
</VirtualHost>
Now; since I can open these web pages from a browser in PC_1 (the one with the server), how can I access these web pages from a browser in PC_2? (I mean any PC connected to PC_1 via LAN.)
In addition to danp's answer, you can access the virtual host without having to change the client machine's etc/hosts file by assigning a port to the virtual host. This is ideal if you want to access the server with a mobile or tablet device:
Edit server's httpd.conf file at:
\wamp\bin\apache\apache2.2.x\conf\httpd.conf
Search for "Listen" (around line 61). You should see the following that allows for Apache to listen for port 80:
Listen 0.0.0.0:80
Listen [::0]:80
Add the following lines to add listening for port 81 (or any port):
Listen 0.0.0.0:81
Listen [::0]:81
Edit the httpd-vhosts.conf file at:
\wamp\bin\apache\apache2.2.x\conf\extra\httpd-vhosts.conf
Change your "Virtual Host" tag to port 81:
<VirtualHost *:81>
DocumentRoot "D:/websites/project1/"
ServerName www.project1.com
</VirtualHost>
Restart Apache server.
On the client machine/tablet/mobile, on the web browser, enter the server's IP address (192.168.0.10, or whatever IP) followed by the port number in the following format:
http://192.168.0.10:81
In your virtualhost directive, change 127.0.0.1 to *:80 and as Gabriel mentioned, add an entry to the hosts file in the other machine, adding your domain to be associated with the IP of your server.
When you put an explicit IP into the directive, apache will only listen on that IP - but the wildcard will tell it bind to all IPs available to it.
<VirtualHost *:80>
DocumentRoot "D:/websites/project1/"
ServerName www.project1.com
</VirtualHost>
If your server is on 192.168.1.70 for example, then in the other machines on your lan, the hosts entry will look like:
192.168.1.70 www.project1.com
Restart apache and it should work fine.
As a note, when you are using virtualhosts, apache will use the first definition as a default for when it can't make a match between the domain passed in the HTTP request header and the sites setup in the config, which is why your default page was appearing.
You told apache to bind to all IPs with the NameVirtualHost *:80 directive, but then didn't setup a site for that external IP. Hope that helps!
There are two computer in local network.
A computer(192.168.1.70) Setup(D:\wamp\bin\apache\Apache2.2.11\conf\extra\httpd-vhosts.conf):
<VirtualHost *:80>
DocumentRoot "D:/websites/project1/"
ServerName www.project1.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:/websites/project2/"
ServerName www.project2.com
</VirtualHost>
B computer Setup(c:/windows/system32/drives/etc/hosts):
192.168.1.70 www.project1.com
192.168.1.70 www.project2.com
B access A,My project is working.
A couple of updated points to consider for the selected answer:
NameVirtualHost is no longer used after Apache version
2.3.11 and can be omitted.
In 2.3.11 and later, any time an IP address and port combination is
used in multiple virtual hosts, name-based virtual hosting is
automatically enabled for that address.
Because we are talking about hosting a website over LAN, let's set a
requirement* to only accept connections from IP addresses on your
local network. For example, on a common Linksys router, the default
IP assigned to each device on the network is between 192.168.1.100
to 192.168.1.255. You can allow connection from all devices on the
LAN with an IP address 192.168.1.XXX by using Require ip 192.168.1
(notice the final octet is left off the IP to allow the entire
range).
This allows you to configure access per project so that one may be
available over LAN and another is only available locally.
# This will allow all LAN connections to www.project1.com
<VirtualHost *:80>
DocumentRoot "D:/websites/project1/"
<Directory "D:/websites/project1/">
Require local
Require ip 192.168.1
</Directory>
ServerName www.project1.com
</VirtualHost>
# This will allow only the machine hosting the website to access www.project2.com
<VirtualHost *:80>
DocumentRoot "D:/websites/project2/"
<Directory "D:/websites/project2/">
Require local
</Directory>
ServerName www.project2.com
</VirtualHost>
While your site will not be served publicly without the router forwarding traffic on port 80 to your host, I believe this is considered best practice. It is especially necessary if you need to control which projects are available to devices on the LAN.
Reminder: Your host machine should be configured to use a static IP address
instead of being assigned one by your router's DHCP. Since we are
editing the hosts file of other devices to point to the server's IP,
we don't want it to change.
* I'm including this because it is common to have access restrictions on a local development server and you will need to specifically make it available to your local network.
You need to change the hosts file on the machine you're trying to view the page from.
So you need to add them to the hosts file on the other lan machine.
if you are not able to access your virtual host server in your local area network then check you have configured your firewall to allow httpd.exe file (lying in folder C:\wamp64\bin\apache\apache2.4.51\bin) to allow both incoming and outgoing connections

Cannot access XAMPP (1.7.3) from my local network

I am running XAMPP 1.7.3 on windows 7. My problem is that when I try to access my server (localhost) from another computer, the server does not respond. For example, [on my computer] when I type in 'http://localhost', my pages come up. However, when I try accessing 'http://192.168.0.102' from my computer, nothing happens. When I type in my external IP, nothing shows up, but when add HTTPS to the external IP, my Linksys WRT54GS config page shows up, asking for a password. I have already tried port forwarding and a local "static IP", and no luck, other than my local IP never changing. Can anyone help me?
Here's how I have my XAMPP installation configured. Maybe it will work for you.
Open C:\xampp\apache\conf\extra\httpd-vhosts.conf
Add a VirtualHost block for each site you are running:
Apache config
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot C:/path/to/website/files
ServerName exampledomain.dev
<Directory "C:/path/to/website/files">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Add a line to your hosts
127.0.0.1 exampledomain.dev
On the connecting computer's host file:
192.168.0.102 exampledomain.dev
You can easily access your hosts file by using ctrl+r and running
notepad %SYSTEMROOT%\system32\drivers\etc\hosts

Resources