LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 10-29-2011, 12:40 PM   #1
OtagoHarbour
Member
 
Registered: Oct 2011
Posts: 269

Rep: Reputation: 3
Web Browser Accessing Files On Different PC on Network


I have installed Ubuntu 11.04 on one PC and Ubuntu 11.10 on another. I have installed LAMP on both. I know the IP address of the 11.10 PC and can ping between both PCs w/o another problems. I would like PHP files on the .04 PC to be able to call PHP files on the .10 PC. However none of the following work. (X is an integer in the IP address.)

Code:
file:////198.162.1.X/var/www/index.php
Code:
/198.162.1.X/var/www/index.php
index.php is in the /var/www directory on the .10 PC but FireFox keeps giving me "File not found".

Any assistance with this would be greatly appreciated.
Peter.
 
Old 10-29-2011, 01:56 PM   #2
KenJackson
Member
 
Registered: Jul 2006
Location: Maryland, USA
Distribution: Fedora, Arch
Posts: 572

Rep: Reputation: 64
I believe the file: protocol only works for files on the local machine. To access files on another machine, you need to install a web server, like apache, lighttpd, thttpd or boa.

The index.php would be put at the path indicated by the DocumentRoot parameter in apache's httpd.conf configuration file, or similar configuration for other servers. Then you would access it like this:
http://198.162.1.X/index.php
or just
http://198.162.1.X/
 
Old 10-29-2011, 03:38 PM   #3
OtagoHarbour
Member
 
Registered: Oct 2011
Posts: 269

Original Poster
Rep: Reputation: 3
Quote:
Originally Posted by KenJackson View Post
I believe the file: protocol only works for files on the local machine. To access files on another machine, you need to install a web server, like apache, lighttpd, thttpd or boa.

The index.php would be put at the path indicated by the DocumentRoot parameter in apache's httpd.conf configuration file, or similar configuration for other servers. Then you would access it like this:
http://198.162.1.X/index.php
or just
http://198.162.1.X/
Thank you for your reply. I have Apache set up on both PCs as it is part of LAMP. I had to set up Apache first. I found that /etc/apache2/httpd.conf is empty but, when I enter

Code:
http://localhost/index.php
on a given PC, it uses index.php which is in the /var/www/ directory of that PC. Sam with any other .php file.

I tried

http://198.162.1.X/index.php
and
http://198.162.1.X/

it tries for several minutes to connect and then times out.

Thanks,
Peter.
 
Old 10-29-2011, 11:00 PM   #4
KenJackson
Member
 
Registered: Jul 2006
Location: Maryland, USA
Distribution: Fedora, Arch
Posts: 572

Rep: Reputation: 64
It's odd that httpd.conf would be empty, though maybe there are enough defaults for it to work.

I would first make sure that iptables is not blocking incoming requests. This command will flush all the input rules (until you reboot or reload the rules):
Code:
sudo iptables -F INPUT
You can verify the server is listening with this command, which should give a response something like this.
Code:
netstat -l | grep http
tcp      0     0 *:http            *:*               LISTEN
Also be sure to look for clues in /var/log/httpd/error_log.
 
Old 10-29-2011, 11:14 PM   #5
OtagoHarbour
Member
 
Registered: Oct 2011
Posts: 269

Original Poster
Rep: Reputation: 3
Quote:
Originally Posted by KenJackson View Post
It's odd that httpd.conf would be empty, though maybe there are enough defaults for it to work.

I would first make sure that iptables is not blocking incoming requests. This command will flush all the input rules (until you reboot or reload the rules):
Code:
sudo iptables -F INPUT
You can verify the server is listening with this command, which should give a response something like this.
Code:
netstat -l | grep http
tcp      0     0 *:http            *:*               LISTEN
Also be sure to look for clues in /var/log/httpd/error_log.
Hi Ken,

Thanks again for your reply. I followed that procedure but
Code:
netstat -l | grep http
did not return anything.
Code:
ls /var/log/httpd/error_log
returned
Quote:
ls: cannot access /var/log/httpd/error_log: No such file or directory
I found /var/log/cups/error_log but it was empty.

Thanks,
Peter.
 
Old 10-29-2011, 11:38 PM   #6
KenJackson
Member
 
Registered: Jul 2006
Location: Maryland, USA
Distribution: Fedora, Arch
Posts: 572

Rep: Reputation: 64
If "netstat -l | grep http" didn't return anything on the server, apache probably isn't running. I'm guessing it looked for httpd.conf and gave up. Though that doesn't explain how it worked with localhost.

Maybe Ubuntu puts the httpd log in /var/log. Look through /var/log for a log, maybe this:
Code:
sudo find /var/log -name '*http*'
Or maybe this (press capital G to zip to the end, q to quit)
Code:
sudo less /var/log/messages
I'm not sure what the command is on Ubuntu, but you can try to manually start apache to see what error messags you get. Probably this:
Code:
sudo /etc/init.d/httpd start
Fedora had a default httpd.conf file that I just had to modify, but on Ubuntu if it's empty there is probably an example file you could copy, edit and use. You could look for it with find:
Code:
find /usr/share -name '*httpd.conf*'
find /etc -name '*httpd.conf*'
 
Old 10-30-2011, 03:40 PM   #7
OtagoHarbour
Member
 
Registered: Oct 2011
Posts: 269

Original Poster
Rep: Reputation: 3
Quote:
Originally Posted by KenJackson View Post
If "netstat -l | grep http" didn't return anything on the server, apache probably isn't running. I'm guessing it looked for httpd.conf and gave up. Though that doesn't explain how it worked with localhost.

Maybe Ubuntu puts the httpd log in /var/log. Look through /var/log for a log, maybe this:
Code:
sudo find /var/log -name '*http*'
Or maybe this (press capital G to zip to the end, q to quit)
Code:
sudo less /var/log/messages
I'm not sure what the command is on Ubuntu, but you can try to manually start apache to see what error messags you get. Probably this:
Code:
sudo /etc/init.d/httpd start
Fedora had a default httpd.conf file that I just had to modify, but on Ubuntu if it's empty there is probably an example file you could copy, edit and use. You could look for it with find:
Code:
find /usr/share -name '*httpd.conf*'
find /etc -name '*httpd.conf*'
It looks like it is a format issue because when I went onto the 11.04 PC and typed

Code:
 
var/www/index.html
in the URL box then
Code:
 
file:///var/www/index.html
appeared in the URL box and I saw the web page just fine. I noticed that the IP address for the 11.04 PC was 192.168.1.7 so I tried typing
Code:
 
192.168.1.7/var/www/index.html
in the URL box. This resulted in the message
Quote:
Not Found
The requested URL /var/www/index.html was not found on this server
Thanks,
Peter.
 
Old 10-30-2011, 04:57 PM   #8
KenJackson
Member
 
Registered: Jul 2006
Location: Maryland, USA
Distribution: Fedora, Arch
Posts: 572

Rep: Reputation: 64
The "file://..." URL is showing you the file on the local machine. You don't need apache to see that. The browser reads it directly from disk.

But when you specify the IP address, the browser sends an HTTP request to fetch it. If DocumentRoot is configured as /var/www, then the URL should be: http://192.168.1.7/index.html or just: http://192.168.1.7/

Did you try to start or restart apache? I suspect it's not running.
 
Old 10-30-2011, 05:11 PM   #9
OtagoHarbour
Member
 
Registered: Oct 2011
Posts: 269

Original Poster
Rep: Reputation: 3
I think I figured it out, mate. I just had to leave out the var/www/ part. So

Code:
192.168.1.7/index.php
and I'm off to the races. I noticed that it's case sensitive as well so

Code:
192.168.1.7/Index.php
doesn't work.

Thanks for your help,
Peter.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Network provider blocking Linux PC's from accessing web Durham Linux - Networking 6 02-21-2011 07:13 PM
Need help with accessing Web site on same network using domain name? Woogieman Linux - Networking 8 03-31-2010 07:21 AM
Apache - stop files from being accessible from web browser jlarsen Linux - Software 9 01-20-2009 10:14 PM
accessing CUPS thru web browser slack66 Linux - Newbie 3 10-23-2007 06:51 AM
Accessing novel Network files saurya_s Linux - Software 3 12-28-2004 06:01 PM


All times are GMT -5. The time now is 11:03 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration