Wednesday, November 19, 2008

Installing drupal 6.6 ,PHP ,Apache and MySql on Windows

In this tutorial ,I try to write exaclty the steps I passed through while installing Apache,MySql,PHP and druap for the first time on windows.


  1. Download Apache web server from http://httpd.apache.org/download.cgi
    ,for this tutorial I downloaded version 2.2.10 Win32 Binary without crypto (no mod_ssl)
    MSI Installer

  2. Run the installer , during installation I kept the default settings, the installation folder is
    "C:\Program Files\Apache Software Foundation\Apache2.2"

  3. For the Network Domain,Server Name and Administrator's Email Address I entered localhost,localhost and admin@localhost respectively

  4. Download and install MySql Community server from
    http://dev.mysql.com/downloads/

  5. Download and install MySql GUI Tools from
    http://dev.mysql.com/downloads/gui-tools/5.0.html
    , although these tools are
    not required but they make it easy to manage MySql Server

  6. Download PHP from http://www.php.net/downloads.php
    , for this tutorial I downloaded version 5.2.6 zip package

  7. Extract the PHP zip file into folder c:\php

  8. Add PHP folder to the system path

    • Right click on My Computer

    • Choose Advanced Tab

    • Click on Environment Variables button

    • From System variables , select Path

    • Click Edit

    • Add the folder where PHP is extracted (i.e. "c:\php") to the end of the Variable value

    • The Path Variable might look something like %SystemRoot%\system32;%SystemRoot%;C:\Program
      Files\MySQL\MySQL Server 5.0\bin;C:\php


  9. Restart your computer for the Path vaialbe to be reflected on the system

  10. Go to PHP installation folder ("c:\php") ,make a copy of php.ini-recommended and rename it to php.ini

  11. Edit php.ini

    • Set max_execution_time = 300 (line 303) , the default value is 30 but some drupal actions take longer time

    • Set display_errors = On (line 372), the default value is Off

    • Set display_startup_errors = On (line 377), the default value is Off

    • set extension_dir = ".\ext\" (line 536), this the folder where PHP extensions reside

    • Uncomment the following lines by removing the semicolon at the begining of each line ,to enable the corresponding extensions

      • ;extension=php_gd2.dll (line 661)

      • ;extension=php_mbstring.dll (line 668)

      • ;extension=php_mysql.dll (line 675)

      • ;extension=php_mysqli.dll (line 676)



  12. Edit httpd.conf found in "C:\Program Files\Apache Software Foundation\Apache2.2\conf"

    • To change your WWW root folder change DocumentRoot value (line 177) to your WWW root folder e.g. DocumentRoot "C:/wwwroot"

    • change <Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"> (line 204) to <Directory "C:/wwwroot">

    • To Enable mod rewrite

      • Uncomment the following line #LoadModule rewrite_module modules/mod_rewrite.so (line 116) by removing the hash at the begning of the line

      • inside tag <Directory "C:/wwwroot"> (line 204) , change AllowOverride None (line 224) to AllowOverride All


    • To Enable PHP

      • Inside tag <IfModule dir_module> line (238) change DirectoryIndex index.html to DirectoryIndex index.php index.html so index.php will be regonized as a default file

      • at the end of the file add the following lines


        #Enable PHP 5.2.6

        LoadModule php5_module "C:/php/php5apache2_2.dll"

        AddType application/x-httpd-php .php

        # configure the path to php.ini

        PHPIniDir "C:/php"



  13. Using MySql query browser create a new schema called "drupalDB"

  14. Download Drupal 6.6 from Drupal Download

  15. extract the downloaded file to c:\wwwroot\drupal

  16. Go to drupal installation folder ("c:\wwwroot\drupal") ,make a copy of default.settings.php and rename it to settings.php

  17. If settings.php is readonly make it writeable

  18. Open your briwser and go the url http://localhost/drupal/ click make a new drupal installation and follow the wizard


That's it Done

Wednesday, July 2, 2008

Singleton pattern in a multi-threaded C# application

This is piece of code will assure the creation of a single instance of the singleton class in a multi-threaded application and at the same time highly performing

public class Singleton
{
private static Singleton _instance;
private static readonly object syncObject = new object();

public static Singleton instance
{
get
{
if (_instance == null)
{
lock (syncObject)
{
if (_instance == null)
_instance = new Singleton();
}
}
return _instance;
}
}

}

Sunday, March 30, 2008

How my coding habits changed since 1990?

I start writing code since 1990 when I was in high school , today 18 years later when I think how my coding habits changed, I found three major events that effected the way I write code:
  • Introduction of design patterns by GOF
  • Introduction of garbage collector in Java and I need no more to free allocated memory
  • Introduction of Test driven development
other than this I think the way I write code remain the same wither I code in Java, C# , Ruby or whatever else

Monday, March 3, 2008

Advantages of Offshore development in Egypt

Egypt is a great place and I would like to point here to some advantages of doing offshore development in Egypt:

  • Large pool of technical skills
  • Egypt shares a time zone with many European countries, which make Egypt actually a near shore location
  • Egypt has a multilingual workforce
  • Familiarity with western culture

Thursday, January 31, 2008

My .Net development ToolBox

When I start developing .Net applications some years ago, most of the open source projects available today were beta and can't be used in real world applications so we had to develop a custom framework with lot of functionalities available today. but today its more feasible to use existing open source projects and currently my .Net toolbox consists mainly of the following open source projects:


  • NHibernate for ORM and data persistence
  • Log4Net for logging
  • NUnit for unit testing
  • Spring.Net for orchestrating the above modules and I mostly use Spring.Net Nhibernate integration and declarative transactions
  • MyGeneration for code generation and any routine tasks that requires code generation

Saturday, January 19, 2008

Successful development environment

Delivering successful software projects requires healthy software development environment. Among successful environments I have seen there are common practises independent of the methodology used, here I will try to summarize those point:

  1. Have a clear standards for Design,Coding , Database, Unit Testing , Security, Source Control , UI Design and any aspects relevant to your environment.
  2. Use software development framework
  3. Break project into Independent tasks as much as possible
  4. Minimize effort spend in maintaining UI and have clear separation between UI and business , poorly developed UI consume a lot of time maintaining it more then any other part of the application
  5. Start with small team of senior developers then increase the size of the team
  6. Use custom code generators for common task instead of copy and paste but make sure the generated code is maintainable
  7. Avoid bad developers if you have them get rid of them immediately
  8. Use ORM tools and minimize SQL statements
  9. Avoid using heavy project management tools , use the simplest tools
  10. Don't write documentation that no one will read
  11. Don't let developers got bored in long projects otherwise they will leave

Sunday, January 13, 2008

Books that influenced my software development career

Last night I was thinking about IT books that influenced my software development career and was of great value to me, I came up with this list of 11 books and as you can see there are nearly no books about recent programming languages and software tools on the list because I do think that these are only tools and any developer with the basic knowledge will take him maximum a week or two to learn any new programming language or tool. And from my experience once you are good at C++ you will learn any programming language easily.
Here is the list:

  1. Assembly Language Primer for the IBM PC & XT by Robert Lafore
  2. The Waite Group's Object-Oriented Programming in C++ Robert Lafore
  3. The Waite Group's C Programming Using Turbo C by Robert Lafore
  4. Computer Networks by Andrew S. Tanenbaum
  5. Modern Operating Systems by Andrew S. Tanenbaum
  6. Extreme Programming Explained: Embrace Change by Kent Beck
  7. Head First Design Patterns by Elisabeth Freeman , Eric Freeman, Bert Bates, Kathy Sierra
  8. Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, and John M. Vlissides
  9. Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development by Craig Larman
  10. Patterns of Enterprise Application Architecture by Martin Fowler
  11. Refactoring: Improving the Design of Existing Code by Martin Fowler, Kent Beck, John Brant, and William Opdyke