Beginning Drupal, part 3

Continuing to learn Drupal on Mint Linux 9 running on VirtualBox.

Starting lampp automatically

I’m already getting tired of having to start the lampp setup every time.  There must be a way to script a startup script in Linux for this.

And there is, at Tips4Linux.com.  Many thanks and full credit to that site!

First, in the Terminal, I create a file (what we used to call a batch file in good ol’ MS-DOS):

sudo nano /etc/init.d/local.autostart

Which opens up an editing box.  I put in the first line:

#!/bin/sh

and then add my commands:

sudo /usr/sbin/apache2ctl stop to halt any existing web server, and

sudo /opt/lampp/lampp start to start up everything I want with lampp instead.

I exit the file with Ctrl-X and it asks about saving it, so I agree, save as the given name, and I’m out.

Then I need to permit execution with sudo chmod +x local.autostart (since I’m in the directory already)

and set it to run at startup: sudo update-rc.d local.autostart defaults 80

and when I reboot, I see no difference or need no special passwords.

Apparently it worked, however, because Firefox comes right up with the localhost and the Drupal pages.

Customizing the Theme CSS

Drupal for Dummies covers customizing the CSS for the theme pretty well.

Image Gallery

Chapter 13 covers an image gallery.  I need to add a module, which I get from the original Drupal.org site, called Image.

This provides a number of image functions for a web site, primarily as part of a thumbnail contents list for any images posted.

And on…

Additional Modules

Interesting section in the book on recommended modules to add.

One for your FAQ section.  One for CAPTCHA to reduce spam, although that’s been overcome with brute force attacks of lots of cheap typists, apparently (the 21st-century equivalent of a million monkeys on a million typewriters, turning out not Shakespeare, but CAPTCHA translations for spamming purposes… now, that’s depressing… ).

Beginning Drupal, part 2

Now that I have a Drupal installation on the Mint Linux, I can start the real work of setting up a website using Drupal.  I hope.

It’s another day, and another start of my VirtualBox installation of Mint 9 Linux, so I have to start the LAMPP again (details in last post).  Perhaps I’ll get around to having this happen automagically later.

Oops.  A web server is running already.  I have to do sudo /usr/sbin/apache2ctl stop to shut all that down, first.

Then I start lampp again: sudo /opt/lampp/lampp start .

I start Firefox and go to http://localhost/drupal .

I get a warning that cron hasn’t been run.   I can do it from a link there manually, so that’s taken care of.  This is supposed to be doing maintenance tasks, whatever might be needed for this.

I also have a warning on the settings.php file about making it non-writable.  I pull up the file, right-click and change the permissions.

In the left column, there’s a “My account” link for the administration stuff.  No need to change that since it gets set up during the Drupal installation.

Under Administer we have content creation and similar useful functions.

Content management seems to be mostly about setting up the more blog-like functions of the site.

Site building has Blocks, Menus, and Modules, along with Themes.  The book suggests changing the theme, just for practice.  This changes the overall appearance theme for the web site.

Site configuration is the general rules control for the web site.  I tweak the Site information to make the name read “Over-Automated Librarian” properly.  I also add a footer for the catch phrase, and use HTML code to italicize it.  It all works as it should.

The book Drupal for Dummies has a long section now on users and settings permissions.

Content

The book mentions nodes, which is defined as a block of content, whether in a web page or a story or a blog post.

There’s a step-by-step to create a page, and then how to edit a page.  The page I create now is at http://localhost/drupal/node/2 which explains the business about nodes, somewhat.

Pages don’t show up at this point.  Another story, however, shows up at the top of the home page, like any blog post.

Editing a page is a little interesting.  You can choose the weight of the page, which is similar to the page numbering function in WordPress, but in this case it works rather like a real weight would — the higher the number, the lower it sinks.  Above zero, you move up higher than ground level to the top at -50.

You can also promote it to the front page, or make a post “sticky” like you can in WordPress, so it stays at the top no matter what until you make it unsticky.

Input format: Web URLs and email addresses automatically work as proper links.  Nice to avoid having to do all that in HTML.

Images are in HTML code.  Those have to be linked to the file on a server, as usual.

More on Themes.  By changing to the Pushbutton theme, I get the Pages in the header  and footer, along with the posts.

I can also change the logo.  This gets squashed in the Pushbutton theme if it turns out to be too tall.  No dimensions are given so it seems to be trial and error.

Content (text, menus, graphics, etc.) is grouped into blocks.  Blocks are put into Regions on the web page: the header, footer, left sidebar, right sidebar, and the middle Content region.

Modules are the interesting part.  These are enabled to handle various functions, such as blogs, polls, trigger events, and a batch of other features which can be enabled.  Turning on the Blog module adds “Blog entry” to the Create content options.

New Themes

Chapter 10 covers getting new themes.  Track down the location of themes which turns out to be /opt/lampp/htdocs/drupal/themes and download the themes to there.  I have to use Archive Manager to uncompress them first, then select the new ones and try them out.

It’s a lot like the WordPress blog themes — some work for what you need to do, some don’t, some have the features needed, some don’t.

poormanscron

Drupal for Dummies recommends adding the poormanscron module and gives instructions on that.  This will update modules and themes automatically.

Provided… you configure it.  The book doesn’t cover version 2.2.

The book says it goes in “your Drupal modules directory” but the readme file says that you actually should go into the sites directory, not modules.  Always check the latest readme file, I’ve found in both Windows and Linux.

I go to /opt/drupal/sites/all and create a new modules subdirectory.  I had to change permissions, of course — nothing can be done in Linux without stopping to change permissions at least once somewhere or other.  This is good for security (but a nuisance to set up anything) and only then can you put the poormanscron in there and uncompress it.  That should make it available to every web site done in Drupal.

Contrary to the book and to previous versions, the web page for poormanscron says “The 2.x version no longer has its own module page at admin/settings/poormanscron. You will find the ‘Automatic cron’ poormanscron setting at admin/settings/site-information at the bottom of the page.”

This turns out to be only a timer for how often it runs.  I set it to every hour.

There’s also info in the book on checking the reports on “Available updates” regularly.  I’m okay at this point, everything up to date.

Backup

Now comes the backup.  This involves going back to the localhost page and into the phpMyAdmin to find the Export tab.

In the Export box, I select drupal and click the SQL radio button.  I want to save that database I set up back at the start.  Then I want

  • Structure
  • Add IF NOT EXISTS
  • Add AUTO_INCREMENT value
  • Enclose table and field values with backquotes
  • Data
  • Complete inserts
  • Extended inserts
  • Use hexadecimal for BLOB Export type

Then I change it to use zipped compression.  I had to create a new folder in the ones under my name, titled Backups, and then save the resulting localhost.sql.zip file in there.  Using list view, I can see the date of creation, so I know when the file is current.  Then I rename it with the date as part of the name (an easy way to differentiate a lot of files named with “localhost.sql”).

I think it worked.  I’m going to assume it did, rather than testing to destruction and restoring from the backup.  This is just an exercise.  If it were a regular operating web site, though, I’d probably move my existing stuff off somewhere temporarily and try to actually do a restoration.

Updates

Now come updates.  I needed to backup before doing those, anyway.

In Firefox, I add updates.php to the end of the URL and get a Drupal page of instructions on doing that.

Oh… the backup I already did wasn’t enough.  I need to copy the entire Drupal directory to a safe place.  So, I open up the files, do a copy, and put that in the Backups directory I just created, along with the database backup.

Now I put the site in maintenance mode by taking it offline in Administer > Site configuration > Site maintenance and click off-line and save it.  They have a polite little message for anyone who tries to access the site while it is offline, which you can customize.

However, this is just an exercise, and I have nothing to actually update, so I turn it back on again and save the setting.

Making progress, I think.  This is just the dull maintenance side.

 

 

Beginning Drupal, part 1

So, now that I have a Mint Linux installation running off a network drive, I wanted to start learning some of the new web stuff we’re going to be using.  In fact, the entire campus will be using it, so while the Web Librarian gets to do this in detail, I just have to get some basics down so I can backstop him (and in the immortal words of Snoopy, “I hope that an emergency will never occur.”).  Besides, this is a good way to keep my own 20th-century hand in.

First, I’m starting with Drupal, which is, essentially, a system software for setting up well-integrated websites (well, for our purposes, that’s what we needed it to do).  I just need to do this on a local PC for my own practice, not actually have it open on the Internet, so I’m not going to worry much about security while I practice on this (so only do this at home, kids — in the real world, you gotta lock it all up tightly).

Now the apparent method would be to check the Mint Linux Synaptic Package Manager and find the Drupal package, and install it.

But, looking at Drupal for Dummies (Lynn Beighley, 2010), it becomes clear that I need some other stuff first.  Mint doesn’t come with all the necessary web server stuff installed, but then again, why should it?  You only add that if you need it.  Now I do.

Drupal needs, the book says, Apache, MySQL and PHP installed first.  I could do that by just using the Linux package installer, but I could also miss parts of what I need.  Better if I can get a complete package of all of that together (and trust me, I learned the hard way first).

The book recommends XAMPP (formerly LAMPP) from http://www.apachefriends.org/en/xampp.html so I go there using Firefox in Linux (since I’m going to download it to the Linux system anyway).  (If I’d wanted to do it on a Windows system, the book recommends http://www.wampserver.com for WAMP, and there’s a Mac alternative as well.)

Hmmm… XAMPP “distribution for Linux systems (tested for SuSE, RedHat, Mandrake and Debian) contains: Apache, MySQL, PHP & PEAR, Perl, ProFTPD, phpMyAdmin, OpenSSL, GD, Freetype2, libjpeg, libpng, gdbm, zlib, expat, Sablotron, libxml, Ming, Webalizer, pdf class, ncurses, mod_perl, FreeTDS, gettext, mcrypt, mhash, eAccelerator, SQLite and IMAP C-Client.”  That should do it.

Firefox wants to open it with the Archive Manager (since it is a compressed file).  When the download finishes, Archive Manager pops up but it hasn’t got permission to extract it where I need it.  Typical Linux.  Ignore the Archive Manager and just download it.

Instructions are given at the LAMPP site for installation, however.

The file is in /tmp so I open a terminal (you may as well keep it open, too), become su (superuser) and go into the /tmp and tell it:

tar xvfz xampp-linux-1.7.3a.tar.gz -C /opt

to extract to the /opt directory.

I change to the root directory.  Now I use /opt/lampp/lampp start to start the LAMPP installation.

That works.  It starts up several things and finishes.

I open another Firefox tab and send it to http://localhost/ and I get a LAMPP screen.  Looks good.

One of the choices on the LAMPP site is for English, so I click on that.

On the left, a sidebar of operations… and the phpadmin that I need next.  Click on phpadmin.

I have to create a database, so I fill in the name drupal and click on Create for that.  No other changes at this point.  Important detail to note: the username for the database is root@localhost so make a note of all that.

Now, a new Firefox tab and go to drupal.org for the latest version of that.  Turns out to be version 6.19.

Now comes the tricky part.  The book gets extremely vague and says to copy it to “your local Web server directory.”  And to limit the name to just “drupal.”

I’ll save you the trial-and-error.  It goes into /opt/lampp/htdocs and you can use (in Terminal) the move/rename command mv with the before and after versions of the name: mv drupal-6.19 drupal.  (You are still in su mode, right?)

(I haven’t worked so heavily with operating system commands since I got past Windows 95.  Just keep the Terminal program open through all this.)

Following that, you can use Firefox to go to http://localhost/drupal and get the Drupal install screen.

“Install Drupal in English”.  Sounds simple enough.  Nope — too simple.  I’ll give the trial-and-error here, finishing with the solution.

It first wants me to get back into the /opt/lampp/htdocs/drupal/sites/default directory and rename a file: mv default.settings.php settings.php so Drupal has some starter settings to use.

Still not cooperating.  Change the permissions: chmod o+w settings.php so anyone can change it.  This is the command in the install.txt file that came with Drupal.  So I go back through all the directories and subdirectories, just in case, and do the chmod o+w for all of them.

Now it shows a screen for “Database configuration” and I enter the drupal name that I created earlier.  The username is root and the password is blank.  (Yes, not good security, but this is only for my training on this and not for general Internet consumption.)

And… it won’t accept it.  The advanced options just has the host name which is, of course, localhost.  The username will not accept anything with a @ symbol so that’s out.  The link for XAMPP to MySQL documentation (which is what the book refers me to) is broken.  <sigh>

I checked the web, and found that in an older version of Drupal, the kink was in the settings.php file.  Some people just changed the link info for the database in that file.

However, I checked the install.txt file in the drupal directory.  It talked about renaming the default.settings.php file — but it also offered the option to simply create a blank file of the proper name.

Solution: So, I created an empty file in the right place named settings.php and gave it a chmod 777 settings.php to open up permissions.

Then I tried to do the “Database configuration”.  It worked.  Go figure.  Apparently, it just needed to do its own thing with that settings file without any previous guessing.  It couldn’t create the file, but it could fill it in after that.

Now I got to “Configure site”.  The book says change the localhost name to a title that makes sense for your current site.  I used (of course!) OverautomatedLibrarian.  (I wasn’t sure if it would take a space or a hyphen, and at this point, I just wanted to get past the hurdle.)

I entered an email address, set an administrator name and password, checked the time zone, made sure Clean URLS and update notification were both on.

I got a configuration complete message with a pink warning that it could not send emails.  Might be something with being run in VirtualBox?

Now http://localhost/drupal gets me my new site with “OverautomatedLibrarian” displayed at the top.  I’m finally up to Chapter 3 in Drupal for Dummies.

Whew!  Shadrach, Meshach, and Tobedwego….