Getting Apache22 on FreeBSD 8.1 to work with DHCP

Apache likes to have a static IP address to work with and that is not always something you can guarantee to have. An easy way to get around this is to add the following two files to /etc

Firstly add a file called “dhclient-exit-hooks” with the following

#!/bin/sh


APINCDIR=/usr/local/etc/apache22/Includes
APPIDFILE=/var/run/httpd.pid


if [ ! -z “$new_ip_address” ]; then
    # First, configure the /etc/hosts file so Apache can start
    HOSTNAME=`grep ^hostname= /etc/rc.conf | awk -F = ‘{ print $2 }’ | sed -e ‘s/”//g;’`
    if [ ! -z “$HOSTNAME” ]; then
        echo “$new_ip_address $HOSTNAME” > /etc/hosts.dynamic
        cat /etc/hosts.boilerplate /etc/hosts.dynamic > /etc/hosts
    fi


    # Next, we’ll configure the Apache web server, if it has been installed
    if [ -d $APINCDIR ]; then
        echo “ServerName $new_ip_address” > $APINCDIR/server-name.conf


        if [ -f $APPIDFILE ]; then
            kill -HUP `cat $APPIDFILE`
        fi
    fi
fi

Secondly add a file as referenced above called “hosts.boilerplate” with the following content:
# $FreeBSD: src/etc/hosts,v 1.16 2003/01/28 21:29:23 dbaker Exp $
#
# Host Database
#
# This file should contain the addresses and aliases for local hosts that
# share this file.  Replace ‘my.domain’ below with the domainname of your
# machine.
#
# In the presence of the domain name service or NIS, this file may
# not be consulted at all; see /etc/nsswitch.conf for the resolution order.
#
#
::1 localhost localhost.my.domain
127.0.0.1 localhost localhost.my.domain
#
# Imaginary network.
#10.0.0.2 myname.my.domain myname
#10.0.0.3 myfriend.my.domain myfriend
#
# According to RFC 1918, you can use the following IP networks for
# private nets which will never be connected to the Internet:
#
# 10.0.0.0 –   10.255.255.255
# 172.16.0.0 –   172.31.255.255
# 192.168.0.0 –   192.168.255.255
#
# In case you want to be able to connect to the Internet, you need
# real official assigned numbers.  Do not try to invent your own network
# numbers but instead get one from your network provider (if any) or
# from your regional registry (ARIN, APNIC, LACNIC, RIPE NCC, or AfriNIC.)
#
Then reboot, restart service, whatever your preference is, and test it out.

Creating symbolic links in FreeBSD

Sometimes when you FTP into a FreeBSD environment you need to bounce around to directories acroos the file system. One way to simply this process when working in a FTP client is to create a symbolic link as a file. It is really easy.

To go from point A to point B where point A is a click able file and B is a target folder just run:

ln -s /path/to/folder/B /where/you/want/the/file/to/exist/B

MongoDB: Looking at the file system

MongoDB stores objects in a binary format called BSON. BinData is a BSON data type for a binary byte array. However, MongoDB objects are typically limited to 4MB in size. To deal with this, files are “chunked” into multiple objects that are less than 4MB each. This has the added advantage of letting us efficiently retrieve a specific range of the given file.

While we could write our own chunking code, a standard format for this chunking is predefined, call GridFS. GridFS support is included in many MongoDB drivers and also in the mongofiles command line utility.

http://blog.mongodb.org/post/183689081/storing-large-objects-and-files-in-mongodb

GridFS is a storage specification for large objects in MongoDB. It works by splitting large object into small chunks, usually 256k in size. Each chunk is stored as a separate document in a chunks collection. Metadata about the file, including the filename, content type, and any optional information needed by the developer, is stored as a document in a files collection.

So for any given file stored using GridFS, there will exist one document in files collection and one or more documents in the chunks collection.

http://www.mongodb.org/display/DOCS/GridFS+Specification

  1.   
  2. $m = new Mongo(); //connect  
  3. $db = $m->selectDB(“example”); //select Mongo Database  
  4.   
  5. $grid = $db->getGridFS(); //use GridFS class for handling files  
  6.   
  7. $name = $_FILES[‘Filedata’][‘name’]; //Optional – capture the name of the uploaded file  
  8. $id = $grid->storeUpload(‘Filedata’,$name//load file into MongoDB  
  9.   
  10. ?>  

www.lightcubesolutions.com/blog/?p=209

http://en.wikipedia.org/wiki/MongoDB

Still developing for IE6? Get significant CSS3 compatibility with PIE

Seriously? Well you’re sadly, and probably dangerously for your or worse other peoples data, not alone.

Coming to the rescue for the presentation layer at least as security was thrown out the window with the bathwater AND the baby when you decided to stay with 6 – is PIE.

PIE stands for Progressive Internet Explorer. It is an IE attached behavior which, when applied to an element, allows IE to recognize and display a number of CSS3 properties. It is simply attached to an element in the CSS file like: behavior: url(PIE.htc); and adds support (full or partial) for the following CSS3 features:

  • border-radius
  • box-shadow
  • border-image
  • multiple background images
  • linear-gradient as background image

Note that the missing CSS3 properties are under development…

For more info and the actual PIE itself go here: http://css3pie.com/

How to install MemCached with Apache, PHP, and MySQL on FreeBSD

memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

Danga Interactive developed memcached to enhance the speed of LiveJournal.com, a site which was already doing 20 million+ dynamic page views per day for 1 million users with a bunch of webservers and a bunch of database servers. memcached dropped the database load to almost nothing, yielding faster page load times for users, better resource utilization, and faster access to the databases on a memcache miss.

Notes

  • There are definitely steps in this that can be changed, extended, other, but these will get you what you want in a good learning fashion. And learning is key!
  • You can just as easily install memcached on an IIS server.
  • Yes you can download binaries with pkg_add etc. but building will help you literally see what is going where. One just has to make sure that some housekeeping is performed during the build process. This is done with the clean parameter in the make command.
  • This appears to be quite a popular post. Please keep in mind that version numbers change so update the strings below.
To Start

First off build a FreeBSD box. It’s easy, fast, and best of all free once you have the hardware – real or virtualized. Don’t forget to install the ports. You’re going to need them going forward.

For dependency issues we’re going to install all the items in this order:

  1. MySQL Server 5.x
  2. Apache 2.x
  3. PHP5
  4. PDF-Lite
  5. PHP Extensions
  6. MemCached

1: MySQL

Move to the ports folder, specify some build parameters that will helps speed things up a tad.
cd /usr/ports/databases/mysql51-server
make BUILD_OPTIMIZED=yes BUILD_STATIC=yes
make install clean
Edit /etc/rc.conf and add mysql_enable=”YES”
Apply the configuration file: cp /usr/local/share/mysql/my-medium.cnf /etc/my.cnf
Assign the master password: /usr/local/bin/mysqladmin -u root password ‘new-password’
Start MySQL: /usr/local/etc/rc.d/mysql-server start

2: Apache

cd /usr/ports/www/apache22
make install clean
Edit /etc/rc.conf and add apache22_enable=”YES”
Edit /boot/loader.conf and add accf_http_load=YES

3: PHP

cd /usr/ports/lang/php5
make install clean  !!In the popup at the least check off “Build Apache Module”
4: PDF Lite
fetch ftp://ftp.swin.edu.au/gentoo/distfiles/PDFlib-Lite-7.0.2.tar.gz
sudo mv PDFlib-Lite-7.0.2.tar.gz /usr/ports/distfiles/

5: PHP Extensions
cd /usr/ports/lang/php5-extension 
make install clean !!Confirm that sockets is selected.
Apply the configuration file: cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini
Enabling Apache to run PHP
Edit the Apache configuration file /usr/local/etc/apache22/httpd.conf and add
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
Change DirectoryIndex index.html to DirectoryIndex index.php index.html
Start Apache /usr/local/etc/rc.d/apache22 start
6: MemCached
cd /usr/ports/databases/pecl-memcache
make install clean
cd /usr/ports/databases/memcached
make install clean
Edit /etc/rc.conf and add memcached_enable=”YES”
Start MemCached with /usr/local/bin/memcached -d -u nobody
Confirming MemCached is running
Run netstat -an to confirm that a process is listening on TCP 11211
It may also be useful to run /usr/local/bin/php -i | grep -i ‘memcache’

Troubleshooting problems encountered with the SharePoint 2010 Configuration Wizard

For something with so few options the SharePoint 2010 Configuration Wizard should just work. Sadly it does not always do what it is supposed to do. When it does not your options are pretty much limited to common sense, event logs, and the Configuration Wizards logs themselves which found in the LOGS folder in C:Program FilesCommon FilesMicrosoft Shared Web Server Extensions14

They’re not perfect but they normally are sufficent enough to get started down the right path if you have a really obscure issue.

For example, lets say that you are having some kind of connectivity issues at the specify configuration server and database screen after opting to create a new farm. Inside this file you can find the parameters being set such as the user in the standard DOMAINUN format and their password as a series of ***** followed by mention of the functions as they are being stepped through by the installer. Very helpful if you are trying to figure out where the break is occurring!

A point to take away is that knowing the local time that you are running through the steps can be very helpful.

MongoDB: installing on windows as a service and your first database

MongoDB is an document-oriented DBMS. Think of it as MySQL but JSON (actually, BSON ) as the data model, not relational. There are no joins. If you have used object-relational mapping layers before in your programs, you will find the Mongo interface similar to use, but faster, more powerful, and less work to set up. In fact it is so easy to get running that I’m going to show you how to get it up and running as a Windows service in a few minutes.

But first, why would you ever want to use MongoDB?

The goal of MongoDB is to bridge the gap between key-value stores (which are fast and highly scalable) and traditional RDBMS systems (which provide rich queries and deep functionality). MongoDB is designed for problems that aren’t easily solved by traditional RDBMSs, including problems that require databases to span many servers.

MongoDB is a document-oriented database. This means that unlike a relational database management system, MongoDB manages collections of JSON-like documents. This allows many applications to model data in a more natural way, as data can be nested in complex hierarchies and still be query-able and indexable.

MongoDB supports an automated sharding architecture, enabling horizontal scaling across multiple nodes. For applications that outgrow the resources of a single database server, MongoDB can convert to a sharded cluster, automatically managing failover and balancing of nodes, with few or no changes to the original application code.

Moving on…

1: Getting the binaries…
Download the windows version here and be sure to get the 64bit version. The 32bit version has a limit of about 2.5Gb whereas the 64bit version has almost none… The reason for this is that the MongoDB storage engine uses memory-mapped files for performance and the goal for the engines code was to keep it as uncluttered as possible.

2: Create some folders
Before opening the downloaded archive you have to create a folder with content at the root of C: called “data”. Inside that create a folder called “db” Note that from now on I’m going to be giving the equivalent of shell commands highlighted and as you continue to read you will see why.

Start -> Run -> CMD
C:
cd C:
mkdir data
mkdir datadb
mkdir datalogs

At this point you should now have this structure on your file system.

3: Extract the downloaded files
You should have downloaded something named like this “mongodb-win32-x86_64-1.4.4.zip”

Extract the archive and move its contents to C: so you should see this type of structure:

4: Set MongoDB as a Windows Service
Looking inside of “bin” we can see a few .exe files. Our focus for now is going to be on “mongod.exe”

Setting it up as a service requires a couple of decisions. At a minimum:

  1. Where shall the logs go? In this example c:mongologs
  2. Where shall the data go? In this example c:mongodata 
  3. What port do want to run the web service on? In this example 1001.

With that decided creating the service is as easy as running the below from the command line.

mongod –bind_ip 127.0.0.1 –logpath c:datalogs –logappend –dbpath c:data –directoryperdb -port 1 –install

! If you wish to remove it just use: mongod –remove

So now Mongo should be visible in Services

Note the path to the executable and the fact that the service is not yet started…

Start the service and go here: http://127.0.0.1:1001/ where you should see the following information.

5: Accessing database
Accessing the database is done via mongo.exe found in bin
Run
C:
cd mongodbbin
mongo

and you should now be in the administrative shell like this.

! If you get an error like below just remove the service and redo without the port definition.

MongoDB shell version: 1.4.4
url: test
connecting to: test
Tue Jul 13 14:44:59 JS Error: Error: couldn’t connect: couldn’t connect to server 127.0.0.1 127.0.0.1:27017 (anon):952
Tue Jul 13 14:44:59 User Exception 12513:connect failed

Saving and retrieving is as easy as below.
db.foo.insert( { a : 1 } )
db.foo.find()

I have also included what the file systems should look like as well for this example.



And that’s it. You now have a working MongoDB service on your Windows machine!
Things to note

  • A performance environment would not have everything on C: 
  • Run binmongd -h for more options, there are not that many…
  • Defining the port rather than running it on the default 27017 requires some extras. Expect errors if you do not read up a bit more on MongoDB.
  • Did you notice that the administrative shell is a JavaScript interface..?

Resources

Javascript transition effects with Blockster

Highlighting your featured content can be quite the challenge. Getting the aesthetics right by pulling the eye in without stabbing it is a valuable skill. A nice tool that you can use when appropriate is Blockster.

Blockster is a Javascript transition effect designed for ‘featured content’ rotators or slideshows. Its underlying concept is to transition between one element to the next block by block. It is highly customisable in terms of how many blocks are involved, whether they fade in or simply appear, whether they appear in order or randomly, and more.

The script gives you full control over how the script behaves, giving you scope to create some pretty varying effects. You can set the number of rows and cols in the block grid, whether the blocks should fade in or simply appear, whether they should appear randomly, in order, etc.

Mitya likes jQuery

Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah – read more

Mitya likes GD

Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah – read more

Lorem Ipsum!

Examples, as always, make more sense than words…so go here for more: http://www.mitya.co.uk/scripts/Blockster-transition-effect-122

Another easy way to perform instant and/or automated backups of MySQL

PhpMyAdmin is great for what it does but it does not excel everywhere. If you’re looking to create instant or automated backups of MySQL databases consider Sypex Dumper 2.x

Built with PHP, it has an Ajaxed interface and can run database restores as well. Handily it can avoid PHP script timeouts by pausing the jobs. And being licensed under the BSD license, it is absolutely free. Interestingly supposedly it can also be integrated into third-party products… Something I have not done or tried. What impressed me mostly about it was how easy interacting with databases via the browser became with it.

http://sypex.net/en/