Life of a Geek Admin

The Daily adventures of a true geek administrator

Life of a Geek Admin - The Daily adventures of a true geek administrator

Install OpenDb on CentOS 5.5

The Open Media Collectors Database (OpenDb) is a PHP and MySQL based inventory application that allows you to easily catalog and lend out your stuff. Its primary purpose is to catalog media related items, such as DVD’s, Books, CD’s etc, but its so flexible you can use it to catalog pretty much anything.

Opendb ships with many media related (DVD, VCD, CD, VHS, games, books, and laser discs.) item type definitions, or you can download a user contributed item type or create your own. Currently the application is at version 1.5.0.7 and there is active development in the SVN.

Requirements

To install the Open Media Collectors Database (OpenDb) on your site, you will need the following:

  • WebServer (Apache 1.3, 2.x, IIS,…) – Apache is recommended, but IIS should work too.
  • PHP 4.3.0+, 5.X
    • track_vars must be enabled.
    • register_globals can be enabled/disabled. You should really have this disabled for security reasons anyway!
    • php-mysql or php-mysqli module must be installed, so that PHP can access MySQL.
    • php-gd module for image thumbnail generation.
  • MySQL Database 4.X, 5.X
  • SMTP server or PHP email configured. If this is not possible, be sure to set the email configuration Mailer to ‘none’. The borrower functionality is severely restricted without email functionality.

Installation

The current version for OpenDB is 1.5.0.7 and can be found at http://sourceforge.net/projects/opendb/. Download the file to your server. The downloaded file is in zipned format which will require unzip to open. Our destination for the files is /var/www/html/opendb, for which we will need to create the directory and unzip the file contents.

$ sudo mkdir /var/www/html/opendb

$ sudo unzip OpenDb-1.5.0.7.zip -d /var/www/html/opendb

Change a few directory permissions for the installer to be able to work correctly.

$ cd /var/www/html/opendb

$ sudo chmod ugo+w ./log ./include ./importcache ./itemcache ./upload ./httpcache

Now that the files are in their final destination we can run the OpenDb installer. Run the OpenDb installer, by opening the install.php in your browser. Use a URL something like http://<your_server>/opendb/install.php

I attached an OpenOffice Doc with more detail OpenDb Installation

ClamAV on CentOS 5.5

I know this is Linux and viruses are not supposed to be an issue, but face it we have other operating systems connecting and they are known for bringing these little monsters in, so it is our duty to seek and destroy those on the server. In steps ClamAV, a fast, free and efficient anti-virus solution. Dag Wieers maintains many packages for downloads and he just happens to have what we are looking for with ClamAV. Once you have this installed there are many other applications to integrate with on your server.

To install
1. Download the file using wget
$ sudo wget http://packages.sw.be/clamav/clamav-0.96.4-1.el5.rf.i386.rpm
$ sudo wget http://packages.sw.be/clamav/clamav-db-0.96.4-1.el5.rf.i386.rpm

Install it
$ sudo rpm -ivh clamav-0.96*.rpm

Now that we have it installed there are a few things we need to learn about it and do. First thing is to update the definitions. We achieve this by running the command freshclam. Freshclam requires and Internet connection to download and update the virus definitions. All you have to do is type the command, press enter and voila! We are up to date.

2. To run antivirus and print infected files
clamscan -ri /home
3. To remove infected files and emails.
clamscan -ri --remove /home
4. Running as Cron Daily Job
To run antivirus as a cron job (automatically scan daily) just run crontab -e from your command line. Then add the following line and save the file. I have added them to my root crontab for this example.
02 1 * * * root clamscan -R /var/www
This will run the cron job daily @ 1.02 AM by scanning the public html files. You can change the folder to whatever you want for mail etc.
00 11 * * * * root freshclam
This will update the anti-virus database at 11 am daily.

php-Inventory on CentOS

Found a simple PHP /MySQL solution for tracking Inventory parts to fit a need to track spare computer parts.

PHP Inventory is free, open-source, web-based inventory tracking solution, designed to provide small businesses the efficiency of large companies.

Inventory Control reduces costly inventory errors, improves customer service, and will increase the value of your business. PHP Inventory is easy to use and implement without the cost or complexity of larger inventory tracking systems.

Download the zip file from http://www.phpwares.com/content/php-inventory to your server and unzip to /var/www/html.

$ cp php-inventory_1.2.zip /var/www/html/
$ sudo unzip php-inventory_1.2.zip
$ sudo mv php-inventory/ inventory/

Php-inventory requires MySQL database to be setup. To keep with good practices we should setup an MySQL user and make that user the owner of the database.

Open a terminal and connect to the MySQL database. The passwords are made up and you should use your own.

$ mysql -u root -p
mysql> CREATE DATABASE `inventory` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> CREATE USER 'phpinv'@'localhost' IDENTIFIED BY 'phpMy1nv';
mysql> CREATE USER 'phpinv'@'%' IDENTIFIED BY 'phpMy1nv';
mysql> GRANT ALL ON `inventory` . * TO 'phpinv'@'localhost';
mysql> GRANT ALL ON `inventory` . * TO 'phpinv'@'%';
mysql> exit

Now that we have a database created and permissions set we need to run the supplied sql code. This is easiest to do this with phpMyAdmin or at the command line with MySQL. For ease of use I will be using phpMyAdmin.

Login to phpMyAdmin and click on the inventory database. Open site.sql with a text editor and select all , copy the text. Click on the SQL tab in phpMyAdmin and paste the contents in and click on the Go button. You should see a message stating your code executed successfully and on the left you will now see 7 new tables.Open site.xml and edit the database section with your database details.

<database type="mysql">
<server>localhost</server>
<login>phpinv</login>
<password>phpMy1nv</password>
<default>inventory</default>
</database>

Change the title of the system edit line 8 of templatesadminlayout.htm between the <title> tags.

Open a browser and go to http://localhost/inventory/index.php and login with username of admin with a password of test, after login be sure to change the passwords for the admin and regular user.

Add this to your “.htaccess” file to prevent viewing of the xml config file.
</Files ~ ".xml">
Order allow,deny
Deny from all
Satisfy All
</Files>

Note: They are currently working on a version 2 of the code and are looking for testers.

phpmyfaq on CentOS 5.5

Recently I ran into the need to create a Knowledgebase on my local network, basically a Faq that I could post how I have resolved issues with different hardware and software issues with my company. With a search on Google I came across phpmyfaq that runs on PHP with MySQL. The current version will not run on CentOS due to the requirement of PHP 5.2.x or higher which is not available in the stable repositories for the current CentOS release. However I was able to find 2.0.17 supports PHP 5.1.x series which is available.

Download 2.0.17 tar.gz file from phpmyfaq 2.0.17 tar to your server.

$ sudo su -
# tar zxvf phpmyfaq*.tar.gz -C /var/www/html/
# cd /var/www/html
# mv phpmyfaq-2.0.17/ faq/
# cd faq/

Create some sub-directories needed by the application.
# mkdir directory attachments
# mkdir directory data
# mkdir images/Image
# mkdir pdf
# mkdir xml

Set a few directory permissions for the installer to create the files it needs.

# chmod -R 755 attachments/
# chmod -R 755 data/
# chmod -R 755 pdf/
# chmod -R 755 xml/
# chmod -R 777 inc/
# chmod -R 777 images/

Exit as root and revertback to your user id. Create blank MySQL database and faq user and grant access For this example we are creating a user called faq with the password pHpmyf8q and a database called phpmyfaq and granting the faq user all rights to the database.

$ mysql -u root -p
mysql> CREATE DATABASE `phpmyfaq` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> CREATE USER 'faq'@'localhost' IDENTIFIED BY 'pHpmyf8q';
mysql> CREATE USER 'faq'@'%' IDENTIFIED BY 'pHpmyf8q';
mysql> GRANT ALL ON `phpmyfaq` . * TO 'faq'@'localhost';
mysql> GRANT ALL ON `phpmyfaq` . * TO 'faq'@'%';
mysql> exit

Now we are ready to open the installer web page and set the database settings and admin user account to finish the installation. Open a web browser and type http://<your_server_name>/faq/install/installer.php.

You will be presented with a page asking for database type and connection information as well as admin user and id. Using the information from this example

SQL Server: MySQL 4.x/5.x/6.x (PHP 4/PHP 5)
SQL server host: localhost
SQL username: faq
SQL password: <super secret pasword>
SQL database: phpmyfaq
Table prefix: knowledgebase (if you plan to have more than one Faq you need to put a value here, otherwise leave it blank)

Fill in the information in the phpMyFAQ information and click on Install phpMFAQ 2.0.17 now! and you are done.

phpMyFAQ is now running and is just in need of a few users with rights to post. Access the admin page at http://<your_server_name>/faq/admin/index.php and supply the credentials you setup. Once you are in, you can add users. To access the faq http://<your_server_name>/faq/.

Tracking Movie Collection with Griffith

Have you ever had one of those times that you were looking for a movie  and didn’t know if you had it or just had no idea what movies you had? Well in comes a nice little application called Griffith.

Griffith is a media collection manager application. Adding items to the collection is as quick and easy as typing the film title and selecting a supported source. Griffith will then try to fetch all the related information from the Web. Griffith is a cross-platform application and is known to run on GNU Linux, Microsoft Windows and MacOS X systems.

In  this post we will cover installing Griffith and configuring it to use MySQL for the database back end.

Install / Configure Griffith on the server
Griffith is in the repositories for Ubuntu and Fedora / CentOS, so installation is easy from the terminal.

Ubuntu
$ sudo apt-get install griffith

Fedora / CentOS
$ sudo yum install griffith

MySQL Database Creation
Now that the hard part is over we can create the MySQL database using the terminal. Once the database has been created and permissions set there is nothing to do but connect a client to the database and it will create the tables and fields it requires.

Open a terminal and connect to the MySQL database.

$ mysql -u root -p
mysql> CREATE DATABASE `griffith` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> CREATE USER 'griffith'@'localhost' IDENTIFIED BY 'gRiFiTh';
mysql> CREATE USER 'griffith'@'%' IDENTIFIED BY 'gRiFiTh';
mysql> GRANT ALL ON `griffith` . * TO 'griffith'@'localhost';
mysql> GRANT ALL ON `griffith` . * TO 'griffith'@'%';
mysql> exit

The commands created the database and user griffith on localhost and remote hosts to the database griffith. The password used is the default password created by the application, which you can use a different password (most advisable).

Edit /etc/my.cnf and comment out bind-address, this will allow remote connections to the database. If it is left to 127.0.0.1 then only the local host will be able to connect to the databases being hosted. Once the change has been made restart mysqld service.

$ sudo service mysqld restart

Client Installation and Configuration
Linux
Now that the server is configured and working, the clients need to be installed and configured. For Fedora and Ubuntu distributions use the same installation method as was done with the server. For Windows you will need to download and install Griffith from the website. Once you have installed the program we can move on to the configuration.
Next we need to open Griffith, click  Applications > Sound and Video > Griffith. Click File > Select Database. Use the following settings for this dialog.

Type: MySQL
Host: Your Servername or ip
Database: griffith
Username: Your username for database access or root
Password: Password associated to the selected user.

Click Save and if all is good you will login and connect to the database. If this is the first connection to the blank database the program will create the structure for you.

Windows Clients
For Windows systems the installation is as simple as downloading the self installing executable and double-clicking to install. Download the latest client from http://griffith.cc/index.php?option=com_content&task=view&id=22&Itemid=39 and click on the link for the Windows installer. The current version at this writing is 0.12.1.

Once the installation is complete open Griffith and configure the database connection to your server. Click File > Select Database. Use the following settings for this dialog.

Type: MySQL
Host: Your Servername or ip
Database: griffith
Username: Your username for database access or root
Password: Password associated to the selected user.

Now you are ready to add movies. You can do this one by one or if you have the movies in a spreadsheet you can export to csv and import into Griffith.

Switch to our mobile site