nginx, PHP 5.3 and FastCGI on CentOS 5.5, Fedora 13, Red Hat RHEL 5.5/6

This is guide howto install nginx, PHP 5.3 and FastCGI webserver with MySQL and/or PostgreSQL and Memcache support on Fedora 12 and Fedora 13, CentOS 5.5, Red Hat (RHEL) 5.5/6. nginx (engine x) is a robust, small and high performance http server, reverse proxy server and also mail proxy server.

  1. Add and enable needed repositories: Updated 19.3.2010 Use following repositories to install nginx 0.8.xx version (currently 0.8.36 version) rpm -Uvh http://download.
Read more →

BitLy (bit.ly) PHP Class – Shorten and Expand URLs (and Hashes) with BitLy API

BitLy (bit.ly) is a service which allows users to shorten, expand, share and track URLs (links). bit.ly can be accessed through bit.ly website and a robust and open API. Example: Shorten http://www.if-not-true-then-false.com/ url -> http://bit.ly/8cZ1fb Expand http://bit.ly/8cZ1fb url -> http://www.if-not-true-then-false.com/ This post deals with bit.ly API usage with a simple PHP Class. This PHP class allows to shorten normal urls, expand bit.ly urls and expand bit.ly hashes. BitLy PHP Class <?
Read more →

Format bytes with PHP – B, KB, MB, GB, TB, PB, EB, ZB, YB converter

Simple PHP function that formats the bytes to the desired form. Possible unit options are: Byte (B) Kilobyte (KB) Megabyte (MB) Gigabyte (GB) Terabyte (TB) Petabyte (PB) Exabyte (EB) Zettabyte (ZB) Yottabyte (YB) PHP byteFormat function for formatting bytes Function takes three parameter: (bytes mandatory, unit optional, decimals optional) <?php function byteFormat($bytes, $unit = "", $decimals = 2) { $units = array('B' => 0, 'KB' => 1, 'MB' => 2, 'GB' => 3, 'TB' => 4, 'PB' => 5, 'EB' => 6, 'ZB' => 7, 'YB' => 8); $value = 0; if ($bytes > 0) { // Generate automatic prefix by bytes // If wrong prefix given if (!
Read more →

PHP: Loop through dates (from date to date) with strtotime() function

This is very easy way loop through dates (from date to date) with PHP strtotime() function. This example only echo dates, but of course this model can be used more complicated situations. <?php // Set timezone date_default_timezone_set('UTC'); // Start date $date = '2009-12-06'; // End date $end_date = '2020-12-31'; while (strtotime($date) <= strtotime($end_date)) { echo "$date\n"; $date = date ("Y-m-d", strtotime("+1 day", strtotime($date))); } Note: All different PHP strtotime() function syntaxes can be used.
Read more →

PHP Script to Generate PostgreSQL Table Partitioning (Part 2)

As Part 1 (Howto create PostgreSQL table partitioning) shows, making of PostgreSQL partitioning needs a lot of SQL commands. So this Part 2 explains how SQL commands for PostgreSQL partitioning can be made with a simple PHP script. This example script make SQL for child tables, indexes, trigger function and parent table trigger. This example script can make PostgreSQL table partitioning with using Date ranges. Script can be configured with following configuration section:
Read more →

Hide Apache ServerSignature / ServerTokens / PHP X-Powered-By

By default almost all Apache installation shows sensitive server information with Apache version number, server operating system details, installed Apache modules, PHP-version and so on. Attackers can use this information when performing attacks. Some examples howto check server information that Apache sends Error page Use lynx $ lynx -head -mime_header http://www.ubuntu.com HTTP/1.0 200 OK Date: Fri, 20 Nov 2009 09:25:46 GMT Server: Apache/2.2.8 (Ubuntu) mod_python/3.3.1 Python/2.5.2 PHP/5.2.4-2ubuntu5.7 with Suhosin-Patch mod_ssl/2.
Read more →

CSS compression with own PHP class VS CSSTidy

It makes sense to optimize the site’s cascading style sheets (CSS), as it pages load faster, and it reduce the amount of data transferred, and just combining css files could significantly reduce requests to server. So users benefit from faster page loads and webmaster of the sites benefits from the cheaper price of the transferred data. I have used CSSTidy on many projects. And CSSTidy is very good tool for packing CSS and it can even fix CSS errors.
Read more →

Prevent the browsers to use old cached CSS and JS files

Browser cache is very useful when users download the same CSS and JS files multiple times. Some browsers, however, use the old CSS and JS files from the cache, even though they have been updated. This may lead to unpleasant situations, when the pages are displayed to the user with the wrong styles or pages will work incorrectly. Fortunately, these unpleasant situations is easy to avoid and let the browsers cache files as long as they are changed.
Read more →

Nano Text Editor and nanorc Tips and Tricks

Nano is easy to use and lightweight command line text editor for Linux and UNIX systems. Nano text editor can use either the default settings or improve settings with customized nanorc-file. Here are some tips that can improve the usability of Nano. Changes can be made to nanorc file, either locally or to all users or options can be used as command line options. First is good to check Nano compiled options, with command:
Read more →
Subscribe and follow: