Solved

Apache PHP Not Loading Outside of Localhost

Posted on 2013-11-19
10
468 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
  • 5
  • 5
10 Comments
 
LVL 42

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 42

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
 

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 42

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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 42

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 42

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

705 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now