Drupal

From GeilThings

Jump to: navigation, search
Drupal
General
Version 7.22
Stable 7.22
Function Content Management Software
Scripts

Contents

     Drupal balloon.JPG

General

Installing Drupal

Official page: http://drupal.org/documentation/install
Very good: http://drupal.org/documentation/install/developers
DRUPALPARENTPATH=/path/to/drupal/parent/folder
DRUPALFOLDERNAME=drupalfoldername
MYSQLADMINUSER=root
MYSQLADMINUSERPASSWORD=mysqladminuserpassword
DRUPALDATABASENAME=drupaldbname
 
RAWNEWVERSION=`curl -d "action=ask&query=[[Drupal]]|%3FStable&format=json" http://www.geilthings.com/api.php` 
# Get Version as Substring.
# Using grep to sed to extract STRING between first occurrence of MATCH1 and next occurrence of MATCH2:  
# http://stackoverflow.com/questions/4392106/sed-extract-string-between-first-occurrence-of-match1-and-next-occurrence-of-m  
NEWVERSION=`echo "$RAWNEWVERSION" | grep -Po '^.*?\K(?<=Stable\":\[\").*?(?=\")'`
# Check.
echo ${NEWVERSION}
 
cd ${DRUPALPARENTPATH}
wget http://ftp.drupal.org/files/projects/drupal-${NEWVERSION}.tar.gz
tar -xzvf drupal-${NEWVERSION}.tar.gz
mv drupal-${NEWVERSION} ${DRUPALFOLDERNAME}
cd ${DRUPALFOLDERNAME}
cp sites/default/default.settings.php sites/default/settings.php
chmod a+w sites/default/settings.php
chmod a+w sites/default
 
# Create drupal database.
mysql -u ${MYSQLADMINUSER} -p${MYSQLADMINUSERPASSWORD}
CREATE DATABASE drupaldbname;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON drupaldbname.* 
  TO 'drupaluser'@'localhost' IDENTIFIED BY 'drupaluser_password';
FLUSH PRIVILEGES;
EXIT;
 
# Create a .conf file for the drupal site.
httpd -k restart
# Drupal recommends to install the PHP mbstring extension for improved Unicode support.
# If using the php53 packages in CentOS 5.x, yum install php53-mbstring
yum install php-mbstring
# Go to the url of the drupal site with the browser.
# Follow instructions.
 
chmod a-w ${DRUPALPARENTPATH}/${DRUPALFOLDERNAME}/sites/default/
chmod a-w ${DRUPALPARENTPATH}/${DRUPALFOLDERNAME}/sites/default/settings.php
 
# Installing a cron job for drupal:
# http://drupal.org/node/23714
crontab -e
# insert with i
http://drupal.org/node/23714
0 * * * * /usr/bin/wget -O - -q -t 1 http://www.mysite.com/cron.php

Upgrading Drupal


APPNAME=drupal
DATABASENAME=databasename
MYSQLADMINUSER=root
MYSQLADMINUSERPWD=super_secretisimo_password
 
# PATHTOAPP: No trailing slash.
# e.g. /var/www/html/drupal_site
PATHTOAPP=/path/to/drupal_site
 
DATE=`date +%Y-%m-%d`
 
RAWOLDVERSION=`curl -sd "action=ask&query=[[Drupal]]|%3FVersion&format=json" http://www.geilthings.com/api.php`
# Put Old Version here.
OLDVERSION=`echo "$RAWOLDVERSION" | grep -Po '^.*?\K(?<=Version\":\[\").*?(?=\")'`
# Test
echo $OLDVERSION
 
RAWNEWVERSION=`curl -sd "action=ask&query=[[Drupal]]|%3FStable&format=json" http://www.geilthings.com/api.php` 
# Get Version as Substring.  
# Using grep to sed to extract STRING between first occurrence of MATCH1 and next occurrence of MATCH2:  
# http://stackoverflow.com/questions/4392106/sed-extract-string-between-first-occurrence-of-match1-and-next-occurrence-of-m  
NEWVERSION=`echo "$RAWNEWVERSION" | grep -Po '^.*?\K(?<=Stable\":\[\").*?(?=\")'`  
echo $NEWVERSION
 
# Backup.
 
# The script breaks if variable names are not enclosed with {}
BACKUPDIR=/home/backup/${APPNAME}/${APPNAME}_${OLDVERSION}_${DATE}
echo $BACKUPDIR
 
# Create backup directory if it does not exist.
if [ ! -d "${BACKUPDIR}" ]
then
    mkdir -m 755 -p ${BACKUPDIR}
fi
 
cp -rp ${PATHTOAPP} $BACKUPDIR
 
# Backup database.
mysqldump -u ${MYSQLADMINUSER} -p${MYSQLADMINUSERPWD} --add-drop-table ${DATABASENAME} >> $BACKUPDIR/${APPNAME}_${OLDVERSION}_${DATE}.sql
 
rm -rf ${PATHTOAPP}/includes
rm -rf ${PATHTOAPP}/misc
rm -rf ${PATHTOAPP}/modules
rm -rf ${PATHTOAPP}/scripts
rm -rf ${PATHTOAPP}/themes
rm -f ${PATHTOAPP}/*
rm -f ${PATHTOAPP}/.*
 
cd /opt
wget http://ftp.drupal.org/files/projects/drupal-${NEWVERSION}.tar.gz
tar -zxvf drupal-${NEWVERSION}.tar.gz
/bin/cp -fr /opt/drupal-${NEWVERSION}/* /opt/drupal-${NEWVERSION}/.htaccess ${PATHTOAPP}
 
# Login into the drupal site. 
# If in maintenance mode: http://www.site.com/?q=user
 
# Go to  http://www.mysite.com/update.php
# Follow instructions.
# ...
 
# Logged into the drupal site, go to Administration / Reports / Status report
# If error appears: The directory sites/default/files is not writable
chown -R apache. ${PATHTOAPP}/sites/default/files

Versions

Software name Version number Version date
Drupal 7.18
7.19
7.20
7.21
7.22
2 January 2013
17 January 2013
22 February 2013
8 March 2013
18 May 2013

Comments

blog comments powered by Disqus