LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Web Browser Accessing Files On Different PC on Network (http://www.linuxquestions.org/questions/linux-server-73/web-browser-accessing-files-on-different-pc-on-network-910818/)

OtagoHarbour 10-29-2011 12:40 PM

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.

KenJackson 10-29-2011 01:56 PM

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/

OtagoHarbour 10-29-2011 03:38 PM

Quote:

Originally Posted by KenJackson (Post 4511377)
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.

KenJackson 10-29-2011 11:00 PM

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.

OtagoHarbour 10-29-2011 11:14 PM

Quote:

Originally Posted by KenJackson (Post 4511580)
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.

KenJackson 10-29-2011 11:38 PM

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*'


OtagoHarbour 10-30-2011 03:40 PM

Quote:

Originally Posted by KenJackson (Post 4511589)
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.

KenJackson 10-30-2011 04:57 PM

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.

OtagoHarbour 10-30-2011 05:11 PM

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.


All times are GMT -5. The time now is 10:17 PM.