Wednesday, December 19, 2012

New Server setup with CentOS 6, Drush and Drupal libs


My compilation of docs and tutorials to help me get a server setup with CentOS 6, Drush and various libs needed for Drupal 7.  Once that is complete and working, a short write-up on getting a Drupal 7 site up and running in less than 2 minutes.
  1. Webmin install and setup: http://jarodms-drupal.blogspot.com/2012/07/webmin-on-ec2.html
  2. Config Firewall for Webmin:   http://www.webmin.com/firewall.html
  3. LAMP Setup: http://library.linode.com/lamp-guides/centos-6
  4. Drush in less than a minute: http://danreb.com/content/how-install-drush-centos-linux-drupal-development
  5. Additional libraries for Drupal:
    1. yum install php-gd
    2. yum install php-dom
    3. yum install php-mbstring
Additional Steps:
  1. Optimize php.ini
  2. Depending on server, may need to open firewall for port 80

Install Drupal 7 instance in less than 2 minutes:
  1. Create MySQL Database
  2. Create MySQL User/pass
  3. Grant MySQL privileges for user
  4. Config virtual host for new Drupal site and restart Apache

<VirtualHost *:80>
     DocumentRoot "/var/www/html/drupal7"
     ServerName fill-in
     ServerAlias fill-in
     ErrorLog /var/www/logs/drupal7-error.log
     CustomLog /var/www/logs/drupal7-access.log combined
     <Directory "/var/www/html/drupal7">

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

</Directory>
</VirtualHost>



Use Drush to download Drupal and install site:
  1. drush dl 
  2. drush site-install standard --account-name=admin --account-pass=admin --db-url=mysql://SiteMySQLUser:SiteMySQLUserPassword@localhost/SiteMySQLDatabase



Friday, December 7, 2012

My Dell Inspiron 1764 - CentOS 6.3 and Broadcom Wireless BCM43224 driver

There is no default driver for Broadcom wireless cards on CentOS 6.3.  Broadcom is apparently getting better at Linux support, so they provide the source you can compile to get the driver.  Here's the awesome and simple writeup that I found.  It really did take just 5-10 minutes of copy/paste/execute.

I won't even try to recreate all the steps in this blog.  Just go to http://elrepo.org/tiki/wl-kmod and follow the instructions.  Worked like a charm!

My setup:
Dell Inspiron 1764 dual-boot into Windows 7 and CentOS 6.3
PCI Device (lspci at terminal) :
Network controller: Broadcom Corporation BCM43224 802.11a/b/g/n (rev 01)

Tuesday, November 20, 2012

Drupal User Admin module stack

Here's a stack of modules that I like which help a non-administrator manage their own users.

Administer Users By Role:  http://drupal.org/project/administerusersbyrole
Role Delegation:  http://drupal.org/project/role_delegation
Login One Time:  http://drupal.org/project/login_one_time
No Current Password:  http://drupal.org/project/nocurrent_pass

Once installed and enabled, I create a role ("site-owner" for example) and assign it the various permissions.
A few more little tricks and now the Site-Owner can create or cancel users, assign various roles, and send them a One Time Login link if needed.

One caveat I need to investigate...the Administrators (e.g., User 1) are still shown on the list of users (admin/people) and certain roles can be added or removed, but the Administrator role can't be removed and the Admin account can't be edited or canceled.  Really the Site Owner can't do anything harmful to the Admin, but I'd prefer that account wasn't shown at all in the list.  I need a module that will only show the users whose role is less than or equal to the current role.

Thursday, October 18, 2012

Drupal 7, Services 3.x , Request and Response

Here is something that I just recently learned regarding request/response from a REST server.
In this case, I am using Drupal 7 with Services 3.x.

It's just one of those things I guess you don't lean until you need to, and I never had yet.  It was difficult to find the info though.

Here is the scenario:

  1. You are calling a web service using JSON as the Content Type.
  2. You are getting back an XML response.
  3. You want to get back a JSON response.

Here's what you need to do.
Goto your services
 
Select "Edit Server"

Make sure the response formatter "json" is selected.  It may already be.


Now in your JSON REQUEST, add the following header:
Accept = "application/json"

For some reason, Drupal was returning the response in XML format by default, I don't know why, but adding this header to the request immediately gave me back a JSON response.


Monday, July 2, 2012

Webmin on EC2

Installing the RPM package of Webmin on EC2 was a 5 step process for me:

*** Verify the latest RPM version at http://www.webmin.com/download.html
  1. wget http://prdownloads.sourceforge.net/webadmin/webmin-1.610-1.noarch.rpm
  2. sudo rpm -U webmin-1.610-1.noarch.rpm
  3. sudo /usr/libexec/webmin/changepass.pl /etc/webmin root foo
    1. Change the webmin root password to foo. 
  4. sudo /etc/init.d/webmin restart
  5. Configure IPTables to allow port 10000: http://www.webmin.com/firewall.html
Webmin will be accessible at http://youserverip:10000

* Works fine on CentOS in Linode and Rackspace.
* Would be nice to install cert for this though.

Monday, April 16, 2012

What's New in Drupal 7

What's New in Drupal 7 | drupal.org

A good page to read...just in case someone asks you.  ;)

'via Blog this'

Friday, March 30, 2012

Getting Drupal updates into TEST


.

  1. I create a branch from TEST and call it something like updates. (git checkout -b updates)
    1. Now I'm working in the branch updates
  2. Create a backup of the database - important and discussed later.
  3. Pull the necessary modules or Drupal updates and test it out.
  4. Everything look ok?  Then merge the branch to TEST.  
    1. git checkout test
    2. git merge updates
    3. handle any conflicts
Why would you do this rather than pull your Drupal updates right into TEST? Murphy's Law.  If you pull the Drupal updates into TEST first, then somebody is bound to have an issue or item that needs worked on that needs to go into TEST before you had a chance to completely test and verify your Drupal upgrade.  

The approach above helps you get around this.  You're in the middle of testing Drupal updates and someone approaches you with a bug or change that needs to go into TEST first. How do you roll back to the TEST branch? 
  1. checkout TEST (git checkout test)
  2. Restore the database using the backup you created earlier.
  3. You are now at the TEST version you need for the new change, without those Drupal updates that you haven't completely tested.
  4. Create your new bug/change branch and continue on the issue that was asked of you.


Monday, February 27, 2012

Drupal - Bootstrap for old PHP script

In a hurry and I have an old PHP application that pulls data from proprietary tables.  I have connected some of the data to a node, but now I need to display the data in a separate window when applicable.

So, using the old and large PHP script, just to get it functioning, I had to bootstrap Drupal.
Place this at the beginning of OldLarge.php


$drupal_dir = getenv("DOCUMENT_ROOT");
$current_directory = getcwd();
chdir($drupal_dir);


require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

...
Do my Drupal stuff here....db_query() and whatever so that I can get results back from weird tables.
...

Then at the end of  OldLarge.php , add the final code....


chdir($current_directory);


Eventually...some day (which ends up being never) I will convert the OldLarge.php script to something more Drupalized.

Wednesday, February 8, 2012

CiviCRM "Javascript must be enabled in your browser in order to use the dashboard features"

"Javascript must be enabled in your browser in order to use the dashboard features"

I started getting this error from some of my testers when they were using IE9.  Sure enough, I couldn't access the CiviCRM dashboard or CiviCRM menu (it acted like it was disabled).

Yep, well JavaScript is enabled.

Stats on the site:
CiviCRM version 3.4.8
Latest Drupal (6.24)
Drupal module jquery_update installed (giving Drupal the jQuery version 1.3.2)

Hmmmmmm.....It works FINE with Chrome (16.0.912.77 m), Opera (11.61), Safari (5.1.2), and Firefox (10).

Oh YEAH!  That's right!!!   Internet Explorer doesn't handle a lot of JavaScript files very well.  CSS files are limited to 32(?) I think.  Not sure what the JS limit is.

So on the TEST site I enabled "Optimize JavaScript files" and all works well in IE8/IE9.

Things to look at:
http://drupal.org/project/javascript_aggregator
Great article by Vlad http://shvetsgroup.com/blog/optimizing-javascript-and-css-files-drupal

Wednesday, January 4, 2012

User Agents

A large list of user agents
http://techpatterns.com/forums/about304.html

Any other lists you know of?

Friday, December 16, 2011

My current sites/all/modules

My current "modules" folder and what it contains:

  • civicrm
  • contrib
  • custom
  • shortsitename_features
I kind of like that.  Nice and sweet.  There's a bunch of modules under "contrib" of course, a few under custom (but growing) and a few under shortsitename_features  (but growing).

Tuesday, December 13, 2011

CiviCRM - moving your configuration changes to a different environment

I love code driven development.  So when I build my Drupal sites, I immediately download and enable Features.  I do not want to handle website settings between environments by comparing screens and clicking box after box.  When you are running in a local DEV environment, plus you have a TEST and LIVE environment, using Features saves time (which of course equals money).

So I started a new project using CiviCRM and the thought in the back of my mind for awhile was:

"I just changed a CiviCRM setting.  How do I migrate that change to my TEST and LIVE environments?".  

Well the time came and I had to do it.  I needed to get my TEST site going and didn't want to bother remembering all of the settings I needed to configure.

Luckily, CiviCRM comes with migrate scripts to Export and Import your settings.

First Export it from the localhost (DEV environment) using one of the options.  More exist, but these are pretty basic:

  1. Browse to
    1.  http://localhost/virtual_dir/sites/all/modules/civicrm/bin/migrate/export.php?name=&pass=&key=
      1. This will download a file called CustomGroupData.xml
  2. Using wget (if you want to script this and update the file at 3pm for example)
    1. wget -O D:\dev\htdocs\virtual_dir\sites\default\CiviCRM.info "http://localhost/virtual_dir/sites/all/modules/civicrm/bin/migrate/export.php?name=&pass=&key="


I save this file to a folder in the website I am working on.  Then, if it has changed, I commit it to git.

After the export file has been committed to git, then moved to your next server, import:
http://example.com/sites/all/modules/civicrm/bin/migrate/import.php?name=&pass=&key=&file=../../../../../default/CiviCRM.info


Notice the difference between this command and previous ones is that it uses import.php and specifies a file.

I noticed there were a couple of settings that did not get exported and I think those are related to CiviCRM Profiles.  I need to look into this a bit and see if this is an issue or "works as designed".

What are some other options for moving CiviCRM configuration changes between environments?

Monday, November 7, 2011

Drupal - Code Driven Development

I think most of my sites have 2 versions...LOCAL and LIVE to allow testing of various changes as well as developing new themes and modules. Some sites have 3 versions, LOCAL, USER TEST, and LIVE.

I like having a local version so that I can polish it first. Also, I use tools like NetBeans for coding and debugging.

I use "Code driven development" for all my Drupal sites. Remember, the changes you are making through the GUI in your Drupal site are being saved to the database.  To use code-driven development, you need to get those changes out of the DB and into code.  This is where Features comes in.  My process:
  1. Develop code or theme; make your config changes in Drupal
  2. Export as much as possible using Features and Strongarm - This puts the DB changes into code
  3. Checkin the code to your version control system
  4. On the server - pull code from your repo
  5. Enable the various Features
Once you have your systems and procedures in place, this can actually be a time saver.  It's actually quite fun!!!! :)

Debugging PHP in NetBeans (in Ubuntu)



Here are the steps I used to setup PHP debugging in NetBeans (6.8 at the time of this writing) in Ubuntu 10.

sudo apt-get install php-pear
sudo apt-get install php5-dev
sudo apt-get install php5-xdebug



Edit your PHP INI settings
sudo nano /etc/php5/apache2/php.ini

Add the following lines under extensions:


zend_extension=/usr/lib/php5/the-folder/xdebug.so
xdebug.remote_enable=on


In my case it was ""/usr/lib/php5/20090626+lfs".  You will have to find the xdebug.so file in the correct folder.

Restart Apache
sudo /etc/init.d/apache2 restart


NetBeans PHP Debug Settings
  1. Goto tools->Options
  2. Select PHP
  3. On the General tab
  4. If this is your first time configuring xdebug, you may want to keep "Stop at First Line" checked.  this way when you start debugging you should know right away that your setup is correct. 
Start Debugging
  • Add some break points.
  • Right-click your project and select Debug

Thursday, October 13, 2011

CentOS 5.6 server setup

These are the guides and blog posts I use to setup LAMP on my new CentOS servers:



I typically install Webmin too, so I'll document that one in a bit.

Thursday, October 6, 2011

Drupal 6 "Unable to fetch any information about available new releases and updates"

When manually trying to check for available updates I ran into this message:

"Unable to fetch any information about available new releases and updates"

I don't recall ever seeing this when running Drupal 6.

My solution: restart Apache and it worked.

http://drupal.org/node/168828

Thursday, September 29, 2011

Updating modules and themes requires FTP access to your server

How to get rid of that pesky (D7) FTP issue when updating modules:

Updating modules and themes requires FTP access to your server

http://drupal.org/documentation/install/modules-themes/modules-7#comment-4690140

The short of it, change the owner of the sites/default directory to whoever the Apache default user is (www-data, apache, etc.)

chown www-data sites/default

Monday, September 19, 2011

Debugging PHP in NetBeans (in Windows)


Here are the steps I used to setup PHP debugging in NetBeans (7.0 at the time of this writing).

The way to do it:  http://xdebug.org/docs/install
You will need to download the correct php_xdebug from the xdebug.org site: http://xdebug.org/download.php

I downloaded the correct DLL for my environment and followed the install instructions.  Below are my final php.ini settings:

This extension is disabled
;extension=php_xdebug.dll


[XDebug]
;; Only Zend OR (!) XDebug
;zend_extension_ts="D:\xampp\php\ext\php_xdebug.dll"
zend_extension_ts = "D:\xampp\php\ext\php_xdebug-2.1.1-5.2-vc6.dll"
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.profiler_enable=1
xdebug.profiler_output_dir="D:\xampp\tmp"


NetBeans PHP Debug Settings
  1. Goto tools->Options
  2. Select PHP
  3. On the General tab

Friday, September 2, 2011

Almost 3 Years!!!

Hey look, I've been a member of D.O for nearly 3 years now.  :)


Thursday, September 1, 2011

Drupal 6 - Remove N/A from list of Radio button options

When creating a radio button field with CCK, you can remove the "N/A" option by making the field required.

fyi...to make your options turn into checkboxes, change "Number of values" to something other than 1.