Technology, Social Media, Travel
RSS icon Email icon Home icon
  • Tuning LAMP Systems

    Posted on June 29th, 2008 John Berns No comments

    I have been on a website performance and scalability kick lately. I thought I would share some articles I have enjoyed on the topic.

    IBM Developer Works has a nice little two part series on Tuning Lamp Systems (pt 2).

    Then again, IBM Developer Works often has some awesome articles. Scan it regularly if you can!

    Enjoy!

  • Compiling PHP5 with Mysql and Mysqli Database Drivers

    Posted on October 30th, 2005 John Berns 13 comments

    NOTE: This blog post was written in 2005 and worked for PHP 5.0.x versions. Things might have changed–I cannot vouch for this method working on recent versions of PHP. (Hopefully, they have made it easier to support mysql and mysqli simultaneously!)

    For years, the mysql library has been the standard for PHP development and a lot of great apps have been built running PHP and mysql. Now, with PHP5 there is a new database extension called mysqli that stands for “MySQL Improved.”

    So what’s so great about mysqli? Why switch to mysqli?

    The answer is simple: PHP5’s new mysqli database driver kicks ass.

    However, for those of you looking for more solid justifications to present to a boss or a client, let me outline the reasons in a more quantifiable manner:

    • An object-oriented interface.
    • Support for the new MySQL binary protocol that was introduced in MySQL 4.1. (The new protocol is more efficient that the old one and allows for the support of a broader range of features, such as prepared statements.)
    • Support for the full feature set of the MySQL C client library, including the ability to set advanced connection options via mysqli_init() and related functions.
    • Support for additional tracing, debugging, load balancing and replication functionality.
    • Greater speed. Enhancements in both the extension and in MySQL have made most operations faster, with certain operations becoming up to 40 times faster as compared to ext/mysql.
    • Better security. In older versions of the MySQL RDBMS, the possibility existed for an attacker to extract weak password hashes from the network and then recreate a user’s password. The new authentication procedure is much more robust and mirrors the attack-resistant authentication procedure of tools like SSH.

    If mysqli is so great, then why isn’t everybody using it?

    The reality is there is a lot of code out there based on the mysql extension; you might be running blogging software (like WordPress as I am) that does not run under mysqli, you might have legacy code that you don’t want to go through the expense of updating, you might have other apps hosted on the server that require mysql (Mambo, Joomla, MediaWiki, WordPress to name a few).

    Correction: Mambo does work with mysqli, thanks for pointing that out Nikos! Joomla is a fork of Mambo and also supports mysqli.

    The good news is that mysqli and mysql can peacefully co-exist on the same server: you can let the exisitng code run under mysql and start to develop new code with mysqli.

    Here’s how you can set up PHP5 with both mysqli and mysql enabled.

    When you run the configure command (step 10 in the PHP installation instructions if you are reading he guides mentioned above) use the following:

    ./configure --with-mysql=/usr –with-mysqli=/usr/bin/mysql_config

    Notice that the =’some directory’ is different for mysql and mysqli–this is as it should be!

    The locations of the directories might vary on the system you are using, so, from the command line run:

    slocate mysql_config

    On a RedHat / Fedora install the response you will get is:

    /usr/bin/mysql_config

    That the directory for mysql_config and the path that goes after “–with-mysqli=�?, the path that goes after “–with-mysql=�? is /usr (or whatever is two directories above mysql_config).

    Now, here is the trick: this configure command actually generates a bad makefile, so use a text editor and open up the file called “Makefile�? and look for a line that starts with EXTRA_LIBS such as:

    EXTRA_LIBS = -lcrypt -lcrypt -lmysqlclient -lpng -lz -lz -lresolv -lm -ldl -lnsl -lxml2 -lz -lm -lxml2 -lz -lm -lmysqlclient -lcrypt -lnsl -lm -lz -lnss_files -lnss_dns -lresolv -lnss_files -lnss_dns -lresolv -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lcrypt

    You will notice that the term “-lmysqlclient�? is in there twice. Delete one of them and save the Makefile

    With this little tweak, when you run “make�? it PHP5 should compile just fine–and support both mysql and mysqli.

    That’s it!

    More Info: