UPDATE 10-28-2007: Revised for Drupal 5.
This is a how-to guide to install drupal (drupal runs this site) on Debian or Ubuntu.
Background:
I am running apache2 and mysql. All of my software packages were initially installed with apt-get. But when I did a “apt-get install drupal” I would always get a failure communicating with the mysql server. After getting stuck, and getting advice from 1 person I trust, and another person on a forum who sounded intelligent - you’re better off installing drupal from source rather than apt-get. So I did. I downloaded “drupal-4.6.3.tar.gz” untarred it and followed “INSTALL.txt”. This howto is intended to be followed along with the INSTALL.txt .
If I to leave details or if you are stuck on something I’ve left out, please add a comment or contact me for help. I’d be happy to further explain anything I did.
Step 0 - Prereqs
My system is currently using apache2 mysql5 and php5. You can install drupal with apache1, but unless you have a good reason to install apache1, you should use apache2. You could also install drupal with a postgres backend if you wish. If you need any of these programs, just do a:
apt-get install [package]
Where package can be any/all of the following:
apache2
php5
php5-mysql
php5-gd
libapache2-mod-php5
mysql-server-5.0
mysql-client-5.0
Step 1 - Get the Code
Go to the drupal site and download the latest drupal. For my original install, the latest drupal was: drupal-4.6.3 . Simply do this:
tar -zxvf drupal-x.y.z.tar.gz
mv drupal-x.y.z /your/full/path/to/site/www.mydrupal.com
Step 2 - Set up mysql
I got stuck on step 2 of INSTALL.txt . I did a “mysqladmin -u debian-sys-maint -p create drupal” and that worked fine. Then I got into the mysql database with this: “mysql -u debian-sys-maint -p” Note: “debian-sys-maint” is the user automatically created when you install mysql on a debian system. It is basically the admin account of mysql.
In MySQL you should create a seperate user for most databases, so you’re going to create a new user like “drupaluser” or something else - and makeup or generate a new password. Your system’s “root” mysql username (debian-sys-maint) and password are stored in /etc/mysql/debian.cnf . You’ll make a new user with the MySQL GRANT command.
My problem was with the next command in INSTALL.txt:
GRANT ALL PRIVILEGES ON drupal.* TO nobody@localhost IDENTIFIED BY ‘password’;
I was first confused by the line break and indentation - what was I supposed to enter? Keep in mind I had little experience with mysql - other than somehow getting it to work with slashcode. I soon realized that the line break is optional - it works with or without it. Whenever I entered this command in, substituting drupal for drupal, nobody for drualuser, and password for my password - I got a mysql syntax error. I finally figured out that the username, host, and password need to be encased in ” or “
GRANT USAGE ON *.* TO ‘drupaluser’@’localhost’ IDENTIFIED BY ‘password’;
GRANT ALL PRIVILEGES ON drupal.* TO ‘drupaluser’@’localhost’ IDENTIFIED BY ‘password’;
The output for the above commands should be something like Query OK, 0 rows affected (0.00 sec)
Step 3 - Populate the mysql database
Make sure /sites/default/settings.php is writable by the webserver (chmod 666 sites/default/settings.php will do it). Go to http://www.mydrupalsite.com/install.php and fill out the information. After you are done, chmod the file back to something reasonable like 644(mod php) or 600(for fastcgi).
Step 4 - Cron tasks
You need some way of hitting http://www.drupalsite.com/cron.php every hour or so. The easiest way to do this is to set up a cron job. Crontab + curl is probably the best solution to this. If you don’t have curl installed, just do a apt-get install curl
First you take the example script which is drupalsite/scripts/cron-curl.sh - and modify it to for your site, eg:
#!/bin/sh
curl —silent —compressed http://dimmeria.com/cron.php
Save it in drupalsite/scripts and do a chmod 755 drupal-lynx.sh .
Now type crontab -e this will open up your default editor, which may be vi. (side note: to change your default editor put export EDITOR=/usr/bin/vim in your .bashrc or .profile file (or equivalent command in equivlaent shell startup file. Change vim to your editor of choice).
If you don’t know how to use vi - hit, you “i” for insert, then you can type your code in. When you are done, you hit escape and then “:wq” for write and quit.
Enter this line on a new line in your text editor:
17 * * * * /complete/path/to/drupalsite/scripts/cron-curl.sh
The 17 means that the script will execute on the 17th minute of every hour. Change this if you like. After you write and quit, type in “crontab -l” . If you see your new command in there, it worked.
For more drupal cron info:
Step 5 - What’s not in INSTALL.txt, but should be
Under my administer menu, I noticed that my the php gd imaging program wasn’t installed…because of drupal’s very noticable warning message. I was missing a software package. The solution was to apt-get install php4-gd . The larger error message dissappeared.
Now drupal worked without errors, but something bothered me. Anyone could see my /database /scripts or /includes directory. I thought it was a file permissions problem at first - but it’s not. Your webserver has to be able to read those directories for drupal to function..yet you want to keep out every web browser. The problem actually was that my apache2 config file for www.dimmeria.com had not been set up to allow my .htaccess file to functioin. I had to edit /etc/apache2/sites-available/www.dimmeria.com to read:
<Directory /complete/path/name/www.dimmeria.com>
AllowOverride All
</Directory>
AllowOverride allows your .htaccess file to function. And drupal needs this .htaccess file to work. Here are the first lines of my .htaccess file:
<Files ~ “(.(inc|module|pl|sh|sql|theme|engine|xtmpl)|includes|sites|database|Entries|Repositories|Root|scripts|updates)$”>
Order deny,allow Deny from all
</Files>
The letters separated by a pipe “|” and put in parentheses () are filetypes that are blocked from webbrowsers. To the right of those are directory names. I added “includes” “sites” and “database” myself because I’d rather keep people out of files they don’t need to see. Also, you may want to move update.php into your updates folder, or somewhere else where it’s not accessible. Just in case.
Step 6a exim4 - outgoing mail
So I thought drupal was set up right. Wrong. My friend tried to create an account, and he never got emailed his password. wtf, mate? Debian installed exim4 for me automatically when I installed - but it was not configured properly. Here is how you configure exim4 on debian so that it will work with drupal (and should work with everything else too). At the command line, run: dpkg-reconfigure exim4-config Go through the configuration script. Your setup may vary from mine. Here are the steps I took:
- Do not break up the configuration file into smaller files - why make things more complicated for myself?
- “internet site; mail is sent and received directly using SMTP”
- mailname=”dimmeria.com”
- IPs to listen on =”127.0.0.1:192.168.0.x” where x is the last digit of my LAN ip. eg 192.168.0.5
- other final destinations = blank
- relay mail for domains - blank
- Relay mail for local machines - 192.168.0.0/24 (meaning 192.168.0.[1-255])
- Dial-on-demand: this is only necessary if you don’t have a constant internet connection - you’ll probably want to select no
Finally, do a
update-exim4.conf
/etc/init.d/exim4 restart
Then test your email with drupal. If anyone has any mail problems, please post them here in the comments.
Section 6b - exim4 alternate
I actually wrote section 6b before I wrote section 6a, but then my mail stopped working after 2 days. The steps in section 6a work for me, so I consider them better. For those who are brave, or desperate, here is an alternate configuration. At the command line, run: dpkg-reconfigure exim4-config Go through the configuration script. Your setup may vary from mine. Here are the steps I took:
- Do not break up the configuration file into smaller files - why make things more complicated for myself?
- “Mail sent by smarthost; received via SMTP or fetchmail”
- mailname=”dimmeria.com”
- IPs to listen on =”127.0.0.1:192.168.0.x” where x is the last digit of my LAN ip. eg 192.168.0.5
- other final destinations = blank
- relay mail for LAN IPs only - “192.168.0.0/24”
- hostname for outgoing mail: “smtp.dslextreme.com” This is because my isp is dslextreme.com. To make life easier for myself, I’m using their smtp server to send mail. I don’t know how to configure exim to send mail to any mail server..such as gmail or yahoo. Yours might be “smtp.mywebhost.com” or “mail.myisp.com” .
- Hide local mail name? This is up to you. If you want your mail to come from “mydrupalsite.com” then select no. If you want your mail to come from something you create eg “myemailaddress.com” then select yes. I selected no.
- Dial-on-demand: this is only necessary if you don’t have a constant internet connection - you’ll probably want to select no
If you’re lucky you might be done now. But I wasn’t lucky. I had to set my mailserver to send my ISP username and password to login to my ISP’s smtp server. Edit /etc/exim4/passwd.client Add a line like this:
mail.isp.com:ispusername:isppassword
eg
smtp.dslextreme.com:myusername@dslextreme.com:mypassword
Now you’ll probably have to tell exim that it’s okay to send clear-text passwords. Otherwise it will try to encrypt the password - which your isp may not like.
Edit /etc/exim4/exim4.conf.template Add these lines:
#For SMTP Auth
AUTH_CLIENT_ALLOW_NOTLS_PASSWORDS = 1
Finally, do a
update-exim4.conf
/etc/init.d/exim4 restart
note: If you connect to the internet through your isp, sending a clear-text password to them isn’t much of a security risk…your password should only be travelling a short distance over your ISP’s equipment. However, if you really care about your password security you should figure out how to send an encrypted password to your ISP with exim4 (in which case, do not add the above line). However, you’ll have to read a different howto to figure that out.
Conclusion:
I hope that I helped someone. Comments are welcome.
Comments
comments powered by Disqus