&n>
Who Should Read This Book? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
How This Book Is Organized. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . 2
About the Book’s Source Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Conventions Used in This Book. . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . 3
Part I: Getting Up and Running
1: Installation QuickStart Guide
Linux/UNIX Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Windows Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Mac OS X Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . 16
Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 20
2: Installing and Configuring MySQL
Current and Future Versions of MySQL . . . . . . . . . . . . . . .. . . . . . . . . . . . . 21
How to Get MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Installing MySQL on Linux/UNIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Installing MySQL on Mac OS X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Installing MySQL on Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Troubleshooting Your Installation . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . 32
Basic Security Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Introducing the MySQL Privilege System. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Working with User Privileges. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Q&A. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Workshop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3: Installing and Configuring Apache
Current and Future Versions of Apache . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Choosing the Appropriate Installation Method . . . . . . . . . . . . . . . .. . . . . . . . . . . 44
Installing Apache on Linux/UNIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Installing Apache on Mac OS X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Installing Apache on Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . 48
Apache Configuration File Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Apache Log Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Apache-Related Commands . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . 57
Starting Apache for the First Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . 60
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Q&A. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Workshop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
4: Installing and Configuring PHP
Current and Future Versions of PHP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Building PHP on Linux/UNIX with Apache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Installing PHP on Mac OS X . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . 69
Installing PHP on Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
php.ini Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Testing Your Installation . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Getting Installation Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
The Basics of PHP Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Q&A. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Workshop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Part II: PHP Language Structure
if (window.amznJQ) { amznJQ.onCompletion('amznJQ.criticalFeature', function() { var precacheDetailImages = function(imageUrls, pids) { function transformUrl(imgUrl, pid) { var suffix = '._SL500_AA300_.jpg', defaultApparel = '._AA300_.jpg', imgUrlSplit = imgUrl.split("._"); if (imgUrlSplit.length) { var prefix = imgUrlSplit[0]; if ((!pid && storeName == "books") || pid == "books_display_on_website") { if (imgUrl.match("PIsitb-sticker-arrow")){ var OUID = imgUrl.substr(imgUrl.indexOf('_OU'), 6); var lookInsideSticker = '._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA300_SH20'+ OUID +'.jpg'; urls.push(prefix + lookInsideSticker); } else { urls.push(prefix + suffix); } } else if ((!pid && storeName == "apparel") || pid == "apparel_display_on_website") { urls.push(prefix + "._SX342_.jpg"); urls.push(prefix + "._SY445_.jpg"); } else if ((!pid && storeName == "shoes") || pid == "shoes_display_on_website") { urls.push(prefix + "._SX395_.jpg"); urls.push(prefix + "._SY395_.jpg"); } else { urls.push(prefix + suffix); } } }; var urls = [], numImgsPreload = Math.min(6, imageUrls.length), storeName = "english-books"; for (var i = 0; i < numImgsPreload; i++){ var currPid = (pids && pids.length) ? pids[i] : ""; transformUrl(imageUrls[i], currPid); } for (var j = 0; j < urls.length; j++) { var img = new Image(); img.src = urls[j]; } }; var win = jQuery(window); var feature = jQuery("#purchaseShvl"); var shvlPresent = feature.length > 0 ? 1:0; var lastCheck = 0; var pending = 0; var onScrollPrecache = function() { if (pending) { return; } var lastCheckDiff = new Date().getTime() - lastCheck; var checkDelay = (lastCheckDiff < 200 ? 200 - lastCheckDiff : 10); pending = 1; var u = function() { if(shvlPresent && (win.scrollTop() + win.height() > feature.offset().top + 200)) { var p = precacheDetailImages, $ = jQuery; if (p) { var selector = "#purchaseButtonWrapper"; var imgElems = $(selector).find("a > div > img"); var pgs, imgs = [], i = imgElems.length; while (i-- > 0) { imgs[i] = $(imgElems[i]).attr('src'); } p(imgs,pgs); } // unbind listening on scroll once pre-caching completed $(window).unbind('scroll', onScrollPrecache); return; } pending = 0; //precache not execute yet, wait next invoke lastCheck = new Date().getTime(); }; setTimeout(u, checkDelay); return; }; jQuery(window).bind('scroll', onScrollPrecache); }); }
|