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

Changing Print Size in Firefox 11+ with NoSquint

Recently came across and issue with emails and other web pages printing the fonts in an unreadable size. This was not an issue with Internet Explorer or Chrome. Found that this is a fairly common issue that users were experiencing.

This is where Firefox AddOns fill the gap. Enter NoSquint. NoSquint allows you to adjust the viewing and printing size of the pages and fonts and alleviates the issue. Installation is simple as clicking on Add To Firefox and allowing Firefox to restart.

Controls are handles by the zoom buttons in the toolbar and the Add-on bar on the bottom of Firefox.

NoSquint allows you to adjust the text-only and full-page (both text and images) zoom levels as well as color settings both globally (for all sites) and per site.  NoSquint can:

  • Override the default text-only and full-page (both text and images) zoom levels for all websites
  • Enforce your own foreground and background colors
  • Remember your zoom levels and color settings per site, automatically applying them when you return.
  • Disagree with what NoSquint calls a site? A powerful exceptions mechanism lets you split up or group together sites with URL patterns.

Download and install the Add-on and give it a try and see if it resolves your Firefox printing issues.

Update!!!

I also found that the Scale setting in Page Setup can also correct printing size. Click File > Page Setup and un-check Shrink to fit Page Width, change the Scale value to 100% and  re-check Shrink to fit Page Width and click OK to save the changes will correct the printing small fonts issue.

Enabling Server Status on Apache 2.2

Apache 2 has a nice feature to allow a server admin to view the performance of Apache. When mod_status module is enabled an HTML page will be presented to allow stats to be presented in a readable format in which refresh can be set.

Server status details:

  • The number of worker serving requests
  • The number of idle worker
  • The status of each worker, the number of requests that worker has performed and the total number of bytes served by the worker (*)
  • A total number of accesses and byte count served (*)
  • The time the server was started/restarted and the time it has been running for
  • Averages giving the number of requests per second, the number of bytes served per second and the average number of bytes per request (*)
  • The current percentage CPU used by each worker and in total by Apache (*)
  • The current hosts and requests being processed (*)

 

Enabling the module is easy and can be done on Apache running on Windows and other Unix / Linux systems. First lets open the Apache configuration file httpd.conf.

Find the LoadModule line

LoadModule status_module modules/mod_status.so

and un-comment or add it. Next we need to add the ExtendedStatus variable and set it to On, the default setting is Off.

Note: This setting applies to the entire server, and cannot be enabled or disabled on a virtualhost-by-virtualhost basis. The collection of extended status information can slow down the server.
Add

ExtendedStatus On

Now we need to add the server-status site to Apache. You can create a virtual host for the server object and store it in the conf.d or you can just add it to the httpd.conf, the choice is yours.

Save the httpd.conf file and restart Apache, make sure to test the config changes before restarting. Open a browser and  open http://servername/server-status and you should be directed to Apache Server status page.

As you can see there is plenty of good information on the performance of the server as well as another problem determination tool.

Automatic Updates
You can get the status page to update itself automatically if you have a browser that supports “refresh”. Access the page http://your.server.name/server-status?refresh=N to refresh the page every N seconds.

Display Machine Readable Status File
A machine-readable version of the status file is available by accessing the page http://your.server.name/server-status?auto. This is useful when automatically run, see the Perl program in the /support directory of Apache, log_server_status.

Running ASP.NET on Apache 2.2

Continuing with running Apache 2.x on Windows systems (Windows 7 and Windows 2008 R2) I found the desire to be able to deliver ASPX pages on the Windows server in my development environment. Upon searching the Internet I came across an Apache module mod_aspdotnet.so found here. The module is no longer being actively updated but works well on Apache 2.0 – 2.2 installations.

This implementation is limited  and true ASP hosting should be done with IIS, but no one said we couldn’t have a try at it!

Download mod_aspdotnet-2.2.0.2006-setup-r2.msi but do not double click to run the installation. Instead we need to extract the contents to a temporary directory and will manually copy Apache.Web.dll and mod_aspdotnet.so to the correct directory’s. The reason is that double-clicking will not put the Apache.Web.dll file in the correct location and will register with the GlobalAssemblyCache.

Open a command prompt and change to the directory where you downloaded the file to and run the command.

msiexec /a  /qb TARGETDIR=

Example:

msiexec /a mod_aspdotnet-2.2.0.2006-setup-r2.msi /qb TARGETDIR=c:\temp

The files will be extracted into

First, copy mod_aspdotnet.so to your Apache modules directory c:\Apache2\modules next copy Apache.Web.dll to the c:\apache2\bin, assuming this is where you have installed Apache.

Modify Apache’s httpd.conf file and add this section to the end of the file.

# asp.net support
LoadModule aspdotnet_module modules/mod_aspdotnet.so

AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \
licx rem resources resx soap vb vbproj vsdisco webinfo

AliasMatch "^/(?i)aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*)" \
"C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"


Options FollowSymlinks
Order allow,deny
Allow from all

# Create Temporary ASP.NET Files directory under .NET framework 2.0.
AspNetMount /asp "C:/apache2/htdocs/asp"
Alias /asp "C:/apache2/htdocs/asp"

# Allow asp.net scripts to be executed

Options FollowSymlinks Indexes
AspNet Files
Order allow,deny
Allow from all
DirectoryIndex default.htm default.aspx

Save the changes and restart Apache service, hopefully the service will restart without errors. Now we need to test the setup, in the Directory directive I have created a test asp site.

Open your editor of choice and paste in the following code. This will display the .NET version.

<%@ Page Language="VB" %>








Save the file as default.aspx in the c:\apache2\asp\ directory.

Hope this works for you as it did for me. This will only work on Apache 2.0 / 2.2.

Install mod_perl on Apache 2.2 on Windows 7

To continue on with developing on Windows using Apache/MySQL/PHP I wanted to add mod_perl to the mix. For this post I chose to make it work on Apache 2.2 but it could possibly work on Apache 2.4 as well, but I have not tested they portion yet.

First piece of the puzzle is to download a version of Perl that supports the Module on Apache. In the past I have gone with ActiveState’s ActivePerl but lately I have been using Strawberry Perl due to changes in retrieving older releases.I settled on Perl 5.10 release.

Download Strawberry Perl 5.10.5 from http://strawberryperl.com/releases.html and click on strawberry-perl-5.10.1.5.msi under the Strawberry Perl May 2011 section.
Once downloaded just double-click to install it, you can change the default installation path or change it to your preference. Once the installation is completed then, open a command prompt to set the perl environment and reboot the system.

c:\> cd C:\strawberry

Run the command

c:\strawberry> perl\bin\perl.exe update_env.pl.bat

Next download and compile the mod_perl using ppm (Perl Package Manager)

ppm install http://cpan.uwinnipeg.ca/PPMPackages/10xx/mod_perl.ppd

The installation process will start. Once it compiles the module it will ask where to put it. This will be your Apache modules directory (ex:c:/Apache2/modules)

Close the command prompt and edit c:\Apache2\conf\httpd.conf
We must tell Apache to load the module and tell it where the perl Dll lives. You can add this to the bottom of the file.

LoadModule perl_module modules/mod_perl.so
LoadFile "C:/strawberry/perl/bin/perl510.dll"

Find the mime section and modify this

AddHandler cgi-script .cgi .plx .plex .pl

Now we need to enable and add a few items to allow perl to execute.

Look for the alias_module section and make sure the cgi-bin line is pointed to the correct location.

ScriptAlias /cgi-bin/ "c:/Apache2/cgi-bin/"

Next you will need to add ExecCGI in the Option section.

Options Indexes FollowSymLinks ExecCGI

Save the changes and restart Apache service. We are now ready to test to see if it displays a simple Perl Hello script.

You can copy the code and save it as test.pl in c:\apache2\htdocs or anther directory of your preference.

#!c:\strawberry\perl\bin\perl.exe
# ^^^ this must be the first line of the script! ^^^
# start code

use strict;
use CGI;
my $q = new CGI;

# print header and start the markup output

print $q->header( "text/html" ),$q->start_html( "hello from perl cgi!" );
print $q->h2("Hello Mark...");
print $q->end_html;
# end code

I hope this helps get Perl working in your Windows Apache install.

Install WordPress on Apache 2.4 on Windows

In following along with a previous post on installing Apache 2.4 PHP 5.4 and MySQL 5.5.21 on Windows, I will explain how to install WordPress 3.3.1. The installation is very easy to accomplish.

First download the latest version of WordPress from here, which at the time of this post it is 3.3.1. Next you will need to unzip the file to c:\apache24\htdocs\ on your system.

Next step is to create an empty database. To accomplish this task open a command prompt.Login to mysql and create the DB (wordpress) and create the user account and grant access.

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

Close the command prompt open Windows Explorer and open C:\Apache24\htdocs\wordpress\wp-config-sample.php with a text editor of your choice.  Find the following lines and change the database name to wordpress and your username and password for , which by default is root with no password.

// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘wordpress’);

/** MySQL database username */
define(‘DB_USER’, ‘wpadmin’);

/** MySQL database password */
define(‘DB_PASSWORD’,  'P$ssw0rd');

/** MySQL hostname */
define(‘DB_HOST’, ‘localhost’);

Save the file as wp-config.php.

Open your Internet browser and type in http://localhost/wordpress/wp-admin/install.php and everything from there should run smoothly to complete the installation.

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

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/.

Switch to our mobile site