20 Dec 2011

Reading the documentation in /usr/share/doc especially the .gz compressed files

Have you ever wanted to read the the documentation in the /usr/share/doc directory. If you install apache it makes it nice and easy to read all the documentation that comes with most Linux packages.
First install Apache2
$ sudo apt-get install apache2 apache2-doc
apache2-doc is the special case here. It allows you to browse your documentation /usr/share/doc/ through your web browser. from

http://localhost/doc/

This does not work out right though. you need to change the configuration of apache to get it to decompress and show the *.gz files as plain text.
I posted on Stackoverflow to get a way to use the apache to show the content of *.gz documents in the /usr/share/doc/ directory. This is what was posted as possible solution
http://stackoverflow.com/questions/5242106/apache-gz-gzip-content-handler-for-linux-documentation-usr-share-doc-and-local

Here are those instructions in brief. It tells apache how to deal with .gz files to process them as plain text and send them to the browser as plain text.
 sudo a2enmod headers
 sudo a2enmod deflate
 gksu gedit /etc/apache2/sites-enabled/000-default
Go to the bottom of the file and find the section with Alias /doc/ "user/share/doc/" and change it to look like this.
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/local/doc">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128

    AddEncoding gzip gz
    <FilesMatch "\.gz$">
      ForceType text/plain
      Header set Content-Encoding: gzip
    </FilesMatch>
</Directory>   

 sudo apache2ctl restart
Now you are done and can read your *nix documentation that comes with most packages.

4 comments:

Anonymous said...

You need to edit your posting - the bracketed directory clause is missing:

<Directory "/usr/local/doc">

bulk of your conf insert

</Directory>

It's obvious to anyone who spends much time editing apache configs, but Joe user might miss it.

Aaron Nel said...

For some reason, blogger is removing any thing that looks like a html tag, I will keep trying to get it to show correctly.

Sean said...

In my reply, I entered the brackets using gt and lt html constructs, but you should be able to simply encapsulate your config file block in an html pre tag.

Aaron Nel said...

Thanks Sean, That worked. blogger is not a fan of pasting plain text. It took me about 10 tries to get it to look like the composer once it was posted.