Salient Digital Techno Blog

Ramblings on technology with a dash of social commentary
RSS icon Email icon Home icon
  • Enabling Command-line PHP Curl on Mac OS X Lion

    Posted on October 25th, 2011 phpguru No comments

    If you’re doing web development on the Mac with the Apache 2 and PHP 5.3.6 that ships from Apple, you might one day run into a use for some command-line scripts. I happen to be doing just that at the moment. Well it seems that Apple ships PHP 5 with everything you need to use the curl libraries, except the extension.

    I was surprised with an error warning like this:

    PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/php_curl.dll' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/php_curl.dll, 9): image not found in Unknown on line 0
    Huh? I need a Windows DLL on Lion? I guess so…

    I’ve been using CURL scripts from PHP running under Apache since day one, but what I’m realizing is that the command line version of PHP, aka, the php-cli, is installed a little differently.

    First, you may want to check your php.ini that the extension is uncommented (remove the preceding semicolon):
    extension=php_curl.dll This is a pretty obvious step to try, even though Lion is clearly not Windows, and the section in php.ini clearly says it’s for Windows Extensions.

    So you might try installing the latest version of cURL.
    cd ~
    mkdir src
    cd src
    curl -V
    curl 7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5

    At this point, you start wondering what’s going on, because cURL is installed at the Factory by Apple. Strange…

    So you can
    sudo find / -name php_curl -print just to see if the DLL is in the wrong place or something, maybe a quick symlink would fix it.
    Nope.

    But this is interesting… PHP 5.3.6 from Apple ships with the curl extension:

    cd /Users/%me%/Documents/src/php-5.3.6/ext/curl
    phpize
    ./configure
    make
    sudo make install

    Now edit your php.ini and add
    extension=curl.so
    and
    sudo apachectl restart
    Well that didn’t do much. Now I get:
    PHP Warning: Module 'curl' already loaded in Unknown on line 0

    Hmmm, stranger still.

    Here’s the punchline: All you need to do is comment out (add the semicolon at the front)
    ;extension=php_curl.dll
    and restart Apache.

    The warning was exactly correct – it couldn’t find a Windows DLL. I wonder why that’s uncommented.

    I don’t remember uncommenting it, but maybe I did.

  • How to install MySQL 5.5 on Mac OS X 10.7 Lion

    Posted on September 8th, 2011 phpguru 2 comments

    This may not be obvious, but on the new Macs that ship with Lion, you can use the MySQL 5.5 64-bit dmg installer. It works perfectly on Lion, even though the MySQL site (still, at the time of this writing) says Mac OS X 10.6 Snow Leopard. You can use the Preference Pane to stop and start MySQL.

    Now after MySQL 5.5 is running, strangely enough, you cannot simply launch terminal and type mysql -u rootBash will complain that it can’t find mysql. So we have to help it like so:

    1. Use your favorite text editor to edit the file /Users/%yourname%/.bash_profile If this file doesn’t exist you can create it.
    2. Add the following line to your .bash_profile export PATH=$PATH:/usr/local/mysql/bin and save the file. Be careful editing this file exactly as above. You can render terminal unable to find all your programs if you break your $PATH.
    3. Quit and relaunch terminal, or type source ~/.bash_profle and hit return to reload the changes in your profile.
    4. Check your $PATH by typing echo $PATH and pressing return. You should see something like this /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/mysql/bin
    5. Now you should be able to run mysql -u root which means there is no root password by default!
    6. Run this next, at the mysql prompt GRANT ALL ON *.* TO 'root'@'localhost' IDENTIFIED BY 'your_password_here' WITH GRANT OPTION;This is how to secure your root user login.

    Now, for PHP to use this connection I had to tweak my system as shown below:

    1. Run phpinfo() and check out the path PHP is trying to use for mysql.sock. On my new Mac Mini, it was/var/mysql/mysql.sock
    2. From terminal, I did sudo find / -name mysql.sock -print
    3. The critical line of output shows that MySQL 5.5 installs the sock to /private/tmp/mysql.sock
    4. Now we need to create a symlink for PHP to be able to access the mysql.sock. Trouble is if you try it you’ll get an error because /var/mysql doesn’t exist. So next, do sudo mkdir /var/mysql
    5. Finally, do this sudo ln -s /private/tmp/mysql.sock /var/mysql/mysql.sock

    Did that work for you?

  • Face Facebook Sharing Security Head On

    Posted on August 31st, 2011 phpguru No comments

    Sharing Policies on Facebook just got an upgrade. I thought you might like to see the new enhancements.

    1. Say who your with. Right off the bat, you can select the friends you want to be involved with a particular stream or conversation.

    2. Add Location to your posts. You can now define places where your conversation has relevance.

    3. Control privacy when you post – or after. If you realize a conversation might be better kept between certain people, you can now change the way your wall posts are published during or after the conversation starts.

    Visit this page on the Facebook.com Help pages For a more in-depth look at how to use Facebook’s newer, more secure sharing features.

  • How to Add Products to your Home Page in Magento

    Posted on August 28th, 2011 phpguru No comments

    In just 10 easy steps!

    Here are the steps:
    1. Download Magento and get it set up and running on your local box or web hosting account. I wrote about that before.
    2. Login to the backend in one browser tab, and load up your frontend in a new window.
    3. Turn off caching on the System -> Configuration screen.
    4. Configure your default store, or copy the default theme (or better yet, follow this tutorial to create a new Magento theme as your_interface/your_theme)
    5. Go to  System -> Manage Stores -> Website, Store, Store Layout and create one, point it to your_interface/your_theme
    6. Configure at least one Category and activate it.
    7. Configure at least one Product, assign it to the active category, and set it to enabled. Add Inventory of more than zero, and change Out of Stock to In Stock on the product editor.
    8. Assign the product to a website by checking the product on the Manage Products list and choosing Update Attributes in the upper right-hand corner. On the Manage Product -> Update Attributes screen is a right-hand tab that says “Website”. Choose that and check the store(s) you created in step 2 to assign the product to the website.
    9. Edit your Home Page content to have the following code, where 2 is Category ID shown on the Manage Categories -> Edit Category page.
    10. Go back to the Home Page browser tab and hit refresh (option refresh to force reload, in some browsers, or to be sure, clear your browser cache first).

    If this isn’t very clear, please watch this great screencast by Scott W on Vimeo.  In less than 10 minutes it will all be clear.

     

  • Zend & RightScale: The Ferrari of PHP Deployment has Arrived

    Posted on August 15th, 2011 phpguru No comments

    Zend Server is already the Cadillac of PHP Application Servers.

    The Ferrari of PHP Application Deployments has arrived.

    At least some, if not many PHP application developers are comfortable maintaining an Apache-based web server on Linux, the critical hardware that most often drives the web. Apache is free, and PHP is free, but you can’t be afraid to roll up your sleeves and get your hands dirty if you need to upgrade your software, install a new module, or tweak your server config.

    Most, if not all PHP developers are familiar with Zend, the engine that powers the PHP scripting language interpreter, and many great sites are developed using the Zend Framework.

    Zend PHP Cloud Platform on RightScale

    The Zend Framework is an enormous collection of ready-to-go building blocks (object-oriented PHP classes) for building just about any type of web application. There’s no question that their Zend Studio IDE ($299, built on Eclipse) is a solid PHP development platform, and Zend Server ($1,195 and up for support licenses) provides a terrific web-based GUI for managing your development, staging or production server’s LAMP stack.

    A little pricey, maybe, but if you rely on a LAMP environment for your deployed software applications and you don’t have a lot of time or resources to be fiddling with your server software, Zend solutions still are excellent product choices to rely on from the company most closely associated with PHP development.

    In today’s inbox, Zend announced a partnership with RightScale. If you’re not already familiar with RightScale, their service piggy-backs onto Amazon AWS to give you a nice, clean, friendly UI to manage and deploy webscale applications in the cloud. If you’ve ever experimented with Amazon AWS, you know it can be a little confusing and cumbersome to manage multiple server configurations as they scale.

    "Considering PHP's ubiquity on the web, it wasn't a question of it embraced the cloud, but when," said Stephen O'Grady, Principal Analyst with RedMonk. "With the recently announced RightScale/Zend partnership, the two companies are offering PHP users the best of both worlds, with the time to market of Platform-as-a-Service (PaaS) and the flexibility of Infrastructure-as-a-Service (IaaS)."

    With RightScale, you can save server templates and security group configurations, manage users and more. In the same way that Jenkins can help you automate testing your PHP applications and delivering them seamlessly to your server environments, RightScale can help you manage multiple-server cloud server application architectures with ease. Really a big time-saver.

    Definitely not cheap, but absolutely worth checking out if you have a decent budget and need to save time managing PHP cloud deployments.

    Scalable, Flexible, Portable PHP in the Cloud

    RightScale and Zend recently introduced a solution to provide a best practices path to launching and maintaining highly-available PHP applications in the cloud. Learn more about the RightScale and Zend Solution Pack: attend our webinar on August 17.

    Join us on August 17 for a demo of this new cloud solution that
    enables you to:

     

    Provision a pre-configured, high availability PHP environment
    in minutes
    Autoscale your application based on system and application
    load metrics
    Receive system, server and application-level monitoring,
    alerting and diagnostics
    Abstract your application from underlying cloud infrastructure to
    enable future portability 

    Topic: Introducing “PaaS in a Box”: Scalable, Flexible, Portable PHP in the Cloud
    Date: Wednesday, August 17
    Time: 9 AM PT / 12 PM ET / 5 PM BST / 6 PM CEST
    Speakers: Uri Budnik – Director ISV Partner Program, RightScale
    Claudio Gentile – Sales Engineer, RightScale
    Kevin Schroeder – Zend Technology Evangelist, Zend

     

    Register


     

     

  • How to install PHP APC extension on Snow Leopard

    Posted on August 11th, 2011 phpguru No comments

    I followed several posts on the Apple Suppor forum to install APC on Snow Leopard (not Server, but this forum seems much more appropriate as I am using Snow Leopard on my local MBP 17 for serious web development, trying to match my Ubuntu Server config as closely as possible.)

    Most notably, these:

    discussions.apple.com/thread/2448001
    discussions.apple.com/message/12923918
    discussions.apple.com/message/11696363
    discussions.apple.com/message/10454666

    as well as

    www.kevinworthington.com/nginx-mac-os-snow-leopard-2-minutes/
    serverfault.com/questions/206633/failed-to-instal-apc-via-pecl-install-apc

    I had to instal PCRE 8.12 before APC 3.1.9 install would work. Wincent has perfect instructions for that.

    Now back in my APC source directory, doing phpize and ./configure resulted in test failures; I realized that the recommended way of installing APC is via pecl channel-discover pecl.php.net
    pecl install APC

    This succeeded: Build process completed successfully
    Installing '/usr/include/php/ext/apc/apc_serializer.h'
    Installing '/usr/lib/php/extensions/no-debug-non-zts-20090626/apc.so'
    install ok: channel://pecl.php.net/APC-3.1.9
    configuration option "php_ini" is not set to php.ini location
    You should add "extension=apc.so" to php.ini

    Okay, so I add extension=apc.so to php.ini and restart apache. sh-3.2# php -i | grep apc
    apc
    apc.cache_by_default => On => On
    apc.canonicalize => On => On
    apc.coredump_unmap => Off => Off
    apc.enable_cli => Off => Off
    apc.enabled => On => On
    apc.file_md5 => Off => Off
    apc.file_update_protection => 2 => 2
    apc.filters => no value => no value
    apc.gc_ttl => 3600 => 3600
    apc.include_once_override => Off => Off
    apc.lazy_classes => Off => Off
    apc.lazy_functions => Off => Off
    apc.max_file_size => 1M => 1M
    apc.mmap_file_mask => no value => no value
    apc.num_files_hint => 1000 => 1000
    apc.preload_path => no value => no value
    apc.report_autofilter => Off => Off
    apc.rfc1867 => Off => Off
    apc.rfc1867_freq => 0 => 0
    apc.rfc1867_name => APC_UPLOAD_PROGRESS => APC_UPLOAD_PROGRESS
    apc.rfc1867_prefix => upload_ => upload_
    apc.rfc1867_ttl => 3600 => 3600
    apc.serializer => default => default
    apc.shm_segments => 1 => 1
    apc.shm_size => 32M => 32M
    apc.slam_defense => On => On
    apc.stat => On => On
    apc.stat_ctime => Off => Off
    apc.ttl => 0 => 0
    apc.use_request_time => On => On
    apc.user_entries_hint => 4096 => 4096
    apc.user_ttl => 0 => 0
    apc.write_lock => On => On

    So now we know, from the command line anyway, PHP CLI is reporting it has APC installed.

    Now here’s the interesting part… from Apache (e.g. trying to run any local PHP file http://localhost/info.php for example) I just get a white page of death.

    If I comment that extension out and restart Apache, PHP files work again.

    Hmm, lets look at the error.tail -f error_log
    shows: Fatal error: Unknown: apc_fcntl_unlock failed: in Unknown on line 0

    I google that and find this bug report, where it is stated that a patch is available for apc_lock.h.

    I go back to the PECL APC source site and browse the sources in trunk, find the apc_lock.h file, download it, put it into my APC-3.1.9 source directory and run phpize
    ./configure
    make clean
    make install
    apachectl restart

    Note that `make clean` is the magic bit there since we already installed APC from these sources, we need to make a new fresh install from these same sources.

    Now everything is working happily again.

    Good luck with yours!

  • Matt Mullenweg’s Photos are in MY WordPress Database

    Posted on August 5th, 2011 phpguru No comments

    It may come as a surprise to you, just like it was to me, to find hundreds of personal photos from Matt Mullenweg’s trip to Alaska in MY WordPress blog database.

    Seriously, folks, this is rather rude in my opinion. I invite you to Check your wp_options table for instances of ma.tt and you may be quite surprised what you find.

    SELECT * FROM wp_options WHERE option_value LIKE '%ma.tt%'

    To be fair, the actual photos aren’t in my database, but useless links to them are. Apparently WordPress stores newsworthy feeds it receives (when is unclear – all day? when I login to wp-admin?) in the wp_options table.

    I’m shocked and somewhat horrified to find thousands of rows of this useless junk mucking up my WordPress database unnecessarily. I’m not sure there’s any way to inject malicious code into a database through a news feed that is automagically stored, but it sure seems like a potential security risk to me. If there’s a way to turn off this storing of feeds, I’d like to know.

  • Create and customize internet radio streams with Pandora

    Posted on July 28th, 2011 phpguru No comments

    I recently upgraded to an internet-ready Sony Blu-ray disc player which I found out after getting it home that it required a NetGear wireless to wired adapter, not included. Total cost: around $170. I don’t have a 3-D ready HDTV, but if you do, you should definitely get a Sony 3D Blu-ray disc player with Wi Fi.

    Step two, I created an account at Pandora.com, the leading free online music streaming sites. I really like Pandora’s smooth Flash-based UI, though you may prefer Slacker. Either way, the Sony BD player works with Pandora, Slacker, and a few more online music sites, in addition to video sites Netflix, Hulu and several others, and you can also interact with your account from your smart phone or tablet.

    My favorite part about Pandora is the easy way your stream grows in intelligence and becomes better with age. Here’s how it works:

    1. You add a few artists or albums to “seed” your channel.
    2. You can like or dislike music streamed on your channel.
    3. Pandora adds to your original seed artists, other similar artists that other people like, who have the same artists in their channel seeds.
    4. You can make as many streams as you like, or at least plenty to suit the gamut of musical tastes.
    5. And, you can easily share your channels.

    Here are a few of my Free Internet Radio Stations… created and shared for your streaming enjoyment.

    Hawaiian Radio

    AmbientRX

    Best of Trance

    80′s Radio

     

    One more point aboutthe Sony Blu-ray player. Their on-screen user interface is good, and the small, lightweight remote allows you to listen to your Pandora station through your home entertainment center in glorious 5.1 surround sound. The quality is amazing! That’s not even to mention streaming movies and tv shows from YouTube, Hulu, Netflix and more straight to your HDTV.

    Good stuff.

     

  • How to see previously viewed ads on Facebook

    Posted on July 23rd, 2011 phpguru No comments

    Here’s the scenario… you were surfing on Facebook, you saw an ad, you clicked on it, saw the coolest site and forgot to bookmark it to check out later, and now you can’t find it again. Searching on Google doesn’t help. So where is the ad you saw before so you can click on it again?

    Facebook Advertising is highly targeted to your likes and interests, and millions of really terrific businesses and organizations run ads on Facebook for that reason, so why doesn’t Facebook make it easier to find ads that Facebook thinks you may like?

    The Facebook AdBoard actually shows you the ads you have seen before*, ads you liked, and you can see if any of your friends liked them, too. You can also see Facebook Sponsored Stories. What a great way for businesses to get involved with their fans! Too bad they’re so buried in an impossible-to-find link.

    There is no information about how to do this that I could find in the Facebook Help files, so I wanted to keep this info posted somewhere I could find it again.

    Thanks to this Question and Answer on Yahoo! I found where you can go to see the Facebook Ads that have been shown to you before.

    Login to Facebook and then visit Facebook Ads Adboard to see the ads that you may have seen recently.

     

    * You just may not remember having seen it, but it was counted as an impression on the Facebook Advertising platform. Still not finding your previously viewed ads after visiting the AdBoard? You may be able to find the ad by viewing the files in your browser cache too.

     

  • Cool 404 Pages

    Posted on June 23rd, 2011 phpguru No comments
    Google 404 Page

    Google 404 Page

    GitHub 404 Page

    GitHub 404 Page