Unix How to Install Apache, MySQL, PHP, and phpMyAdmin on FreeBSD

1 Comment

(1.16.12 – This post has been amended to correct the port used for installing PHP, and to reflect changes in the 9.0-RELEASE of FreeBSD — iceflatline)

This post will describe how to install and configure Apache, MySQL, PHP and phpMyAdmin on FreeBSD for basic local web development. Once set up, you’ll be able to use your “AMP” server to do web development, code testing, maintain local copies of your web sites, etc.

The software discussed in this post are available as free and open source under various licensing structures. The versions of software discussed in this post are as follows:

  • FreeBSD 9.0-RELEASE
  • apache-2.2.21
  • mysql-server-5.5.20
  • php5-5.3.9
  • php5-extensions-1.6
  • phpMyAdmin-3.4.9
  • WordPress v3.3.1
  • The following steps discussed in this post assume you have the FreeBSD Ports Collection installed. If not, you can install it by using the following commands:

    portsnap fetch
    portsnap extract
    

    If the Ports Collection is already installed, make sure to update it:

    portsnap fetch update
    

    Okay, let’s get started. All commands are issued as the root user or by simulating the root user by using the command su. While building the various ports you should accept all default configuration options unless otherwise instructed.

    Install Apache

    Navigate to the Apache server port and build it:

    cd /usr/ports/www/apache22
    make install clean
    

    Once Apache has been successfully installed, add the following line to /etc/rc.conf so that the Apache server will start automatically at system boot.

    echo 'apache22_enable="YES"' >> /etc/rc.conf
    

    Now let’s start Apache to make sure it works:

    /usr/local/etc/rc.d/apache22 start
    

    Point your web browser to the host name or IP address of the FreeBSD host you’ve installed Apache on and you should see the venerable “It Works.”

    Install MySQL.

    Now let’s build the MySQL server:

    cd /usr/ports/databases/mysql55-server
    make install clean
    

    Add the following line to /etc/rc.conf:

    echo 'mysql_enable="YES"' >> /etc/rc.conf
    

    And start the mysql server:

    /usr/local/etc/rc.d/mysql-server start
    

    Then set a password for the MySQL root user:

    /usr/local/bin/mysqladmin -u root password 'your-password'
    

    Install PHP

    Next, we’ll build PHP. Before we proceed, however, we need to add a configuration option so that PHP build includes support for the Apache server. Start with the following commands:

    cd /usr/ports/lang/php5
    make config
    

    A menu should come up allowing you to select/deselect various build options. You should select “Build Apache module” by highlighting the option with the arrow keys and hitting the space bar, then use the tab key to highlight “OK” and hit Enter, which should bring you back to the command prompt. Now proceed with building the port:

    make install clean
    

    Now let’s add the requisite extensions to PHP to round out its capabilities. Before we build this port though we’ll want to add support for MySQLi, an improved interface for PHP to communicate with the MySQL server.

    cd /usr/ports/lang/php5-extensions/
    make config
    

    In the corresponding menu you should select “MySQLi database support,” then proceed with building the port:

    make install clean
    

    Install phpMyAdmin

    phpMyAdmin is a free software tool written in PHP intended to handle the administration of MySQL from your web browser. phpMyAdmin supports a wide range of operations with MySQL, including managing databases, tables, fields, relations, indexes, users, permissions, etc., from an easy-to-use web page, while you still have the ability to directly execute any SQL statement from the command line if you prefer. Installing phpMyAdmin is optional but it’s nice tool to have. Here again we’ll want to add support for MySQLi before building the port:

    cd /usr/ports/database/phpmyadmin/
    make config
    

    Here you should select “Improved MySQL support,” then proceed with building the port:

    make install clean
    

    Configuration

    Now that we have the requisite ports built and installed it’s time to configure them. First, let’s create the file /usr/local/etc/php.ini to hold our PHP options. The simpliest way to do this is to copy the file /usr/local/etc/php.ini-development which will add the default settings for new PHP installations. This configuration is suitable for development purposes, but NOT necessarily for production purposes. If your plans include a production server, then among other things, and before going online with your site, you should consider copying /usr/local/etc/php.ini-production instead and consult the recommendations at http://php.net/manual/en/security.php.

    cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini
    

    Now let’s configure Apache. Open the file /usr/local/etc/apache22/httpd.conf in your favorite editor and look for the following line:

    DirectoryIndex index.html
    

    And change it so it reads as follows:

    DirectoryIndex index.html index.htm index.php
    

    Then append the following lines to the end of the file in order to support PHP files as well as phpMyAdmin, which normally lives outside of the Apache document root. Note: if you elected not to install phpMyAdmin, then you need only add the two AddType lines:

    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    
    Alias /phpmyadmin "/usr/local/www/phpMyAdmin"
    
    <Directory "/usr/local/www/phpMyAdmin">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
    </Directory>
    

    As an optional step, if you’d like to add multilanguage support to Apache, uncomment the following line:

    Include etc/apache22/extra/httpd-languages.conf
    

    Then open the language settings file /usr/local/etc/apache22/extra/httpd-languages.conf and add the following line to the end of the file:

    AddDefaultCharset On
    

    Now restart Apache:

    /usr/local/etc/rc.d/apache22 restart
    

    That’s it for our Apache configuration. Now let’s configure phpMyAdmin. We’ll do this by creating the file /usr/local/www/phpMyAdmin/config.inc.php, the basic configuration file for phpMyAdmin. Traditionally, users have manually created config.inc.php, but now phpMyAdmin includes a nice setup script, making it much easier to create this file with the settings you want. Start by creating the directory /usr/local/www/phpMyAdmin/config and make it writable by phpMyAdmin:

    mkdir /usr/local/www/phpMyAdmin/config && chmod o+w /usr/local/www/phpMyAdmin/config
    

    Then open your web browser and navigate to http://your-hostname-or-IP-address/phpmyadmin/setup where you will see the phpMyAdmin setup Overview page. Select “New server” and then select the “Authentication” tab. Under the “Authentication type” choose “http” from the drop-down list (using HTTP-Auth to sign-in into phpMyAdmin will avoid storing login/password credentials directly in config.inc.php) and remove “root” from the “User for config auth”(See Figure 1).

    Screenshot of the phpMyAdmin setup page

    Figure 1

    Now select “Save” and you will be returned you to the Overview page where you should see a new server listed. Select “Save” again in the Overview page to save your configuration as /usr/local/www/phpMyAdmin/config/config.inc.php. Now let’s move that file to /usr/local/www/phpMyAdmin where phpMyAdmin can make use of it.

    mv /usr/local/www/phpMyAdmin/config/config.inc.php /usr/local/www/phpMyAdmin
    

    Now let’s try out phpMyAdmin to make sure it works. Point your web browser to http://your-hostname-or-IP-address/phpmyadmin where you will be presented with a pop-up box requesting you to log in. Use “root” and the MySQL password you set up previously, then you should be directed to the phpMyAdmin administration page. We no longer need the /usr/local/www/phpMyAdmin/config directory so let’s remove it and wrap up by restarting the Apache and MySQL servers:

    rm -r /usr/local/www/phpMyAdmin/config
    /usr/local/etc/rc.d/apache22 restart
    /usr/local/etc/rc.d/mysql-server restart
    

    Testing our installation using WordPress

    WordPress is a full-featured website/blog platform that makes heavy use of Apache, MySQL and PHP. We’ll install it on our newly created implementation to ensure we have these packages installed and working correctly. Once again, all commands are issued as the root user or by simulating the root user using the command su. Let’s start by downloading the latest WordPress directly from the developers site to your home directory and untarring the package:

    fetch http://wordpress.org/latest.tar.gz
    tar -zxvf latest.tar.gz
    

    You should now see the new directory wordpress in your home directory. Next we need to create the file ~/wordpress/wp-config.php and make some changes to it so WordPress can access the MySQL server. First, let’s copy the file ~/wordpress/wp-config-sample.php to use as a template:

    cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php
    

    Open ~/wordpress/wp-config.php in your favorite editor and enter the database name as well as your MySQL login and password in the appropriate lines. When complete, it should look like the following:

    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('DB_NAME', 'wordpress');
    
    /** MySQL database username */
    define('DB_USER', 'root');
    
    /** MySQL database password */
    define('DB_PASSWORD', 'your-mysql-password');
    

    Now move the wordpress directory to Apache’s document root:

    mv ~/wordpress/ /usr/local/www/apache22/data/
    

    Next, let’s create an MySQL database for our WordPress installation. Open phpMyAdmin in your browser and create a database by selecting the “Databases” tab at the top. Enter a name for it in the “Create a new database” field. For purposes of our example, I’ll use “wordpress” as the database name. You’re free to use a different database name, just make sure to use the same name in the define(‘DB_NAME’, ‘your-DB-name’); line in ~/wordpress/wp-config.php as described above. Then select “Create.”

    Now let’s run the WordPress script that will populate its database with the requisite tables. Open your web browser and navigate to http://your-hostname-or-IP-address/wordpress/wp-admin/install.php. If everything is configured correctly you should see the WordPress installation wizard page (See Figure 2). Enter a title for your site, username, password, and an e-mail, then select “Install WordPress.” Then login with your newly created WordPress credentials and you should be presented with the default WordPress administration page.

    Screenshot of WordPress installation page

    Figure 2

    Common problems

    You may run into the following error when attempting to build the Apache port:

    httpd-2.2.21.tar.bz2 doesn't seem to exist in /usr/ports/distfiles/apache22.
    => Attempting to fetch http://www.apache.org/dist/httpd/httpd-2.2.21.tar.bz2
    fetch: httpd-2.2.21.tar.bz2: local file (7229347 bytes) is longer than remote file (5324905 bytes)
    
    => port manually into /usr/ports/distfiles/apache22 and try again.
    *** Error code 1
    

    To fix this problem, simply remove the file from /usr/ports/distfiles/apache22 (in this case httpd-2.2.21.tar.bz2) and run make config clean again.

    Another error that occasionally pops up when attempting to start the Apache server is the following:

    httpd: apr_sockaddr_info_get() failed for <some-host-name>
    httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
    /usr/local/etc/rc.d/apache22: WARNING: failed to start apache22
    

    This can be fixed by adding a line to /etc/hosts. First, verify your hostname by running the hostname command:

    hostname
    

    Then add the following to /etc/hosts:

    hostname   IP-address-of-your-freebsd-box
    

    Finally, 403 permission problems seem to frequently pop up when trying to access phpMyAdmin. This is usually caused by errors in the way either the Alias or Directory Apache directives for phpMyAdmin have been written in /usr/local/etc/apache22/httpd.conf. As an example, a missing “/” in the Alias statement cost me two hours of troubleshooting time!

    Conclusion

    Well, that’s it. A few hours of your time with the FreeBSD Ports Collection and you can a get a fully configured “AMP” web development server up and running on your FreeBSD box.

    References

    http://caffetine.org/freebsd-amp.php

    Tags: , , ,

    Hardware PC Build: Intel Core i7 Sandy Bridge

    0 Comments

    Recently I decided it was time to upgrade my main desktop computer. My current system, featuring an Intel DP55KG motherboard (P55 Chipset/Socket 1156), Intel Core i7-860 (Lynnfield) processor, AMD Radeon HD 5870 GPU, and 8 GB of DDR3-1600 Mushkin RAM, had served me well, but I was anxious to give Intel’s “Sandy Bridge” architecture a try. This post will document my upgrade, starting with the parts I selected and why; the assembly of the system and the challenges I encountered; and finally, a few thoughts on overclocking the upgraded system.

    The Parts

    As I stated in my previous posts concerning my Lynnfield build, I’ve built a good many PCs over the years. My goal now, as it was then, was to use the best quality components I could find for a low price, and build a good, fast, and reliable machine. In other words, build a machine that’s a good value.

    The Case – Thermal management in Intel processors have progressed to the point where unless you’re planning on doing some serious overclocking there’s really no reason to consider using water cooling over a good air cooling solution. Consequently, I was looking for a mid-tower case with good air flow. Since the NZXT Tempest case I used for my Lynnfield build had served me well in this regard, I decided to go with the next generation of this case, the NZXT Tempest Evo. Among other things, this case features dual 120mm intake and 140mm exhaust fans, with an additional side 120mm fan and rear 120mm fan, making it one of the better cases for air cooling. Another nice feature that was added to this case is a slightly wider side panel design, thus increasing the available space behind the motherboard for cable routing, as well as a punchout behind the processor so one doesn’t have to completely remove the motherboard from the case in order to replace the heatsink and fan.

    The Power Supply – I’ve almost exclusively used power supplies from two manufacturers: Fortron for lower cost builds and PC Power & Cooling for nearly everything else. This time however, I decided to go with the Corsair TX750. This is a slightly less expensive unit than a comparable one from PC Power & Cooling, but Corsair does maintain quality products and this unit still features a dedicated, single +12V rail for maximum and efficient power distribution.

    The Processor – With Sandy Bridge Intel launched with no less than 29 different SKUs (15 for mobile and 14 for desktop) once again presenting a very challenging decision for the gamer/enthusiast building a new desktop system. After doing some research and giving it much consideration, I chose the Intel Core i7-2600k processor with a 3.4 GHz core clock, 8 MB of L3 cache and hyper-threading. Besides the featuring the highest core clock among the Sandy Bridge desktop processors, the “K” suffix means the “turbo mode” multipliers, from 16x all the way up to 57x, are fully unlocked, giving this processor a lot of overclocking potential.

    The Motherboard – I’ve traditionally used ASUS motherboards but then began to run into reliability problems with them over the years. I also grew tired of the growing list of “features” their boards began to offer that I had no use for on my desktop machines (e.g. WiFi, Bluetooth, etc.), resulting in time spent maintaining drivers for these features or trying to disable them altogether. For my Lynnfield build I used Intel’s DP55KG and really liked it. No it didn’t have all the features and overclocking capabilities of say an ASUS or Gigabyte motherboard at the time, but it turned out to be sufficiently overclockable for my needs and has been 100% reliable. However, The Sandy Bridge processor ushered in yet one more socket change by Intel, Socket 1155, taking the option to use my existing Socket 1156-based Intel DP55KG motherboard off the table. Even so, given my overall good experience with Intel motherboards, I initially decided to go with them again for this build and chose their DP67BG. However, no sooner had this board arrived than Intel announced that they had discovered a design error in the P67 chipset. In some cases, the Serial-ATA (SATA) ports within the chipset may degrade over time, potentially impacting the performance or functionality of SATA-linked devices such as hard disk drives and DVD-drives. Since I had just purchased the product I returned it as defective for a full refund. Then I waited for Intel to roll out the next (so called “B3″) version of this board. Unfortunately that day never came, and Intel showed no sign that they would upate this product, so I once again looked to ASUS to meet my needs and ended up selecting their Sabertooth P67 board, my first I should add that featured a Unified Extensible Firmware Interface (“UEFI”). I also purchased a small 50 mm fan from Evercool to help improve upon the board’s “TUF Thermal Armor” cooling capabilities.

    The Heatsink – I chose the Cooler Master Hyper 212 after doing a bit a research to make sure it would clear the surrounding components on the motherboard, including the RAM. To improve its already very good cooling capabilities, I purchased an additional 120 mm fan from Cooler Master that matched the fan the product shipped with and set it up in a push/pull configuration. This fan configuration combined with the NZXT case should provide excellent overall processor cooling. Finally, to ensure that both fans would rotate at reasonably the same speed, I used a PWM splitter from Rosewill to power and control both fans from the processor fan header.

    The RAM – I was looking for an 8 GB DDR3-1600 dual kit (2 x 4 GB) with the timings as low as possible. Another factor that I was glad I considered ahead of time was whether the RAM would fit under the processor’s fan/heatsink due to the close proximity of the RAM slots to processor. I ended up eliminated a couple of products (Corsair’s “Dominator” as an example) because they were too tall to fit. I ended up selecting G.Skill’s RipjawsX DDR3-1600 8 GB dual kit, which runs at 1.65v with timings that spec at 7-8-7-24-2N. I had heard and read good things about G.Skill memory and was anxious to finally have the opportunity to give one of their products a try.

    The Graphics – I have no particular allegiance to either AMD or Nvidia and was willing to go with a product from either depending on its price versus performance. I ended up going with AMD this time around and chose the MSI R6950 Twin Frozr II OC. For ~$290, I felt it provided the best performance for the money.

    The Hard Drives – When I built my Lynnfield-based rig, solid state drive (SSD) prices were still relatively high compared to conventional spindle drives and firmware support for features like “trim” so fluid I decided to stick with with my trusty Western Digital “Raptor” drives. SSD prices have since dropped and trim support is now fully implemented so I decided it was time to upgrade. While I wanted to spring for a new SATA revision 3.0 (SATA 6 Gb/s) drive, I could not justify the cost at this time, so I chose instead the OCZ Vertex 2 80 GB SATA revision 2.0 (SATA 3 Gb/s) SSD. This will serve as my system drive, and a Western Digital Caviar Black 1TB 7200 RPM 64MB cache SATA 3.0 drive will hold my data.

    The Optical Drive – Believe it or not I actually still use one of these :). I didn’t spend much time shopping for it though, instead I went to Newegg, navigated to CD/DVD Burners, selected “Best Rating” from among the search options, and dutifully paid for the ASUS DRW-24B1ST.

    The Operating System – Not much of a surprise here, I went with Windows 7 Pro 64-bit. Why the Pro version instead of Home Premium? Remote Desktop. Home Premium doesn’t support it and I need this feature so I can access this machine remotely. Why Windows and not Linux? Games. I’m a PC gamer and this is my gaming rig (there are many like it but this one’s mine…). Someday perhaps computer gaming on *nix-based systems will be a viable option. No one hopes that day will will come more than I do, but it’s not today.

    The Build

    With the component selection and purchase out of the way it was time to put them all together. I like to build systems outside of the the case. Then, when I’m sure everything is running well, I’ll place the components in the case and dress up the wiring (See Figure 1).

    Screenshot of my Core i7 Sandy Bridge build outside of the computer case

    Figure 1

    The SATA 2.0 and SATA 3.0 ports are mounted horizontally, facing the back of the case, instead of vertically, making it much easier to connect/disconnect disk drives with the graphics card in place. I placed the 80 GB OCZ Vertex 2 drive, which will hold the operating system, on the P67 controller’s SATA 3.0 GB port 1, and the 1TB WD Caviar Black drive on the SATA 3.0 port 2. These are the Brown SATA ports on the ASUS Sabertooth P67 motherboard.

    The Sabertooth P67 is equipped with what ASUS calls “TUF Thermal Armor,” a rather fancy term for what is essentially a heatsink that encompasses nearly the entire motherboard. The idea behind this somewhat unorthodox design is to conduct the hot air generated by cards and components out of the case through special air flow channels, thus reducing the overall temperature of the motherboard, and by extension the inside the the PC case. To do this effectively, however, ASUS recommends that system builders use a processor fan that directs air downward into the motherboard. Unfortunately, like most processor fan/heatsink products made for the PC enthusiasts market, the Cooler Master Hyper 212 Plus is mounted vertically, directing air out the back of the case, not downward towards the motherboard’s components. In anticipation of the situation, ASUS provides a spot on the motherboard that allows one to mount a small 50mm “assistant” fan, in order to improve the air flow through the TUF Thermal Armor (See Figure 2).

    Screenshot of the 50 mm fan from Evercool installed on the ASUS P67 motherboard

    Figure 2

    After successfully assembling the components, and firing up the system without issue, I proceeded to update the P67 Sabertooth’s UEFI firmware to the latest version. Fortunately ASUS makes updating the firmware incredibly easy, offering a number of ways to perform the task, including directly from Windows. The one that worked best for me was to perform the update directly from within the UEFI. First, I inserted a USB drive contained the latest UEFI ROM file into a USB port. Then I entered the “Advanced Mode” of UEFI, navigated to the “Tool” menu, and selected “ASUS EZ Flash Utility.” I highlighted the USB drive containing the ROM file and selected “Enter” to proceed with the UEFI firmware update.

    With updated UEFI firmware now place, it was time to explore the UEFI settings, ensuring that my drives were detected correctly, disabling unwanted features, etc. One issue I noticed fairly quickly was that my processor temperature was idling at ~42C at a room temperature of ~21C, a little hotter than what I would expect when using the Cooler Master Hyper 212 Plus. It should be noted here that on the P67 Sabertooth, the processor temperature reading in the UEFI can be anywhere between ~5C – ~10C higher than in Windows. That’s normal as the UEFI does not send idle commands to the processor, as is the case when the OS is running. Investigating this issue further led me to this Benchmark Reviews article discussing the best thermal paste application methods for heat-pipe direct touch coolers. After a bit of experimentation, I obtained the lowest processor temps using my Cooler Master Hyper 212 Plus by applying two thin lines of Artic Silver 5 thermal compound to the two center mounting base partitions (See Figure 3), lowering my processor temps to ~37C in UEFI and ~31 when measured from within Windows using Real Temp.

    Screenshot showing where to apply thermal compound on the Cooler Master Hyper 212 plus heatsink

    Figure 3

    Windows Professional (x64) installed without issue on the OCZ Vertex 2 drive, but this is where my progress came to a temporary halt. One of the first applications I typically install shortly after I finish installing the OS is CPU-Z in order to evaluate processor core stepping and core voltage; internal and external processor clocks and clock multipliers; and memory frequency and timings. CPU-Z showed that the processor multiplier was “stuck” at 1.6 GHz (multipler = 16x), never allowing the processor to rise to its specified default operating frequency of 3.4 GHz (multiplier = 34x) or its default Turbo mode frequency of 3.8 GHz (multiplier = 38x). After trying numerous UEFI tweaks, I gave up and concluded that the board was defective. The replacement board was received a week or so later and after reassembling the requisite parts it worked as designed.

    Another issue I encountered involved updating the firmware on the OCZ Vertex 80 GB drive to the most recent version – 1.33 at the time of this post. The OCZ Toolbox firmware update tool did not see the SSD drive because the tool is currently incompatible with the Intel Rapid Storage Technology (“RST”) driver software – V10.0.0.1046 at the time of this post. The work around for this problem was to remove the Intel RST driver, update the firmware, then reinstall the Intel RST driver. Incidentally, I took the opportunity to run a few benchmark tests against this drive using ATTO Disk Benchmark and came away with the 272 MB reads and 258 MB writes (128 KB transfer size).

    With all of the device drivers installed Window’s Device Manager was still indicating that a driver for the “PCI Simple Communications Controller” was still missing (The dreaded yellow exclamation mark). It turned out that I needed to download and install Intel’s Management Engine Interface utility from ASUS in order to clear that error.

    Finally, to improve the reliability of the P67 Sabertooth’s Wake on Lan feature, I decided to download and install the Intel drivers for the Sabertooth P67′s 82579V Ethernet network interface controller. Then, I entered the UEFI’s Advanced mode, navigated to Advanced -> APM and enabled “Power On By PCI.”

    With these issues out of way I continued on, updating Windows, adding applications, tweaking options and generally letting the system burn-in for a bit. Then it was time to move on to overclocking the system.

    The Overclock

    With the advent of Intel’s “Turbo Mode” feature starting in its Nehalem “Bloomfield” processor, the Base Clock (BCLK) multiplier value was able to automatically increase beyond its default value if the processor was operating within what the design considered to be a safe temperature tolerance. For example, in the Bloomfield architecture, processors were allowed to raise the stock multiplier value by 1 or 2 depending on the number of cores being used so long as the processor’s core temperatures did not rise beyond an arbitrary threshold. Intel’s Lynnfield processors generally ran cooler and so were allowed to be considerably more aggressive with Turbo Mode, increasing Turbo Mode multipliers within a range of ~2-5. In practice what this meant was that when fewer processor cores were in demand by a given application or process, larger multiplier values were used, thus allowing the processor to temporarily run at a higher clock rate than the default multiplier would normally allow. In the case of my Core i7 860 for example, with its BCLK of 133 MHz, it was not uncommon to see it use a multiplier value of 26 in single-threaded applications, yielding a processor speed of 3.46 GHz, well above its stock speed of 2.8 GHz when using the default multiplier of 21.

    Consequently, when it came to overclocking, the Lynnfield architecture offered the user somewhat of a choice. You could attempt to overclock the system with Turbo Mode enabled, requiring you to be mindful of the headroom necessary when higher turbo multiplier values kicked in, or you could simply disable Turbo Mode and go with the more traditional overclocking approach. Either way, the steps were similar: adjust the BCLK to achieve your desired processor frequency; adjust the memory multiplier to compensate for the change in BCLK; and, if necessary, adjust the processor voltage, memory voltage, and Uncore voltage to stabilize the system; rinse and repeat.

    The new Sandy Bridge technology, however, is a bit more challenging when it comes to overclocking. The new 100 MHz BCLK of Sandy Bridge processors doesn’t give users a lot of latitude in terms of increasing its value. If you’re lucky you can get it to run reliably at say 110 MHz. Multiply that value with your maximum Turbo Mode multiplier value, 38 in the case of the Core i7 2600K, and you’ll achieve ~4.2 GHz. Fortunately, with the K series processor, your overclocking options aren’t limited by the BCLK value; you’re also offered an unlocked multiplier ranging from 34 to 57, allowing you to potentially reach much higher processor speeds when operating in Turbo Mode.

    Not unlike most of the “enthusiasts” motherboards on the market today, the Sabertooth P67 offers a method to automatically overclock your system, dispensing with the need in most cases to independently adjust BCLK, memory and voltage settings. In fact, the Sabertooth P67 offers two methods: one is available by navigating to the in the UEFI’s “EZ Mode” settings and selecting the “Performance” option. The other is available by navigating to Advanced Mode -> Ai Tweaker and selecting “OC Tuner.” I decided to give the EZ Mode Performance option a go and was quite happy with the results (See Figure 4).

    Screenshot of the ASUS Sabertooth P67 Ai Tweaker settings after invoking the "Performance" option in EZ Mode

    Figure 4

    The BCLK was increased to 103 MHz and the Turbo Mode multiplier for all four cores to 43. This resulted in an overall processor speed of ~4.4 GHz when running in Turbo Mode. My DDR3-1600 memory settled at a speed of 1648 MHz. None of this is going to set any overclocking records, but you know what? It’s plenty fast for me for the time being, with plenty of headroom to make further increases at a later time if desired.

    Next, I adjusted my memory timings to the 7-8-7-24 and ran Memtest86+ for a couple of passes to ensure those timings were stable. Then I ran the 64-bit version of Prime 95 using the “Large in-place FFT” setting for ~24 hours to ensure that the system stability and maximum processor core temperatures were kept in check. I should note that ambient room temperature during the Prime 95 testing was ~21 C. The tests resulted in no errors and the maximum processor core temperatures were ~65 C. (See Figure 5).

    Screenshot of my desktop showing Prime 95, CPU-Z and Real Temp running simultaneously

    Figure 5

    Conclusion

    Intel’s Core i7 2600K processor and ASUS’s Sabertooth P67 motherboard turned out to be a good mid-range combination. Throw in the MSI R6950 Twin Frozr II graphics card and the 8 GB DDR3-1600 dual kit from G.Skill and I couldn’t be more pleased with the results of my first Sandy Bridge build. Since its completion, the system has been 100% stable. Future plans for this system likely include replacing the 80 GB SATA 2.0 drive with a SATA 3.0 drive, and of course do a bit more overclocking.

    References
    http://support.asus.com/Search.aspx?SLanguage=en&keyword=sabertooth%20p67&ps=10&pn=1

    Tags: ,

    Code How To Fix Duplicate Title and Meta Tags When Spanning Multiple Home Pages In WordPress

    1 Comment

    This post describes how to fix duplicate meta and title tag content when spanning mulitple home pages in WordPress. This isn’t a topic I normally cover here at iceflatline.com, but after searching for a solution to this problem for this site and continually encountering advice such as just add a plugin, I decided to post how I fixed this problem without encumbering my site with yet another WordPress plugin or other solutions that didn’t fully meet my requirements.

    The Problem

    Like each post here at iceflatline.com, my index or main “home” page contains its own unique description and keywords meta tags and title tag content. WordPress allows me to determine the number of posts displayed on my home page (I typically choose five). Once this limit is reached, my WordPress theme automatically generates an “Older Entries” link at the bottom of the page, allowing the reader to navigate to a another page containing the previous five posts, and so on. While this is a helpful navigation feature for the reader, to a search engine like Google it’s another URL that contains the same meta and title tag content as that of the main home page. For example, I use the following content for my home page description and keywords meta tags:

    <meta name="description" content="Here at www.iceflatline.com you will find how-tos, tutorials, tips, guides, news, reviews and commentary for users of Linux, Unix and Windows">
    
    <meta name="keywords" content="howto, install, configure, setup, server, review, games, network, ubuntu, crunchbang, fedora, linux, unix, windows">
    

    Left unchanged, however, each Older Entries link will also contain the same description and keywords content. Consequently, tools like Google’s Webmaster Tools will complain that it has detected duplicate meta descriptions. This issue likely won’t prevent your site from appearing in search results, but paying attention to it can provide Google and other search engines with more information and help drive traffic to your site.

    The Solution

    To fix the problem of duplicate meta and title content I added a bit of PHP code to my theme’s header.php file. When a reader of iceflatline.com uses the Older Entries link to view a page containing its previous five posts, this code will automatically prepend or append a page number to the contents of these tags so that the metadata in each of these pages appears unique to the search engine. The page numbering starts with 2 and increments each time the reader navigates to a previous page.

      Duplicate Meta Tag Content

    To eliminate duplicate description and keywords meta tag content, I added the following PHP code to my theme’s header.php file:

    <?php if(is_home()) {
    echo '<meta name="description" content="';
    if ( $paged < 2 ) {
    } else {
    echo 'Page ' . ($paged) . ' | ' ;
    }
    echo 'Here at www.iceflatline.com you will find how-tos, tutorials, tips, guides, news, reviews and commentary for users of Linux, Unix and Windows"/>';
    }
    ?> 
    
    <?php if(is_home()) {
    echo '<meta name="keywords" content="';
    if ( $paged < 2 ) {
    } else {
    echo 'Page ' . ($paged) . ' | ' ;
    }
    echo 'howto, install, configure, setup, server, review, games, network, ubuntu, crunchbang, fedora, linux, unix, windows"/>';
    }
    ?>
    

    Now when someone clicks on Older Entries the description and keywords meta tag content will be prepended with a page number so that it looks like this:

    <meta name="description" content="Page 2 | Here at www.iceflatline.com you will find how-tos, tutorials, tips, guides, news, reviews and commentary for users of Linux, Unix and Windows"/>
    
    <meta name="keywords" content="Page 2 | howto, install, configure, setup, server, review, games, network, ubuntu, crunchbang, fedora, linux, unix, windows"/>
    

    If desired, the following variations of the code above will append the page numbers instead:

    <?php if(is_home()) {
    echo '<meta name="description" content="Here at www.iceflatline.com you will find how-tos, tutorials, tips, guides, news, reviews and commentary for users of Linux, Unix and Windows.';
    if ( $paged < 2 ) {
    } else {
    echo (' | ' . 'page ');
    echo ($paged);
    }
    echo '"/>';
    }
    ?> 
    
    <?php if(is_home()) {
    echo '<meta name="keywords" content="howto, install, configure, setup, server, review, games, network, ubuntu, crunchbang, fedora, linux, unix, windows';
    if ( $paged < 2 ) {
    } else {
    echo (' | ' . 'page ');
    echo ($paged);
    }
    echo '"/>';
    }
    ?>
    
      Duplicate Title Tag Content

    To eliminate duplicate title tag content, I appended the following PHP code to the tag’s existing contents in my theme’s header.php file:

    if ($paged < 2 ){
    }else{
    echo (' | ' . 'page ');
    echo ($paged);
    }
    

    Combined with the original code, the revised PHP code within the title tags now looks like this:

    <title><?php wp_title(' ');
    if(wp_title(' ', false)){
    echo ' | ';
    }
    echo bloginfo('name');
    if ($paged < 2 ){
    }else{
    echo (' | ' . 'Page ');
    echo ($paged);
    }
    ?></title>
    

    Now when someone clicks on Older Entries the title description will be appended with a page number so that it looks like this:

    <title>iceflatline | Page 2</title>
    

    Conclusion
    There ya have it. A bit PHP code and I fixed these nagging problems, and saved myself the hassle of having to update and manage yet another WordPress plugin or use some other solution that didn’t fully meet my needs.

    Tags: ,

    Unix Using xargs

    0 Comments

    Recently I decided to update and re-tag my music collection, which had suffered at the hands of the untrained and uncaring for far too long. The album art in particular, comprised of various jpg files and scattered throughout the numerous artist and album directories, was incomplete and/or inaccurate. I decided I needed a way to quickly and efficiently remove this old album art before starting the re-tagging process. Enter xargs, a handy little utility in Linux and Unix operating systems used to construct a list of arguments for an arbitrary Linux or Unix command. xargs is a good companion for commands like find, locate and grep that output long lists of files. The general syntax for the xargs command is as follows:

    xargs [option...] [command [initial-arguments]]
    

    Let’s take the case of the my superfluous jpg files to see how xargs might be used in practice. We’ll start by opening a terminal and using the find command to locate these jpg files. This following command should find files ending with “.jpg” anywhere within my music directory, including sub-directories, and list them to the terminal:

    find ~/music -name "*.jpg"
    

    By the way, in this particular example I’m passing along a directory to the find command that I know in advance I have the appropriate permissions to access, in this case my home directory. However, depending on what you’re searching for and where, the find command may return “Permission denied” because it (or rather you) lack sufficient permissions to access certain directories and files. In those cases you’ll need to preface the find command with su or perhaps sudo in order to avoid these errors.

    Also be aware that the locate command offers similar capabilities to find, but instead of searching through the system’s directories and files, locate searches through a pre-built database of these directories and files. locate can produce significantly faster results using less computing resource compared to find, but requires the database to be updated regularly or else the results will be inaccurate and/or incomplete. Here’s an example of how to find our jpg files using the locate command:

    sudo updatedb
    locate ~/music/*.jpg
    

    Okay, let’s combine the find command we used before with xargs to quickly remove the jpg files:

    find ~/music -name "*.jpg" -print0 | xargs -0 rm
    

    In this example, the find command searches through my ~/music directory and pipes to xargs a list any files ending in “.jpg”. The xargs command then splits this list into sub-lists and calls the rm command once for every sub-list. The -print0 option in the find command prints the full file name on the standard output followed by a null character. This allows file names that contain newlines or other types of white space to be correctly interpreted xargs when it uses it’s corresponding -0 option. Using xargs is more efficient than this functionally equivalent version of the find command, which must call rm once for every single file it finds:

    find ~/music -name "*.jpg" -exec rm '{}' \;
    

    Want to copy these jpg files to another directory instead removing them? The following two examples demonstrate how xargs can be used to accomplish that:

    find ~/music -name "*.jpg" -print0 | xargs -0 cp -t ~/tmp
    
    find ~/music -name "*.jpg" -print0 | xargs -0 -I {} cp {} ~/tmp
    

    In the second example, the -I option tells xargs to replace the string {} with the argument list from the find command, in this case our list of jpg files. Note that not all versions of xargs support the {} syntax. No worries though, in those cases you can specify any string you’d like after -I; for example, the following variation replaces the string {} with x and will work just as well:

    find ~/music -name "*.jpg" -print0 | xargs -0 -I x cp x ~/tmp
    

    Here’s another use for xargs – systematically setting permissions for a large number of directories or files. When assigning reasonably secure permissions directories and files it’s common to give directories a permission of 755 and files a permission of 644. Since the command we’d normally use in this situation – chmod [some permission] -R /path/to/some_directory – will assign the same permission level to the directory and the files, let’s use xargs to assign permissions selectively:

    find ~/music -type f -print0 | xargs -0 chmod 644
    find ~/music -type d -print0 | xargs -0 chmod 755
    

    Using this approach, for example, we could set all the mp3 files in ~/music to read-only so that an application or script doesn’t accidentally overwrite their tag metadata:

    find ~/music -name "*.mp3" -print0 | xargs -0 chmod 644
    

    To verify that the permissions were set correctly let’s pass ls -l to xargs:

    find ~/music -name "*.mp3" -print0 | xargs -0 ls -l
    

    There ya have it. A couple of examples of how to use the xargs utility, one of the most useful and the most underappreciated utilities in *nix toolbox.

    Tags: ,

    News Google +1 Button

    0 Comments

    I’ve never been all that keen on all those little social buttons that one sees cluttering nearly every web site you visit these days. You’ve seen them – Facebook’s “Like” button, Twitter’s iconic blue bird, and the like. As a web user I find them distracting. I suppose they make a certain kind of sense – Web Site A generates revenue through advertising; the more page views/impressions and ad clicks Web Site A can muster the more money Web Site A’s owner makes – those little buttons help support this ecosystem.

    But that’s another reason you haven’t seen any of those buttons on this site. My goal isn’t to make money on ads, in fact you won’t ever see ads on this site. My goal is simply to share information and experiences to whomever can benefit from it. And it’s to that end that I’ve decided to add Google’s +1 button to this site.

    Adding the +1 button will hopefully give you an easy way to recommend the content you’ve read. Your friends and contacts, when logged into Google will see your recommendation when it’s most relevant — in the context of Google search results. +1’s can also be a useful signal to Google when determining the relevance of the content to a user’s query and may be used to determine its relevance and ranking.

    In short, my goal is to share information with people who can use it. The Google +1 button strikes me as a tool that could help meet that goal.

    Tags: