Solved

Apache PHP Not Loading Outside of Localhost

Posted on 2013-11-19
10
490 Views
Last Modified: 2013-11-25
I have an apache 2.2 webserver running on a windows machine. The php files load correctly from localhost without any issue. When trying to load the same site on a machine on the LAN it does not load. Non PHP files load without any issues.

Any ideas?

Thanks
0
Comment
Question by:fred2k3
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 39659742
How are you loading the pages (are you calling them with a URL - if so, what is it). Is your DNS setup correctly (HOSTS file on Windows)

You can open any HTML file in any browser and it will work, but that doesn't mean the server is 'serving' it. PHP has to be served by a server - you can't just open your files and expect them to work.
0
 

Author Comment

by:fred2k3
ID: 39659769
We are loading the pages using a web browser by referring to the machines local IP address. E.g. http://10.0.0.10/index.php
0
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 39659816
OK. You say it doesn't load - what do you mean? Does it time out / do you get an error etc.

Do you have a firewall in place / if so, have you opened up port 80?

If you call http://10.0.0.10/index.html you say it works fine, but not if you change the filename to index.php
0
Save the day with this special offer from ATEN!

Save 30% on the CV211 using promo code EXPERTS30 now through April 30th. The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 

Author Comment

by:fred2k3
ID: 39660013
Thanks Chris,

Yes, the page (on IE) times out with "This page can't be displayed".

There are no firewalls on the machine running apache.

Calling index.html works fine without any issue.
0
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 39660049
Hmmmm. All the obvious stuff seems to be checked. If you simply rename your index.html file to index.php does it still hang. (i.e it hangs on a php file even if they is no PHP in it?)

Try a simple PHP file containing something very basic:

<?php echo "PHP File"; ?>

What happens if you call http://10.0.0.10/index.php on the server itself.
0
 

Author Comment

by:fred2k3
ID: 39660083
Unfortunately it still doesnt work when using a basic file.

When calling http://10.0.0.10/index.php on the server itself, it redirects to http://127.0.0.01/index.php and loads?
0
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 39660104
Right - it shouldn't redirect - it should just load the page from 10.0.0.10

Maybe that's where the problem lies. If you call 10.0.0.10 on a remote computer and it tries to redirect to 127.0.0.1 then it'll never get served. Now just to figure out what's causing the redirect.

Do you have any .htaccess files in your folder? If you do, remove them.

Maybe time to have a look at your http.conf file - particularly the virtual hosts section as well, to make that's configured correctly.
0
 

Author Comment

by:fred2k3
ID: 39660194
Thanks, yes we do have htaccess files in your folder - they are there by default for the Magento installation. Removing them didnt resolve the issue.

I couldnt see a section about virtual hosts in the http.conf, only comments about it. We havent altered the file, so it out of the box so to speak. Any section i should look at?
0
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 500 total points
ID: 39660250
Ahhhh right!

Magento is a complex system and is configured to run on a specific server. The base_url of your installation is stored in the database (in the core_config_data table). I'm guessing you have yours set up to be 127.0.0.1 and not 10.0.0.10!! If you want to access your Magento app over your network then you can't use 127.0.0.1

As for your virtual hosts, it may be in a different file. Look for a line like this:

Include conf/extra/httpd-vhosts.conf

If it's not commented out (i.e it doesn't start with a semi-colon) then that's the file that contains details of your virtual hosts.

If you want to do simple tests, then you will need to remove all the files related to magento from your folder (including htaccess!!). Once done, put a simple file in there and try and access it.

A better setup wold be to use 'named virtual hosts' - that's more complicated but would allow you to serve several different websites from the same server.
0
 

Author Closing Comment

by:fred2k3
ID: 39676474
Many thanks for your help.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question