[SOLVED] Web Browser Accessing Files On Different PC on Network
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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/
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.
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.
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
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:
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:
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.