Monday, January 24, 2011

Drupal 101 - Installing and configuring Drupal 6

This paper was delivered at Boise CodeCamp on March 26th and 27, 2010 as part of the Drupal Track. I am an active member of the Boise Drupal Group.

Drupal System Requirements (Both 6 and 7)

Drupal requires a web server, PHP 4 (4.3.5 or greater) or PHP 5 (http://www.php.net) and either MySQL (http://www.mysql.com) or PostgreSQL (http://www.postgresql.org). The Apache web server and MySQL database are recommended; other web server and database combinations such as IIS and PostgreSQL have been tested to a lesser extent. When using MySQL, version 4.1.1 or greater is recommended to assure you can safely transfer the database. For more detailed information about Drupal requirements, see (http://drupal.org/requirements).



For detailed information on how to configure a test server environment using a variety of operating systems and web servers, see "Local server setup" at http://drupal.org/node/157602
Installing Drupal 6.x on Linux
Installation Candidates (Not Inclusive)
Ubuntu 9.10/LinuxMint8
Fedora 12
SLAMPP 2.0.2 (Slackware 12.2)
Each version (called distribution or distro) of Linux has its own Drupal 6 installation process but the good thing is that the Ubuntu and Fedora support Drupal 6 with an automatic downloading and configuring of the base installation (before configuration)

Before installing Drupal 6, you must have Apache, MySQL, and PHP5 installed. Since these are server components, they are not found in a normal desktop configuration.

Webserver Building
Note: You should be logged in the ‘root’ user in at the command line while installing server components. Procedure below provides the commands to be entered at the command line prompt, all as one line with no carriage returns (automatic line wrap), press enter when complete.

I. Ubuntu 9.10/LinuxMint 8 (Updated for LucidLynx 10.04)
Install MySQL if not installed:
1) apt-get install mysql-server mysql-client libmysqlclient15-dev mysql-doc-5.0
Ubuntu installation of MySQl will prompt you for passwords during installation. If you are not prompted to set the passwor or use a different installer, you should set the password as follows:

mysqladmin -u root password your-new-password
mysqladmin -h root@local-machine-name -u root -p password your-new-password

2) vi /etc/mysql/my.cnf
Comment out line shown below
# bind-address 127.0.0.1

3) Restart the MySQL server: /etc/init.d/mysql restart
Install Apache if not installed:

4) apt-get install apache2 apache2-doc apache2-mpm-prefork apache2-utils apache2-suexec libexpat1 ssl-cert

5) Extend PHP Support (tested on Ubuntu 10.04)

apt-get install libapache2-mod-php5 libapache2-mod-ruby libapache2-mod-python php5 php5-common php5-curl php5-dev php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-mysql php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl autoconf2.13 autoconf-archive gnu-standards php5-suhosin

apt-get install automake1.10

apt-get install gfortran-4.4

apt-get install autoconf-doc gettext libapache2-mod-python-doc liberuby uw-mailutils libtool-doc libmcrypt-dev mcrypt gcj

apt-get install php-apc #Speed up PHP

6) vi /etc/apache2/mods-available/dir.conf
# DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.php3 index.pl index.xhtml

7) mod-rewrite enable:
cd /etc/apache2/mods-enabled/
ln -s ../mods-available/rewrite.load
vi /etc/apache2/sites-available/default:
Change Document Root /var/www directory entries for /var/www to
AllowOveride All instead of None. Exit vi with write quit.

service apache2 restart (new command in 10.04)

Verify that mod_rewrite is working:
apache2ctl -M
rewrite_module should now be in list

8) Enter each of the following individually at the command line prompt:

a2enmod ssl
a2enmod suexec
a2enmod include
a2enmod dav_fs
a2enmod dav

9) /etc/init.d/apache2 restart

10) Install phpmyadmin: apt-get install phpmyadmin

Now you should be able to goto http://localhost/phpmyadmin andlog in using root as username and the root password created during the installation of MySQL server.

Installation reference: http://www.ubuntugeek.com/howto-install-mysql-database-server-with-phpmyadmin-frontend.html

Now you are ready to install Drupal on Ubuntu which is covered in the Drupal installation section of these notes.

II. Fedora 12

Fix sudo users file so you can use sudo su - for root access without being prompted for password and/or being denied:
echo 'username ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
(You must be logged in as root at the root prompt).

1) Install MySql command: yum install mysql mysql-server

Chkconfig command to setup MySQL to start at boot time: chkconfig --levels 235 mysqld on
Start MySQL: /etc/init.d/mysqld start
2) Set the root password from the command line (as root or sudo):

mysqladmin -u root password sqlpassword
mysqladmin -h server.example.com -u root password sqlpassword

3) Install Apache command: yum install httpd
Chkconfig command to setup MySQL to start at boot time: chkconfig --levels 235 httpd on
Start Apache: /etc/init.d/httpd start
You should now be able to view the webserver in the browser as localhost.

4) Install PHP and restart Apache

yum install php
/etc/init.d/httpd restart

5) Install MySQL PHP5 support in Apache (kitchen sink approach). yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-eaccelerator php-magickwand php-magpierss php-mapserver php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy
(Enter the above as all one line).

/etc/init.d/httpd restart
6) Install phpMyAdmin
yum install phpmyadmin

7) Enable remote access to phpMyAdmin by commenting out the phpMyAdmin.conf as shown below.
Commmand: vi /etc/httpd/conf.d/ phpMyAdmin.conf :

Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin
#
# order deny,allow
# deny from all
# allow from 127.0.0.1
# allow from ::1
#

8) Restart Apache one more time
/etc/init.d/httpd restart

II. SLAMPP 2.0.2 (Slackware 12.2)

SLAMPP is “out-of-the box” ready to go for Drupal installation which includes configured rewrite_module along with Apache, MySQL, PHP5, and phpmyadmin.

Create Drupal Database and Drupal DB User (All Linux's)

a) mysql -u root -p
use password your created when installing MySQL
b) mysql> CREATE DATABASE drupal;
Query OK, 1 row affected (0.00 sec)
c) mysql> CREATE USER 'dp_user'@'localhost' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)
d) mysql> GRANT ALL ON drupal.* TO 'dp_user'@'localhost' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)
e) mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
f) mysql> EXIT

Note: You can also do this using phpMyAdmin with a single SQL query:

CREATE DATABASE drupal;
CREATE USER 'dp_user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL ON drupal.* TO 'dp_user'@'localhost'IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

Then press GO and the all is done.
Installing Drupal

I.Ubuntu 9.10/LinuxMint 8 (Updated for LucidLynx 10.04)

1) apt-get install drupal6

Notes:
Be sure to allow db_config to run completely so it will setup the database user and database to be used by Drupal.
The Drupal 6 install by Ubuntu should not be considered a standard install and the config files are located in non-standard locations such as /etc/drupal/6 and dbconfig-common is used in the installation.
If you have problems with an installation, you can try re-installing with apt-get –reinstall install drupal If you have the gui desktop available, you can use synaptic to do a “complete removal” and reinstall. I have observed that reinstalling can be a bit troublesome.

I have observed at least one instance where it was necessary to link in the Drupal6 directory to the web root directory. The command: ln -s /usr/share/drupal6 /var/www/drupal6

2) Update to PHP GD2 Bundled for Imagerotate functionality for Drupal
Reference: http://wiki.slicehost.com/doku.php?id=php5_with_bundled_gd

apt-get install build-essential debhelper fakeroot
apt-get source php5
apt-get build-dep php5
cd php5-5.3.2 (your version number may be different)
vi debian/rules
search and change --with-gd=shared,/usr – to
--with-gd=shared --with-gd=shared --enable-gd-native-ttf \
(remove comma and /usr)

compile with dpkg-buildpackage -rfakeroot (Will take a while!)

Install gd2 bundled:
dpkg -i php5-gd_5.3.2-1ubuntu4_i386.deb
check phpinfo.php to verify it is active.

3) Install Drupal 6:
apt-get install drupal6
cd /usr/share/drupal6/
vi .htaccess (set rewrite root to drupal6

4) /etc/init.d/apache2 restart
(Picks up new vitural website created by installation script)

If Drupal6 is not accessible in Browser:
ln -s /usr/share/drupal6 /var/www/drupal6

5) First run: http://localhost/drupal6
The home page reference will automatically run install.php and/or let you know if there are problems in your installation that prevents installation.

6) Enter the information requested for installation
After autologin to website, and click on administration, you may get a security warning. You may have to update Drupal to the current release as Ubuntu installs an older version of Drupal6. Drupal will give you a security alert when there is a newer release available and provide a link to download the latest release. To update, follow this procedure:

1. After downloading, extract the zipped tar file with the following command:
tar -zxvf drupal-6.16.tar.gz
(substituting the downloaded version number for 6.16)
2) Enter the directory where the file is extracted:
cd drupal-6.16 (again substituting the downloaded version number for 6.16)
3) Run the following command:
cp -R * /usr/share/drupal6/. (review errors but the .profile and .sites cp errors are to be expected)
4) Login to Drupal as the 1st user (admin user).
5) Put Drupal in offline mode. Located under Administer | Site configuration | Site maintenance.
http://localhost/drupal6/update.php?op=info
6) Run the Update: http://localhost/drupal6/update.php

Run the update script by clicking on Continue from the update.php page
Then click on Update (update selection is automatic).
Click on "logged" to check logged errors.

7) After update, review any errors, and then put the site back online.

Note: Documentation recommends that at this point you backup both the /usr/share/drupal6/ folder (recursively) and do a mysql database backup (dump), just incase something should go wrong and that you change the theme back to the default theme. If this is a new install, you do not need to do this usually.

7) Your Drupal site is now ready for configuration and use.

II.Fedora 12 Drupal 6 Installation

1) yum install drupal

Create link from installation directory to web directory.
ln -s /usr/share/drupal /var/www/html/drupal

2) Edit drupal.conf
Uncomment Allow from 127.0.0.1 and Allow from all in drupal.conf
vi /etc/httpd/conf.d/drupal.conf

3) /etc/init.d/httpd restart

4) Copy & set permissions on files:

chmod -R 777 /var/www/html/drupal
cd /etc/drupal
chmod 777 default
cp default/default.settings.php default/settings.php
chmod 666 default/default.settings.php default/settings.php

5) first run: http://localhost/drupal/install.php
6) Enter the information requested for installation
7) When configuration is complete, secure configuration files:

cd /etc/drupal
chmod 755 default
chmod 644 default/default.settings.php default/settings.php

8) You can configure Drupal 6 to your preferences and begin putting it into use.

III. SLAMPP 2.0.2

Perform installation while logged into as the root user.

This link may be helpful if you have any questions: http://www.basicconfig.com/linuxsoftware/setup-configure-drupal-slackware-linux-tutorial

1) Download latest Drupal (currently 6.16) from www.drupal.org, link is on home page.
2) cd to directory where file is downloaded. Extract file: tar zxvf drupal-6.16.tar.gz
3) cd drupal-6.16.tar.gz
4) mkdir /usr/share/drupal
5) cp -r * /usr/share/drupal/.
6) cp -r .htaccess /usr/share/drupal/.
7) vi /etc/httpd/httpd.conf
Edit line 214 to read AllowOverride All which enables the ‘.htaccess’ file to be read (Rewrite Engine).
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All

8) vi /usr/share/drupal/.htaccess
Under # Various rewrite rules uncomment the line: RewriteBase /drupal

9) Set Permissions on Drupal files
cd /usr/share/
chmod -R 777 drupal
cd drupal/sites/
cp default/default.settings.php default/settings.php
chmod 666 default/default.settings.php default/settings.php

10) Link the Drupal directory to /var/www/htdocs
ln -s /usr/share/drupal /var/www/htdocs/drupal

11) restart apache
/etc/rc.d/rc.httpd restart

12) Open the web browser to http://localhost/drupal/
Answer prompts as follows:

Install Drupal in English, yes?
Select mysqli (MySQL) as database
Supply Drupal database name, Drupal DB user and password created in MySQL.
Save and continue

13) Change to terminal session from browser, cd to /usr/share/drupal/sites if not already there. Set permissions from command line:

chmod 755 default
chmod 644 default/default.settings.php default/settings.php

14) Return to web browser Configure site page and enter information.
Note: User entered here is the "admin" or user1 Drupal user and that ‘CleanURLs’ should be automatically enabled on SLAMPP.

Save and continue

Drupal is now installed.

You are now ready configure and build your Drupal website.

Configuring rewrite engine for CleanURLs

I. Ubuntu 9.10/LinuxMint8 enabling of CleanURLs

1) vi /usr/share/drupal6/.htaccess
Uncomment and change line that reads #RewriteBase /drupal to RewriteBase /drupal6
Exit vi with write quit (wq)
2) Using browser, go to http://localhost/drupal6/index.php
This will rerun the test to verify that rewrite is working.
3) From Drupal Naviagtion menu, select Administer, Site configuration, CleanURLs
You should now be able to enable CleanURLs and save the configuration.

Returning to the admin page, you should now get http://localhost/drupal6/admin (clean) instead of http://localhost/drupal6/?=admin
If you are still having problems with enabling CleanURLs, this URL maybe of some use in troubleshooting the problem: http://www.ghacks.net/2009/12/05/enable-mod_rewrite-in-a-ubuntu-server

II. Fedora 12 enabling of CleanURLs

1) vi /usr/share/drupal/.htaccess
Uncomment the line that reads #RewriteBase /drupal to RewriteBase /drupal
Exit vi with write quit (wq)
2) Using browser, go to http://localhost/drupal/index.php
This will rerun the test to verify that rewrite is working.
3) Select Administer, Site configuration, CleanURLs

First Time Drupal Configuration

Welcome to your new Drupal website!

Follow these steps to set up and start using your website:

1. Configure your website
Once logged in, visit the administration section, where you can customize and configure all aspects of your website.

General Settings
Administer > Site configuration > Site information

2. Enable additional functionality
Next, visit the module list and enable features which suit your specific needs. You can find additional modules in the Drupal modules download section.

Enable Modules
Administer > Site building > Modules

3. Customize your website design
To change the "look and feel" of your website, visit the themes section. You may choose from one of the included themes or download additional themes from the Drupal themes download section on the Drupal Website.

Configure Themes
Administer > Site building > Themes

4. Start posting content
Finally, you can create content for your website. This message will disappear once you have promoted a post to the front page.

5. Other Essential Configuration

Set User Permissions
Administer > User management > Permissions
Create required file area for additional modules and themes under /sites/ (using root shell)
cd /usr/share/drupal/sites or cd /usr/share/drupal6/sites
mkdir all
cd all
mkdir modules
mkdir themes

File Permissions and Ownership
http://drupal.org/node/244924

Themes – Lots of Themes to choose from!

Theme Guide: http://drupal.org/theme-guide
Themes: http://drupal.org/project/Themes
Theme Garden: http://themegarden.org/drupal6/

Backup & DB Maintenance

Reference: http://www.backuphowto.info/useful-tips-about-how-backup-drupal-installation

Backup Modules that you can add (each page provides a description of the functionality of the module):

backup module: http://drupal.org/project/backup_files
db maintenance module: http://drupal.org/project/db_maintenance
backup & migrate module: http://drupal.org/project/backup_migrate

I have also found the Backup and Restore using bash shell scripts found at http://drupal.org/node/59369 to be very useful but read the notes on using!

First Starts for Tutorials & Installation Overviews

Drupal.org Getting Started: http://drupal.org/getting-started
(The Drupal.org website should be your first stop for all things Drupal)

Drupal 6 - Overview, Installation & Upgrading: http://drupal.org/node/128752

How-to Install Drupal It's Easy: http://tips.webdesign10.com/how-to-install-drupal-its-easy

Installation Guide: http://open4a.com/files/Getting%20Started%20with%20Drupal%20v2_0.pdf

Image Galleries Tutorials

How to Make a Photo Gallery With Drupal and AJAX:
http://tips.webdesign10.com/how-to-make-a-brazilian-bikini-photo-gallery-with-drupal-and-ajax

Create an image gallery using CCK and Views: http://drupal.org/node/144725

PHP Editors

http://tips.webdesign10.com/php/drupal-editors-318.html

Sandbox Solutions (Install & Configure Drupal)

Linux:

SLAMPP - LiveDVD or HD Install
http://slampp.abangadek.com/info/
Download
http://sourceforge.net/projects/live-slampp/

Turnkey Linux Drupal 6 - VM or ISO
Note: Drupal 6 is already "installed" and is ready for configuration. A lot of extra modules are also installed for your evalutation and configuratoin.
http://www.turnkeylinux.org/drupal6

Windows:

Apache2Triad
Documentation - http://apache2triad.net/docs.php
Create an Apache sandbox using Windows and Apache2Triad - http://drupal.org/node/81988
Download - http://sourceforge.net/projects/apache2triad/

XAMPP
Simple install of Drupal on XAMPP
Requires XAMP Version 1.7.1!
http://drupal.org/node/307956
See Also:
Set up a Windows test server using XAMPP
http://drupal.org/node/161975

Useful Google Search: http://www.google.com search ‘XAMPP +Drupal’

Recommended Books

Using Drupal - Choosing and Configuring Modules to Build Dynamic Websites
ByAngela Byron, Addison Berry, Nathan Haug, Jeff Eaton, James Walker, Jeff Robbins, et al.
Publisher:O'Reilly ISBN:978-0-596-51580-5

Cracking Drupal: A Drop in the Bucket
Greg Knaddison
ISBN: 978-0-470-42903-7
Paperback
The first book to reveal the vulnerabilities and security issues that exist in the sites that have been built with Drupal and how to prevent them.

No comments: