Access XAMPP from my local network

Ralph
Ralph used Ask the Experts™
on
There was a quite similar Q here years ago, but it's not getting me to where I need to go.

I have XAMPP 5.6.14 with Control Panel v3.2.1 on Windows 7 Enterprise here at work, and I have a demo to do for my boss on Friday.
I need to get this working on his desktop.  The network is open w/in our domain.

I have a fair amount of PHP and javascript in DIRs that I need to have accessed, but with the methods I've tried all I get is the HTML.
(Apparently.)

-- -- --

I modified apache config httpd-xampp.conf file's location match two ways, same result.
A)  I commented it all out, and
B) I commented out "Require local" and inserted (above "ErrorDocument 403 ..."),  "Allow from XX.YYY" where those are my higher bytes.

#
# New XAMPP security concept
#
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
#        Require local
         Allow from XX.YYY
	ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var

</LocationMatch>

Open in new window


I get the raw index.html to show, but no jQuery works to populate the DIVs.

I have the standard XAMPP install w/in C:/ DIR.

Thanks!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
Since C:/DIR is not under the 'web root', you need to create an 'alias' to display it's contents.  Here's one I use.  You can insert this into your main 'conf' file or 'include' it from a separate file.
Alias /Pinc/ "c:/Pinc/" 

<Directory "c:/Pinc/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
        Order allow,deny
    Allow from all
</Directory>

Open in new window

Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
And you should probably restore your original version of httpd-xampp.conf because your changes have nothing to do with it.

Author

Commented:
Hi Dave,

Sorry, I don't quite follow  your suggestion.  Consider me not quite savvy enough please.

I've been accessing everything fine via
http://localhost/Cell_Modems/public_html, but when using my IP vs "localhost" I'm just getting the html.
http://10.139.164.191/Cell_Modems/public_html/
XAMPP has been in C:/ all along.

Your Pinc = ?
Put this alias definition where?     httpd-xampp.conf, or httpd.conf?

Thank you.
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Fixer of Problems
Most Valuable Expert 2014
Commented:
Never mind, I think I misunderstood what you were doing.  Forget the Alias.  And Always use the IP address for anything you want to be accessed remotely.  'localhost' has a number of limitations.

http://10.139.164.191/Cell_Modems/public_html/ should be showing the same thing as http://localhost/Cell_Modems/public_html .  ??

Author

Commented:
I made a simple PHP file containing:
<?php
echo "HELLO" ;
?>
<script type="text/javascript">
alert("Howdy!");
</script>

Open in new window

and if I access it via http://10.139.164.191/Cell_Modems/PHP/
it works!

But my index.html is bare bones.
<!DOCTYPE html>

<html>
  <head>
    <title>index page</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css" href="http://localhost/Cell_Modems/CSS/PopulateTables.css">
    
    <script type="text/javascript" src="http://localhost/Cell_Modems/javascripts/script.js"></script>
    <script type="text/javascript" src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
    
    <script type="text/javascript">
      $(document).ready(Main);
    </script>
    
    
  </head>
  <body>
    
    <div class="header-container">
      <div class="header"> 
        <div ID="AjaxSearches"></div>
        <div ID="AjaxResults"></div> 
        <a href="../PHP/parse_form.php">Test Me</a><br>
      </div>
    </div>
    
    <div class="content" >
      
      <div class="left" ID="left_margin"></div>
      <div class="center" ID="center_body"></div>
      <div class="right" ID="right_margin"></div>
      
    </div>  <!-- CONTENT -->
        
  </body>
</html>

Open in new window


Below C:\XAMPP\htdocs\Cell_Modems I have the following DIRs.
CSS, images, javascripts, PHP, public_html, and a couple others.

Looking at XAMPP's Apache access log it looks like it's accessing every page it needs, but I still get a bare bones page.
The error.log file has nothing timely/relevant in it.

Again, Thanks.
access.log
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
Get rid of 'http://localhost/' in those links.  When you access the site with an IP address, they will Not work.  The remote computer can not access 'localhost' on the web server.  'localhost' only works on the computer you're on.

Author

Commented:
Ahh, so in all my headers your saying.
Makes sense!

What's the best way then to keep it portable, since it won't ultimately be on my box?
A global change (via netbeans)?

Thanks!!!
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
I would make them 'relative' links like below.  They will work with whatever the address of the main page is.
<link rel="stylesheet" type="text/css" href="Cell_Modems/CSS/PopulateTables.css">
    
<script type="text/javascript" src="Cell_Modems/javascripts/script.js"></script>

Open in new window

Author

Commented:
Hi Dave,

The relative links like you suggested should work fine, but...
I'm using a lot of JQuery and it doesn't like the options I've tried.
e.g.: Trying this approach,
function Main() 
{
  
  $( "#left_margin ").load("Cell_Modems/public_html/MarginLeft/left_margin.html") ;
  $( "#center_body" ).load("Cell_Modems/public_html/view_forms/modem_config_and_activity_table.html") ;
  $( "#right_margin ").load("Cell_Modems/public_html/MarginRight/right_margin.html") ;
  
  $.ajaxPrefilter(function( options, originalOptions, jqXHR ) {
    options.async = true ;
});
}

Open in new window

Gives me (grabbing the middle browser log message):
Failed to load resource: the server responded with a status of 404 (Not Found) (10:10:12:073 | error, network)
  at http://localhost/Cell_Modems/public_html/Cell_Modems/public_html/view_forms/modem_config_and_activity_table.html

If I try substituting http://myIP/Cell_Modems/public_html/view_forms/modem_config_and_activity_table.html
I get a notice that it assumes I'm crossing domains, (at least that's how I interpret it.  It's definitely over my head at the moment.)
XMLHttpRequest cannot load http://10.139.164.191/Cell_Modems/public_html/MarginLeft/left_margin.html. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. (10:13:37:709 | error, javascript)
  at public_html/index.html

Open in new window


So for the immediate time being I'm back to http://localhost..., but I've got to get this solved.

Do you suggest I reframe my question and resubmit it to the masses here?

Ralph
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
You can Not solve it using 'localhost'.  A remote computer can Not access your computer at 'localhost' because their 'localhost' will be their computer.  You have to get rid of 'localhost'.  This is a well known problem.  Do Not use 'localhost' in any site that needs to be accessed from another computer.

Author

Commented:
I KNOW!
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
Then why are you saying "I'm back to http://localhost..." ???

Author

Commented:
jQuery loading of pages fails when I use relative links, like you suggested,
AND when I use http://10.139.164.191/Cell_Modems/public_html/DIR/file.
See my 10:20 AM reply today.

Really frustrating.
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
Your error means that your jQuery is not on the same IP address as your page.  How are you getting to the main page?  It needs to be at  http://10.139.164.191/ .

Author

Commented:
Well, the ONE thing is working right today!

I have the hard-coded full IP path everywhere now, and it's working.
Why I thought it wasn't before is because even though I now do not have "localhost" anywhere in the project, Chrome puts it there when I 'run' in netbeans.  Once I replace that w/ the IP all works fine.
jQuery and AJAX.

So I'm good Dave.  MANY thanks!

Now if only I can get one of my AJAX calls to not put the cart before the horse, I'd be totally pleased.
http://www.experts-exchange.com/questions/28929029/AJAX-function-is-succeeding-but-not-posting-correctly.html

Again, thank you,
Ralph
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
You're welcome, glad to help.
Chrome puts it there when I 'run' in netbeans
Other IDE's have that same problem.  I don't use any of them.  Just a code editor and a real web server... or two or 12.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial