Sunday, February 24, 2013

Ubuntu Apache2 Can't find fully qualified domain name

TO KNOW:
Linux, VIM or any text editor.

This is a QUICK and DIRTY fix to this problem.  It works and for a local (off the web server) you can call it a day.  Lots more to do if you want to make this a production webserver of course.

vim /etc/apache2/httpd.conf

By default this is a blank file.

Add this line exactly:

Servername Localhost

Restart

/etc/init.d/apache2 restart

Cheers!

Install Imagick in Ubuntu or CentOS

KNOW:
How to setup a LAMP Webserver in either CentOS or Ubuntu
How to program in PHP
Actually have a need for this library for viewing graphic images.

What is Imagick???
Imagick, a horrible name by the way, is a great alternative to the built in GD library supplied by PHP for viewing images.  It's much faster and more structured.
Sadly the documentation to install the software is PAINFUL and lacking.  I checked many a forums and blogposts for a variety of BAD information.  It's amazing.  
Anyway, let's figure out how to do it. 

Please note I am using repositories rather than download from source as I hate involving those headaches.  I'd rather have others instead.  These have been tested with the OS in question and I personally recommend that approach

CentOS: (for old-outdated version)
By far the most work.  If you want to use the CentOS repositories, I have set this up as a script for you. This should work just fine but I honestly don't recommend it.  Imagick is horribly out of date with many basic functions not even included.


!#/bin/bash
yum install ImageMagick.386 -y

# need to investigate.  Do we need the devel.
yum install ImageMagick-devel.386 -y

# you need this and pear for the next two steps.
yum install gcc gcc-c++ autoconf automake -y
yum install pear -y

# update the pear channel
pecl channel-update pecl.php.net

# use pear to install it
pecl install imagick -y

# make a new file called imagick.ini and have one line in it to alert php of this new feature
# It will not work installing in php.ini
echo 'extension=imagick.so' > /ect/php.d/imagick.ini
service httpd restart

# just to test it from the command line
php -m | grep imagick

BUT WAIT!!!!!!!!!!!!!!
This version of Imagick ???  You might as well have downloaded the Model-T. 

TRICKY!!!!
The easiest way is to simply use a repository.  REMI is an excellent repository for the most up-to-date RPM's for CentOS  Keep in mind that you now will deal with two repositories so their are some basic bookkeeping issues here. 

1) ALWAYS use -- enablerepo=remi --disablerepo=* when dealing with this repo for installing and removing packages.  
2) Be sure to think about integrated packages.  In this case we need both php AND Imagick so we will be getting both.  You can live with the old versions of Mysql and Apache as they won't conflict. 

Now, here's the messy ugly steps you need to do.

As of 2013 this is the valid link
#!/bin/bash

# get the data to support REMI Link is valid for 2013

wget http://rpms.famillecollet.com/enterprise/remi.repo
 

# tell YUM to enable the repo
yum --enablerepo=remi

# remove your current outdated version of PHP.  VERY IMPORTANT as we don't want library conflicts.
yum remove php

# Install php and ImageMagik and pear
# NOTE --disablerepo=* we disable EVERY repo for PHP and just use REMI otherwise
# messy dependency issues reveal its ugly head

yum install --disablerepo=*  php ImageMagick2 php-pecl-imagick --enablerepo=remi
 

# restart apache
service restart httpd

# php -m | grep imagick


Ubuntu 12.04 (somewhat easier right :)

!#/bin/bash

apt-get install imagemagick libmagickcore-dev -y
apt-get install php-5-imagick -y
You went through all that work and I'm not showing you how to test it.  That's not nice.  Here's a quick and dirty test file you can generate.  I called my Test.php since I was in a hurry.


<?php

       $FullPathName = '(put your test image here. I'd recommend using the full path ';

       // setup a new image and import from file.
        $Image = new Imagick ($FullPathName);
       
        // generate a header for display
         header('Content-type: image/jpeg');

        // If 0 is provided as a width or height parameter,
        // // aspect ratio is maintained
    
        $Image->thumbnailImage (100, 0);
        //
        echo $Image;
        //
        die ();

?>




Helpful ImagMagick commands


What to know:
Php programming.
That you are insane enough to tackle photos with php

REFERENCES
// at least it gives you the function lists
http://php.net/manual/en/book.imagick.php 

// nice function list with ACTUAL examples
http://eclecticdjs.com/mike/tutorials/php/imagemagick/imagick_1.php

// nice article on EXIF info (turn off your scriptblocker to see the actual script on the blog site)
http://blog.jmoz.co.uk/imagick-strip-exif-data

For those working with Imagick and its libraries you know how 'well' documented the information is.  Well let's help you out with some valuable functions.

EXIF information
There are several, barely documented features for EXIF data in JPG files.  
$File = '(Name of File)';
$Image = new Imagick($File); 
 
// GET EXIF data 
print_r($Image->getImageProperties ('exif:*')); 
 
// STRIP EXIF data 
$Image->stripImage(); 
 
// WRITE file WITHOUT EXIF data 
$DestFile = 'Fred.jpg';
$Image->writeImage ($DestFile); 
 
// read image data 
$Image->readImage($DestFile); 

// output the data
print_r($Image->getImageProperties('exif:*'));

Wednesday, February 20, 2013

Css Tag Styles - updated

WHAT you need to know:
Basic CSS:
HTML:

My first draft, was...terrible...so I have corrected it and made it much easier and  much more complete.  Here we go!

In CSS (cascading style sheets),  one of the first things you need to know is how to label a tag.  For people not that familiar with CSS, basically CSS allows you to move the configuration of HTML tags to another file and call that file ((something).css) for a variety of customizations. 

Now labeling a tag for configuration has some flexibility but also some confusion.  Let's try to move away from confusion to understanding.  For the purposes of this tutorial, I'll be using one line of code for configuration.  I'll change the background color to red (I dare you to do red in a document and like it :)

 1) Basic Tag selection (Tag Selector)
If you want the least painful and quickest way to tag something than look no further than call your selector the tag itself.  That's right, you can actually configure a tag in html by it's actual name.
Example.  Suppose I want the background color of a button to be red (ug).  Anyway:

IN HTML
<button>(not complete of course)

IN CSS
button
{

   background-color:red

}

Now this has one big advantage. Anytime I call the stylesheet, the button tag in html will be red.  The disadvantage is that this has zero customization.  EVERY button will have the background color of red.  If that's what you want then go for it, but CSS gives us some more flexibility than that.

1) Class Selector (a period)

This is pretty basic.  Using a period for the label, you can assign a label to a variety of tags.  This means that anytime I use this label, buttons, body, etc will all inherit this tag.  The key is that this is designed to be used over and OVER and OVER again.  Therefore use it when you need to use it a LOT for a variety of element.s

HTML
<body class='Fred'>
<button class='Fred'>
<input class='Fred'>

CSS
.Fred
{
    background-color:red;

}



Ya, you can use this class with any element your heart desires.  However, what if you want to filter it to only certain elements.  NO PROBLEM.  CSS gives us a nice feature and in my coding, most of the time I do it this way.

HTML
<body class='Fred'>
<button class='Fred'>
<input class='Fred'>

Fred.button
{
   background-color:red;
}

Yes in this case ONLY the button will see red color.  I filtered it so that only a button can have that feature (if you consider ugly red a feature).  Now don't get discouraged.  Using a comma we can actually do more than one element.  Using the same example.

HTML
<body class='Fred'>
<button class='Fred'>
<input class='Fred'>

Fred.button, Fred.input
{
   background-color:red;

}

Now both button and input get the red color. Body will be left alone.  Cool!


ID Selectors (a pound symbol)

IDENTICAL except that you use this only ONCE.  If you only need this label once use this; otherwise use the Class selector.  As it's called, the ID selector means you use the id label of an element.  Given that ID's must be unique to an element, this is something useful if you have need for it in only one element.

#Fred
{
  background-color:red;
}

<table id = 'Fred'>

That's it.  Now isn't CSS labeling flexible?  Their are a few misc. things you can do but stick with the basics.  Most of the time this will be just fine for your issues.