|
You have several computers around the house. They are all connected to a
router one way or another. One or more of them are not running linux. You
want to share the files on the linux machine will all the rest with the
least possible hassle. Here is how to do it.
You can open up ftpd. You can learn SMB, Samba, to share files. Or you can
recognize that the web is the great leveler across all computers of every
kind and use that. After a few false starts I found it is really quite
simple to use.
It is simplest because anyone who can use a browser can read files using
this method. There is no need to learn to use an ftp client. A child can use
it.
Your linux distribution has the Apache web server under the filename httpd.
For free use. For buy waste time. If it does not have it use a better
distribution. Find it on apache.com and install it. I use Redhat, Fedora 10.
I do not see a single thing unique to this distribution. It has been on
Redhat distributions going back to at least 6.0.
1) You must start Apache.
2) You must open the http port which is 80.
3) You must make the files available to Apache so they can be served.
Starting Apache
There are several ways to start apache when the system boots or manually.
This is the most frequently recommended way to do it. It is consistent with
turning other system services on and off.
# /sbin/chkconfig --level 5 httpd on
The Apache documentation recommends
apachectl start
when it is to be started manually after boot. I see no reason not to start
Apache when the system boots. It has no overhead until there is a request on
port 80.
Opening port 80
Also as root to open the firewall which is still there even if
selinux is also used. Run the GUI
# system-config-firewall
and check the box for WWW (HTTP) 80/tcp. You should see SSH already
checked. Checked means it is open.
Making files available
! The following is probably the worst way to make it work but it does
work !
Move all the directories which contain the files you want served to
/var/www/http. All my files were on USB drives mounted under /media so I
simply moved media to /var/www/http.
$ mv /media /var/www/http
So as not to mess up other scripts I created a symlink
$ ln -s /var/www/http/media /media
If the files you want to share are some place else you do the same two
things. Say the share directory is your home diretory.
$ mv share-dir /var/www/html
$ln -s /var/www/html/share-dir share-dir
To make it easy I created a small index.html file which contains the links
to the right directories. For example,
<a href="media/8500/BOOKS">Books</a>
If you are not familiar with how to write html files VIEW>SOURCE of this
file. Ignore the tags about tables. The following is the minimum needed.
Name the file index.html and put it in /var/www/html. Note because media
was also moved to this directory there is NO leading / on media.
<html>
<body>
<a href="media/8500/BOOKS">Books</a>
</body>
</html>
How to access files
For the other computers to access these files its browser is pointed to the
router IP of the storage computer.
192.168.1.101
Those numbers are what is entered in the top center window on browswers. It
is the same place that the website name is found.
From there the browser moves to the file of interest and retrieves it with a
right-click of the mouse.
Other considerations
I use a Linksys router. I have NOT looked into how to have my file serving
computer always get the same IP. It hands them out on a first come first
served basis starting at 100 or whatever you have set it to do. Read The
Fine Manual.
I use external usb drives for all my mass
storage. If you want to share files in your home directory you move that
directory to /var/www/html and create a symbolic link in your home directory
to that directory in /var/www/html.
Continuing the original example say you have a subdirectory called BOOKS.
Simply repeat the steps above moving BOOKS to /var/www/html
mv BOOKS /var/www/html
and create the symbolic link, the symlink, as above while in your home
directory.
ln -s /var/www/html/BOOKS BOOKS
WARNING
Do not reverse the above steps. Do not create a symbolic link this way.
ln -s BOOKS /var/www/html/BOOKS
It will not work.
If you have privacy issues you have several options. The first and simplest
is to organize your files so what you want kept private is not a
subdirectory under BOOKS. After lots of false starts I found that only
things which are in directory and subdirectory of what is put in
/var/www/html can be served. I am certain there is way to serve them without
that but I am not interested in learning more at this point.
Another method is to use the .htaccess file. I am certain there are other
methods and much better methods in the fine docs Apache provides. However
simply getting the privacy issues out of the subdirectory chain works just
fine and it is absolute. It does not depend upon learning a single thing
about Apache. KISS!
|