Drupal-Install-Using-Drush

From Sysadm
Jump to: navigation, search

Contents

Introduction

  • Drupal - our local drupal page

Install Drush

Installing drush on CentOS-6.x

Drush migrated to git-hub at some point (2012-2013?), thus the differences from earlier install instructions (below)

cd /opt
git clone https://github.com/drush-ops/drush drush
cd drush
ln -s /opt/drush/drush /usr/bin/drush

CentOS-5

  • download drush and setup
drushrel=drush-7.x-4.5.tar.gz   # older drush release
drushrel=drush-7.x-4.6.tar.gz   # current release of 4.x branch as of 2012-07-25

Get the URL from the drush site http://drupal.org/project/drush and copy and paste in here every so often. With the drush self-update, keeping this current might not really be that important.

drushurl=http://ftp.drupal.org/files/projects/drush-7.x-5.4.tar.gz   # current release as of 2012-07-25
drushrel=`basename $drushurl`  # get filename from the url above
cd /tmp; wget $drushurl;  cd /opt;  tar xzvf /tmp/$drushrel
echo "alias drush='php /opt/drush/drush.php'" >> ~/.bashrc
. ~/.bashrc
drush self-update  # get things current right off :-)


Updating a drush install

Have seen a few different behaviors with self-update.

  • mentions that update process varies depending on installation method and suggests some ways to update.
  • prompts for which version to update, prompt for backup and then updates

This is first thing to try...

drush --version
drush self-update

If that doesn't update drush, then try something like the following. This assumes an install in /opt

cd /opt; cp -rip drush drush-`drush --version > /tmp/dv ; head -1 /tmp/dv | sed -e 's/[a-z ]//g'`   # create a backup version
drush dl drush --destination=/opt

Install a specific version of a module

 drush dl drupal-8

CLI drupal install

  • figure out the following pieces (avoid - in name for mysql):
    • db name (sampledb)
    • db user (sampleu)
    • db user password (samplepw)
  • setup mysql user for above info

A cleaner, shell driven way. Can be reused in later steps. The convention has been to append a "u" to the db name to get the drupal user name... Could append "browse" or other.

n=sample.eri.ucsb.edu
d=sample     # db name, often drup_sample
u=${d}u   # db-su user name that drupal will use for its internal connection, usually just use d with a u appended
e="webmaster@eri.ucsb.edu"
# do not use "+" in the password, it fouls up the site-install line below.  
# PHP likely filters the URL looking db connection and replaces + with a space.
p=passwd    # db-su-pw setting used below, this is the pw for drupals internal connection
echo "grant all on $d.* to $u@localhost identified by '$p'; flush privileges;" | mysql -uroot -p mysql
  • attempt login using that account... to verify that it works
  • more abbreviated drush install - preferred way as of 2012-05-21 - less clutter
cd /var/www/vhosts    # start off in the vhosts directory
drush dl drupal   # this creates a drupal subdir with version number (drupal-7.9 in this case)
mv drupal-7* $n   # ie: something like sample.eri.ucsb.edu 
  • create drupal multisite instance (multisite install - ie: in sites)
cd $n
#use --sites-subdir=default if you are doing a standalone site..., use the name of the site if using multisite
# alias for site-install is "si"
# first example, using a single site (ie: no multi site, use default)
drush site-install standard --account-mail=$e --site-mail=$e --sites-subdir=default --db-url=mysql://$u:$p@localhost/$d
# second example for multisite use
drush site-install standard --account-mail=$e --site-mail=$e --sites-subdir=$n --db-url=mysql://$u:$p@localhost/$d --db-su-pw=$p --db-su=$u --site-name="$n"
# --db-su=name --db-su-pw=password --site-name="Your New Site"  # other possible options to add for site-install

Make note of the password that is echoed from this install, you will need it later to log into the site.

Password

Site is now installed, older versions didn't provide an admin password... So you would have to reset.

cd <drupal root directory>
php scripts/password-hash.sh 'newpassword'

Now cd to a drupal site directory and copy the resultant hash and paste it into the query:

cd sites/sample
drush sql-cli
update users set name='admin', pass='pasted_big_hash_from_above' where uid=1;
quit

Apache Config

Now, we can setup apache config. Our local vhostutil is good for this. Respond to prompts appropriately.

vhostutil create

If using sitealias in apache, make sure to symlink the main directory to any viable sitealiases

Other Pieces

httpd

Still need to add a few bits to the conf file to get things working.

  • Verify that DirectoryIndex includes index.php (vhostutil at one point didn't include that version)
  • Verify that AllowOverride is set to All so that drupal .htaccess file can do rewrites as needed

vhostutil

Still need to setup the virtual host to point at the install. vhostutil attempts some autodetection of a drupal site... Improved as of 2012-05-21.

SELinux

These first two steps need to be done just once per OS (VM or Iron).

Set up an semanage rule for vhosts if not done

Use semanage/restorecon to resolve context issues:

semanage fcontext -a -t httpd_sys_content_t "/var/www/vhosts(/.*)?"     # add a context rule for everything below the /var/www/vhosts directory 
setsebool -P httpd_can_sendmail on   # allow drupal-7 (and others?) to send email from a CentOS-6.x box:

restorecon

restorecon -Rv /var/www/vhosts/   # This should be done as needed.

Sendmail from HTTPD

If this is a first drupal install on this VM, you may want/need to enable sendmail from httpd

setsebool -P httpd_can_sendmail on

Filesystem Updates

files directory

The sites/default/files directory in drupal needs to have permissions set such that the httpd process can create files in the directory.

cd /var/www/vhosts/$n/sites/default
chown apache:apache files;   chmod 775 files   #chown and chmod the directory

tmp directory for Image styles

ZB discovered that Image styles needs a temp dir to resize images. Seems there are some permission issues with /tmp. One solution is to create a tmp dir in the root of the drupal install

cd /var/www/vhosts/$n
mkdir tmp
chown apache:apache tmp;   chmod 775 tmp   #chown and chmod the directory
Configure Image styles

Got to Configuration->Media->File system, set Temporary directory to "tmp"

cat <<EOF   # not sure if this is needed, as ZB did not think he did this, so maybe thats done by the config menu in ImageStyles.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Deny from all
Options None
Options +FollowSymLinks
EOF

Should probably see if we can figure out why /tmp wasn't working. One possibility is to create a /tmp/drupal with the appropriate permissions.

Log In

Check to see that the site exists and you can log in with pw provided when you ran the site-install script.

If it all works, then:

  • reset admin password and add an email address
  • add a sysadm account? must use a different email address
  • add an account for whoever is driving the install?
  • Update Configuration:Site Information

modules

cd $n

Add modules as needed - most of these are pretty standard - Although some of the imageapi line may be in core now

drush dl ctools token views cck panels context libraries backup_migrate features xmlsitemap date link pathauto   # some of the must-haves and basics
drush dl wysiwyg ckeditor   # coeditor is very nice, but requires additional installation from ckeditor.org
drush dl imageapi
drush dl webform
# outdated entries - think these are in core already
drush dl filefield imagecache imagefield jqueryui
# ACL stuff
drush dl content_access og # ACLs for content types and organic groups
# graphics goodies
drush dl views_slideshow
drush dl galleryformatter    # jQuery gallery formatter (used in eot.nees)
drush dl jquery_ui         # possibly needed for views slideshow cycling  - additional installation required
# business/admin/development
drush dl piwik  # allow easy plugging into web analytics
drush dl devel module_filter admin  # some administrative/development goodies
drush dl admin_menu  # pretty sure this is the one we like
drush dl mytinytodo   # enable module, update perms, create content type, add mytinytodo field
drush dl quicktabs     # use tabs for different blocks...
drush dl captcha recaptcha   # captcha and recaptcha modules - aaron got google key for recaptcha
drush dl biblio  # bibliographic module - interfaces with EndNote (not tested yet)
# theme options
drush dl omega delta   # Omega, very flexible theme, couple with delta and context to go crazy
drush dl mayo      # interesting flexible theme
drush dl fusion mix_and_match  # a theme we used for the first pass at ERI drupal site
drush dl calendar 
# these are from the drupal 7 update install of the new www.eri.ucsb.edu
drush dl feeds uuid node_export    # feeds allows you to create nodes from RSS feeds or import files, node export allows you to export nodes in xml to import to feeds
drush dl entity services
drush dl job_scheduler     # needed to export feeds?
drush dl views_bulk_operations
drush dl entity

If wrapping in https (always a good idea)

drush dl securelogin # makes sure that login form is secure, can add other forms as well

Some other items to consider (from it.eri.ucsb.edu install

drush dl entity freelinking wikitools mediawiki 
drush dl entityreference
drush dl responsive_menus   # 
drush dl responsive_dropdown_menus   # another interesting option

The admin module is a menubar on the left side that can be hidden except for a triangular wrench icon in the upper left corner. Have to play with it a bit more, but I think that I like the admin_menu setup better.

The admin_menu module is a menu that replaces the toolbar but has cascading, dynamic menus - appearance can be varied. By adding "Administration menu Toolbar style", it can be made to look more like the original, but with the drop down menus. The display without this is much more compact...

Should disable toolbar module if using admin admin_menu, otherwise you get a stacked pair of menubars (one from each)

Config using drush

Here is some config that can be done using drush

cd /var/www/vhosts/$n/sites/default
drush dis toolbar admin           # disable standard admin toolbar and admin module (possibly not enabled anyway)
# enable the admin_menu module with an improved drop down menu system that mimics the original toolbar a bit
# module filter, more compact module display
drush en admin_menu admin_menu_toolbar  module_filter

ERIMM subtheme

This requires the following modules/themes be installed

drush dl fusion fusion_accelerator mix_and_match

Configuration (first pass, may not be completely correct)

Login as administrator

Appearance

  • ERIMM - Enable and Default -- Save
  • ERIMM settings
    • deselect Site Name and Site Slogan
    • change Body Background color to gray
    • grid settings
      • First sidebar width 3 of 16
      • second sidebar witdth 2 of 16

Structure - Blocks

  • move search form into header region
  • save

Adaptive/Responsive Themes

adaptive_theme

drush dl adaptivetheme pixture_reloaded footheme  # base adaptive them, pixture reloaded sub theme and then foo theme with is a template to subtheme any subtheme of adaptive

References/Related