Drupal Deployment Troubles and Problems


Published on

Drupal Camp Kyiv2010 (http://camp10.drupal.ua/) presentation about Troupbles and Problems during Deployment Drupal projects

Drupal Deployment Troubles and Problems

  1. 1. Drupal DTP<br />Deployment <br />Troubles and Problems<br />6.x<br /> @landike (Andrii Lundiak)<br />
  2. 2. Deployment steps<br />
  3. 3. Steps level<br />
  4. 4. What we have today to discuss<br />Hosting environment worries<br />First install steps<br />Magic php.ini<br />This very helpful .htaccess file<br />We all like settings.php<br />Strange unbelievable error messages<br />or <br />Let find more Troubles and more Problems and Ways how to fix them.<br />
  5. 5. Useful MySQL stuff<br /><ul><li>mysqlimport --password=mypass --user=myuserdbname dbname.sql;
  6. 6. mysql -h DBSERVER -p -u username dbname < dbname.sql
  7. 7. mysqldump-u username -p dbname > dbname.sql
  8. 8. mysql -h DBSERVER -p -u username dbname > dbname.sql </li></ul>Usemysql.cnffile to run easier<br />#---------------<br />[client]<br />user = myuser<br />password = mypass<br />host = DBSERVER<br />[mysql]<br />database = dbname<br />#-------------<br />mysql< dbname.sql<br />
  9. 9. Log Files<br />It's good to know what we have on hosting server and especially where Log files are. <br />To access the files directly on the server, on some Unix shells, you can type the following command:<br />tail -f /var/log/apache2/error.log<br />To check that you are looking at the right file, you may wish to type the following commands to find where the log files are.<br />grep 'ErrorLog' /etc/apache2/*<br />grep 'ErrorLog' /etc/apache2/*/*<br />
  10. 10. Error Reporting<br />If error reporting is turned off, you could be getting a fatal error but not seeing it. On a production site, it is common to have error reporting turned off.<br />Take care to have in index.php:error_reporting(E_ALL);ini_set('display_errors', TRUE);ini_set('display_startup_errors', TRUE);<br />this will help in debug/test mode<br />
  11. 11. Install and Go<br />Create Database … and enjoy easy installation<br />If some php settings are not in properly state, install process will tell you (about register_globals, mbstring.http_output, safe_mode, etc.)<br />
  12. 12. php.ini magician<br />How to override php settings:<br />value of a configuration option in php.ini<br />.htaccess directives<br />using ini_set() in settings.php<br />or use control panel on your hosting server<br />or call to admin person<br />or change hosting server <br />
  13. 13. Another way to override<br />If you have access to php.ini it’s AWESOME, and It’s great if you have your own php.ini near by www<br />On some hosting servers such kind of option is used to enable using local php.ini file:<br />ssuPHP_ConfigPath /hsphere/local/home/sitelocation<br />This setting must be located in .htaccess file<br />And php.ini file must exists in /hsphere/local/home/sitelocation/php.ini<br />
  14. 14. Allowed memory size …<br />Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y bytes)...<br />Increase PHP's memory limit, up to 16MB or 24M or 32MB or especially 96MB for a site with built-in image processing using ImageAPI GD<br />memory_limit = 16M in your php.ini file. <br />or<br />php_valuememory_limit 16Min your .htaccessfile<br />or<br />ini_set('memory_limit', '16M'); in your settings.php file<br />???<br />
  15. 15. Execution time of 30s exceeded<br />“Fatal error: Maximum execution time of 30 seconds exceeded in ….includesdatabase.mysql.inc on line XXX”<br />The default PHP timeout defined in php.ini is 30 seconds. This is too short for some activities like listing/enabling modules.<br />max_execution_time 120; (php.ini)<br />php_valuemax_execution_time 120 (.htaccess)<br />ini_set(‘max_execution_time’, ‘120’) (settings.php)<br />Set “max_execution_time “ = 3000 and Enjoy  (is very useful in testing stage)<br />
  16. 16. Dear friend - .htaccess<br />.htaccess was not uploaded (Access Denied message, Disabled Clean urls)<br /><ul><li>RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]</li></ul>“PHP: Error parsing …” - () was in .htaccess comments<br />http://example.com -> http://www.example.com<br /><ul><li># RewriteCond %{HTTP_HOST} ^example.com$ [NC]
  17. 17. # RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] </li></ul>http://www.example.com -> http://example.com<br /><ul><li># RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
  18. 18. # RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]</li></li></ul><li>Lovely settings.php <br />$cookie_domain = 'example.com';<br /><ul><li>Drupal automatically generates a unique session cookie name for each site, based on full domain name
  19. 19. This option is used in CKFinder configuring
  20. 20. Do not miss it, going from dev-server to production-server</li></ul>Take care about file permission and $db_url and $update_free_access<br />Don’t forget, if you have $db_prefix, you should use {table} in SQL query build<br />
  21. 21. WSOD (White Screen Of Death)<br />"Invisible" Errors or Blank Pages, how to fix:<br />SELECT * FROM watchdog LIMIT 20;<br />Easy manual quick-fixing <br /><ul><li>rename couple of modules step-by-step</li></ul>Dtools<br /><ul><li>bench_chart.module, wsod_emergency.php, wsod.module</li></ul>Increase CPU limit on hosting server<br /><ul><li>With low level (3-5%) some heavy pages will be “blank”</li></li></ul><li>Another silly mistakes<br />Whitespace at the Begin and End of a PHP File<br /><ul><li>See more about <? and <?php in short_open_tag “php configuration option” information
  22. 22. God, bless IDEs, which remove trailing whitespace. Or you should take care with your coding </li></ul>“You are not authorized to access this page”<br /><ul><li>browser multi tab access
  23. 23. block settings changes
  24. 24. admin/build/themes on slow hosting</li></ul>To fix this issue: call drupal_flush_all_caches(); anywhere<br />
  25. 25. Disabling Modules<br />Via the Module Administration Page in the UI<br />Administer > Site Building > Modules … Uncheck and Save<br />Via the Database<br />If your WSOD is caused by a specific module and you cannot access the module admin page, go to system table, set status to 0 and then clear the cache table<br />
  26. 26. You should have cron<br />There are many ways to configure cron (curl, lynx, wget, even GET), but …<br />Here is real “drupal” way:<br />Change file permission for scripts/drupal.sh (chmoda+x scripts/drupal.sh)<br />Use in crontab file (or in Hosting Control Panel) this command:<br />/home/account/www/scripts/drupal.sh --root /home/account/www http://default/cron.php<br />PS. Cron is used by many modules: <br />Update, Event, Aggregator, Search, Notifications, Send, Image watermark, Watchdog and other which must run time-related tasks.<br />
  27. 27. Suggestions Before Deployment<br />Be afraid free hosting with additional ads<br /><ul><li>admin/build/[modules|menu] doesn’t run
  28. 28. admin/build/themes run with errors
  29. 29. JavaScript/AJAX/XMLHttpRequest errors</li></ul>These actions would be great to do before/during/after deployment:<br />TRUNCATE TABLE watchdog;<br />drupal_flush_all_caches(); or “Clear Cached Data”<br />"Rebuild Permissions" in Post Settings page<br />“Re-Index site”<br />
  30. 30. Think at first || rapid development<br />Masquarade module<br />Transliteration<br />Devel/Themer module<br />Drush module<br />“TEASER break” button in rich editor an Node-System<br />Use professional IDE<br />
  31. 31. References<br />Drupal Deployment Checklist (!!)<br /><ul><li>http://www.metaltoad.com/blog/drupal-deployment-checklist</li></ul>General information about cron with Drupal<br /><ul><li>http://drupal.org/getting-started/6/install/cron</li></ul>Advanced Cron Modules<br /><ul><li>http://groups.drupal.org/node/17072/edit +++ http://www.drupalcron.org/</li></ul>Dtools module (WSOD tablet)<br /><ul><li>http://drupal.org/project/dtools/cvs-instructions</li></ul>Advanced PHP Error Handling via htaccess (!!!)<br /><ul><li>http://perishablepress.com/press/2008/01/14/advanced-php-error-handling-via-htaccess/</li></ul>Stupid htaccess Tricks (!!!)<br /><ul><li>http://perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/</li></ul>Drupal Tweaks (helping with allocation of php memory size)<br /><ul><li>http://drupal.org/project/drupal_tweaks</li></ul>Drush - Drupal Shell utility <br /><ul><li>http://drupal.org/project/drush || http://groups.drupal.org/drush || http://drupal.org/node/477684</li></ul>Automating Drupal Deployment with drush_make and Features (!!!)<br /><ul><li>http://drupalcampaustin.org/sessions/automating-drupal-deployment-drushmake-and-features </li></ul>Install with Drush (!!! – GREAT short list of command to install)<br /><ul><li>http://knol.google.com/k/michael-chelen/how-to-install-drupal-using-drush/gxxp1ckx8nad/5# </li></li></ul><li>That’s all<br />Send me email. I’m here landike@gmail.com<br />Follow me in twitter @landike<br />Call me via Skype – lan_researcher<br />See my “media” updates on www.landike.mp<br />drupal user – LAN_DRUPAL<br />