In order to test out the new Red Hat Software Collections (RHSCL, announcement) version of PHP 5.4, I decided to build out a Drupal 7 install using the php54 collection and the mysql55 collection.

Overall, the activity was pretty much like a normal Drupal install. However, to use software collections you have to do a few things differently. Also, if you haven't used a software collection for a "service" (e.g. MySQL) before, the service setup is also a little different than the native versions.

First and foremost, add the channels for RHSCL either via subscription manager or rhn. The name of the channel (for the beta) is rhel-server-rhscl-6-beta-rpms. After that, you need to install the software collections. So, something like:

#yum install php54 mysql55

You could also just install all the dependencies in the same line, but I wanted to pull them out to be able to comment on them a little bit more. I also tend to install some of the semi-optional components because I think Drupal works better that way.

First off, the easiest thing to install, which is also not really related to software collections, is gd (not called "GIF Draw" :) ). Very simple, just install gd from the normal RHEL repositories.

#yum install gd

Next, we need the "driver" libraries for php to various other things. All the ones we need are included in the "php54 Software Collection" but are not installed by the simple install of the php54 package as they are not required for basic php. php54-php-gd is the connection from php to the gd library. php54-php-mbstring is a library for unicode, technically not a "driver" but an optional library. Finally, we need to connect to mysql so we install php54-php-mysqlnd.

#yum install php54-php-gd php54-php-mbstring php54-php-mysqlnd

Last but not least, we need to install the php "driver" for httpd. Now, I call this one out

because I always hear this referred to as mod_php. Well, the interesting thing is, in RHEL mod_php is just a shorthand for the name of the real library (in the software collection, libphp54-php5.so). As a result, you need to install php54-php (which you can also install by using the name php_mod) which includes the correct httpd module to support php.

#yum install php54-php

Now for all of you that want to just have one line to install:

#yum install httpd php54 mysql55 gd php54-php-gd php54-php-mbstring php54-php-mysqlnd php54-php

OK, moving on to making things run. First, you need to make mysql55 start. Pretty straightforward, you just do it normally but put in the "correct" name for MySQL.

#chkconfig mysql55 on
#service mysql55 start

You also need to make sure that the apache webserver is running but this is no different than you would without software collections.

#chkconfig httpd on
#service httpd start

Now, let's create the database. Mind you, I am really trying to show how to set this up for development with these new software collections, not a proper, hardened production box. You can follow similar steps for production, but you should be doing things like locking down access to the database in MySQL, potentially splitting the web server from the database server, etc.

#scl enable mysql55 mysql
(do the above as root for autologin)

Then:

mysql>CREATE DATABASE drupalDev;
mysql>CREATE USER 'drupal'@'localhost' IDENTIFIED BY 'drupal';
mysql>GRANT USAGE ON *.* TO 'drupal'@'localhost';
mysql>GRANT ALL ON drupalDev.* TO 'drupal'@'localhost;

OK, now we can begin the Drupal install. Download the latest tarball of Drupal from drupal.org. Extract it, and put it where you prefer. During development, I usually install it under a "projects" directory under my user account. I also, usually, add the apache group to my user, then give the appropriate permissions to the group on my directories to allow the webserver to access the files.

$ mkdir -p /home/my-user/projects/my-drupal-proj/
$ cd /home/my-user/projects/my-drupal-proj/
$ mv ~/Downloads/drupal-7.22.tar.gz /home/my-user/projects/my-drupal-proj/
$ tar -xf drupal-7.22.tar.gz
# usermod -a -G apache my-user (note: root perms)
$ chown -R my-user:apache /home/my-user/projects/my-drupal-proj/
$ chmod -R g+w /home/my-user/projects/my-drupal-proj/drupal-7.22/

I also usually set up a VirtualHost so that I can easily get to the site and not introduce potential issues because of a difference in subdirectories between dev and prod. Given the above setup, I would use the following VirtualHost conf file. Don't forget to add my-drupal-proj as a host in /etc/hosts (e.g. 127.0.0.1 my-drupal-proj).

<VirtualHost *:80>
        ServerName my-drupal-proj
        ServerAdmin me-user@myemail.com
        DocumentRoot /home/my-user/projects/my-drupal-proj/drupal-7.22
        <Directory /home/my-user/projects/my-drupal-proj/drupal-7.22>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
        ErrorLog /home/my-user/projects/my-drupal-proj/logs/error.log
        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel info
        CustomLog /home/my-user/projects/my-drupal-proj/logs/access.log combined
</VirtualHost>

Finally, we can just follow the normal, web-based, install process by starting approximately here in the Drupal Installation Guide by going to http://my-drupal-proj/

Last updated: November 2, 2023