I needed to set up Drupal on a CentOS
Linux system.
For the system requirements
for Drupal 6, I saw that PHP 5.2 or later was recommended with
PHP version 4.3.5 or higher required. I checked the version of PHP
on the system with php --version
and found it was adequate.
Since a PHP memory limit of 16MB is required for Drupal 6, I verified
that the memory limit was already at 16MB.
# grep memory_limit /etc/php.ini memory_limit = 16M ; Maximum amount of memory a script may consume
I verified MySQL was installed with
and functioning with mysql --version
and that
PHP XML extension (for blogapi, drupal, and ping modules) support was present
with php --info | grep -i xml
. This extension is enabled by
default in a standard PHP installation; the Windows version of PHP has built-in
support for this extension.
An image library for PHP such as the GD
library is needed for image manipulation (resizing user pictures, image and
imagecache modules). GD is included with PHP 4.3 and higher and enabled by
default. ImageMagick
is also supported for basic image manipulations in Drupal core but there is
much less support from contribute modules. I verifed the GD library was
installed with rpm -qi gd
and checked on whether ImageMagick
was present with rpm -qi ImageMagick
; it was installed.
For the PHP required PHP configuration settings, I verified that
register_globals
was set to off in /etc/php.ini
with
grep register_globals /etc/php.ini
. I verifed that
error_reporting
was set to E_ALL
, safe_mode
was set to Off
, and that session.cache_limiter
was set to nocache
. The only value that differed from the
recommended one was the value of
session.save_handler, which was set to files
rather than the
recommended value of user
.
# grep session.save_handler /etc/php.ini session.save_handler = files
This "sets the user-level session storage functions which are used for storing and retrieving data associated with a session. This is most useful when a storage method other than those supplied by PHP sessions is preferred. i.e. Storing the session data in a local database."
The following comment was posted on the system requirements page by ozcan:
Correct me if I am wrong, but "session.save_handler: user" seems not a crucial requirement to be configured in the php.ini file.
Since this directive can be changed from anywhere (PHP_INI_ALL) as is listed here: http://www.php.net/manual/en/ini.list.php and since this is set to "user" in the PHP Settings section of the "settings.php" file in the default directory, nobody needs to set it in the php.ini file.
This info should especially be valuable for those who do not have access to the php.ini file, i.e. for those who will run Drupal on a shared server.
So I decided to just leave that setting as it was in the php.ini
file.
I then decided to check if a Drupal package was available for CentOS. One was available, but it was an old version.
]# yum install drupal Loading "priorities" plugin Loading "fastestmirror" plugin Loading mirror speeds from cached hostfile * rpmforge: fr2.rpmfind.net * base: mirror.nyi.net * updates: mirror.trouble-free.net * addons: centos.aol.com * extras: mirror.anl.gov 324 packages excluded due to repository priority protections Setting up Install Process Parsing package install arguments Resolving Dependencies --> Running transaction check ---> Package drupal4.noarch 0:4.7.11-1.el5.rf set to be updated --> Processing Dependency: php-gd for package: drupal4 --> Running transaction check ---> Package php-gd.x86_64 0:5.1.6-20.el5_2.1 set to be updated --> Finished Dependency Resolution Dependencies Resolved ============================================================================= Package Arch Version Repository Size ============================================================================= Installing: drupal4 noarch 4.7.11-1.el5.rf rpmforge 498 k Installing for dependencies: php-gd x86_64 5.1.6-20.el5_2.1 updates 112 k Transaction Summary ============================================================================= Install 2 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 610 k Is this ok [y/N]: N Exiting on user Command Complete!
The current version of Drupal is version 6, but the version listed as being
available from the RPMForge repository
(see Alpine on CentOS for how to configure yum to use the RPMForge
repository) was 4.7.11-1. I decided I didn't want to install a version that
out-of-date. I did install the package that was listed as a dependency for
it, though, php-gd
with yum install php-gd
.
I found version 6-6.9-1 was available from RPM PBone Search. I downloaded drupal6 rpm build for : RedHat EL 5. The requirements listed for it included the following:
I verified that was already installed with rpm -qi php-mbstring
.
I then installed the rpm file I had downloaded with
rpm --install drupal6-6.9-1.el5.rf.noarch.rpm
Using the RPM file to install drupal results in the software being
placed in /var/www/drupal-6.9
. Documentation is placed in
/usr/share/doc/drupal6-6.9/
, where you will find the
following files.
CHANGELOG.txt INSTALL.pgsql.txt LICENSE.txt UPGRADE.txt
INSTALL.mysql.txt INSTALL.txt MAINTAINERS.txt
Rather than deal with any complexities related to multi-site support
initially, I then logged into an account for one of the domains that will
use drupal and copied the directory tree from where drupal was installed
to the document root directory for the site with
cp --recursive /var/www/drupal-6.9/ .
. I then changed the
directory name from drupal-6.9
to just drupal
with mv drupal-6.9 drupal
. I then changed the working
directory to the default sites directory with cd drupal/sites/default
.
Drupal uses a configuration file for database information and other special configurations. That file needs to be set up properly as explained at Grant write permissions on the configuration file.
You first need to copy default.settings.php
to
settings.php
. You can't simply rename the file, since the setup
process requires both files. You then need to make the settings.php
file writable.
$ cp default.settings.php settings.php
$ chmod 666 settings.php
Drupal should set the file permissions back to read-only once the installation
is done. You should make sure this is the case and manually change it yourself
if it didn't happen. You can use the command chmod a-w settings.php
if the permissions weren't changed.
Since I didn't have a MySQL account set up
for drupal for the site, I created one. The example below uses
drupalacct
for the account name and SomeGoodPassword
for the password. Use whatever values you deem appropriate for those fields.
# mysql -p --user=root Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 5.0.45 Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql& use mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> INSERT INTO user (Host,User,Password) VALUES ('localhost','drupalacct',PASSWORD('SomeGoodPassword')); Query OK, 1 row affected, 3 warnings (0.06 sec) mysql& exit Bye
I then thought I could create the needed drupal database from the account I created, but whenever I tried any operation from that account, I received an "access denied for user" message.
# mysql --user=drupalacct -p Enter password: ERROR 1045 (28000): Access denied for user 'drupalacct'@'localhost' (using password: YES) # mysqladmin -u drupalacct -p ver Enter password: mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'drupalacct'@'localhost' (using password: YES)'
It took me awhile to understand why no operation I tried for the account I
created would work, even though I knew I was using the right password for
that userid, since I even double-checked it in the .mysql_history
in the login directory for the root account. Finally, I realized that I forgot
to issue the "flush privileges" command after I created the account. After
I issued that command, I was able to use the drupalacct
account I
had created.
# mysql --user=root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 24 Server version: 5.0.45 Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> use mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.01 sec) mysql> exit Bye # mysqladmin -u drupalacct -p ver Enter password: mysqladmin Ver 8.41 Distrib 5.0.45, for redhat-linux-gnu on x86_64 Copyright (C) 2000-2006 MySQL AB This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL license Server version 5.0.45 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/lib/mysql/mysql.sock Uptime: 6 days 10 hours 42 min 56 sec Threads: 1 Questions: 146 Slow queries: 0 Opens: 23 Flush tables: 1 Open tables: 17 Queries per second avg: 0.000
I then created the database from the root account and granted access to the database to the drupalacct userid.
# mysql --user=root -p # mysqladmin -u root -p create mysite_drupal Enter password: # mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 29 Server version: 5.0.45 Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON -> mysite_drupal.* TO 'drupalacct'@'localhost' -> IDENTIFIED BY 'SomeGoodPassword'; Query OK, 0 rows affected (0.04 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) mysql> exit Bye
In the example above, you would substitute whatever name you wanted for the
database in place of mysite_drupal
, whatever username you
created for drupalacct
and the password for that username for
SomeGoodPassword
. If you hit Enter at the end of a line,
but you haven't yet completed a command, you will get the ->
prompt on the next line.
When I tried accessing drupal on the site, I received an "Internal Server Error" message.
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
When I checked the error log file for the site, I saw the following:
[Sun Mar 15 10:14:48 2009] [error] [client 192.168.0.44] File does not exist: /home/jdoe/web/example/favicon.ico, referer: http://example.com/
[Sun Mar 15 10:14:49 2009] [alert] [client 192.168.0.44] /home/jdoe/web/example/.htaccess: order not allowed here, referer: http://example.com/
When I checked the .htaccess
file, it appeared there was a
missing double-quote at the end of the "ErrorDocument 404" line.
# Force simple error message for requests for non-existent favicon.ico.
<Files favicon.ico>
# There is no end quote below, for compatibility with Apache 1.3.
ErrorDocument 404 "The requested file favicon.ico was not found.
</Files>
I added the missing double-quote.
ErrorDocument 404 "The requested file favicon.ico was not found."
I tried accessing the site again and received the same "Internal Server Error" message. When I checked the error log file for the site, I saw the two messages listed above repeated again.
Following tips I found in
.htaccess: order not allowed here, I edited the
/etc/httpd/conf/httpd.conf
file and added the following lines
to the virtualhost section of the file for this particular site:
<directory /home/jdoe/web/example>
AllowOverride FileInfo Limit Options Indexes
</directory>
I then restarted the Apache webserver software with apachectl
restart
.
I still got the "Internal Server Error" message, though. When I checked the error log file for the site, I found the following entry:
[Sun Mar 15 10:39:58 2009] [alert] [client 192.168.0.44] /home/jdoe/web/example/.htaccess: AuthUserFile not allowed here, referer: http://example.com/
So I added AuthConfig
to the directory
block
within the virutal host section for that site, which I had placed in
httpd.conf
. I then restarted the Apache webserver again with
apachectl restart
. I then saw the Drupal setup page when
I tried accessing the site.
I wouldn't have received the "AuthUserFile not allowed here" message if
I had stuck to the default .htaccess
file that came with the
Drupal software. I had added an AuthUserFile
line to the
beginning of the file to block all access to the site with a
.htpasswd
file, though.
I clicked on Install Drupal in English. I then saw a "requirements problem" message.
The INSTALL.txt
file had the following information it it:
The install script will attempt to create a files storage directory in the default location at sites/default/files (the location of the files directory may be changed after Drupal is installed). In some cases, you may need to create the directory and modify its permissions manually. Use the following commands (from the installation directory) to create the files directory and grant the web server write privileges to it: mkdir sites/default/files chmod o+w sites/default/files The install script will attempt to write-protect the settings.php file and the sites/default directory after saving your configuration. However, you may need to manually write-protect them using the commands (from the installation directory):
I made the working directory the sites/default
directory and
entered the required commands.
$ cd sites/default $ mkdir files $ chmod o+w files
I then clicked on the Try again link to proceed, which took me to the database configuration step. I put in the name of the database I had created earlier, the username for the account I created to use the database, and the password associated with that userid. I then clicked on Save and Continue.
At the Configure site webpage, which was then displayed, I saw the following message:
I checked the permissions on the sites/default/settings.php
file and saw it still had write permission set, so I changed the permissions
to read-only on the settings.php
file. The files
directory should remain writable.
$ ls -l total 28 -rw-r--r-- 1 jdoe jdoe 8917 Mar 14 20:52 default.settings.php drwxrwxrwx 2 jdoe jdoe 4096 Mar 15 12:28 files -rw-rw-rw- 1 jdoe jdoe 8934 Mar 15 13:01 settings.php $ chmod a-w settings.php $ ls -l total 28 -rw-r--r-- 1 jdoe jdoe 8917 Mar 14 20:52 default.settings.php drwxrwxrwx 2 jdoe jdoe 4096 Mar 15 12:28 files -r--r--r-- 1 jdoe jdoe 8934 Mar 15 13:01 settings.php
Then, on the Configure site page, I entered the email address to be used for the site, a username for the administrator account and an email address and password for that account. The default time zone was correctly set and I left "Clean URLs" and "Check for updates automatically" checked. When I clicked on Save and continue, I saw the message "Congratulations, Drupal has been successfully installed." I was then able to successfully access the website.
Cron maintenance tasks should be run periodically for Drupal. Instructions
for setting up a cron job for Drupal can be found at
Configuring cron jobs. Since
wget
is present on the system, I used the
0 * * * * wget -O - -q -t 1 http://www.example.com/cron.php
format for the crontab entry. You can determine if wget is present by using
the command which wget
.
References:
Created: Tuesday March 17, 2009 1:30 PM