Saturday, September 26, 2015

5.8-C amd64 X200: Drupal 7 Multisite.

Hey,

Why multisite? I read quite a bit of discouragement about this topic. Well, this is a local installation and it is a development (or hope to be) machine so I will (or might) be doing multiple sites. Hence the need.

My reference will be this site:

https://www.drupal.org/documentation/install/multi-site

You might need to refer to my previous posts as I might not be duplicating what is unnecessary here.

1) Preparing the site.
My default drupal site is drupal.example.com. So, I think I want to create another site called drupal2.example.com. I create a folder inside Drupal's sites folder.

$ cd /var/www/htdocs/drupal7/sites/
$ sudo mkdir drupal2.example.com

Along with that, I need to create a files folder inside my new drupal2's folder.

$ sudo mkdir -pm 777 drupal2.example.com/files

The files will need to be fully writeable as installation will gave error or not able to write inside that folder.

Folder creation done, now to set up appropriate files. Inside sites folder, there a file named example.sites.php. For a single-site.. err.. site, no need to touch this file but as I'm trying to create a multisite.. err.. site now, I need to edit this file. First I need to copy this file as sites.php file.

$ sudo cp example.sites.php sites.php

Now to edit this, adding this text at the bottom (bolded):

----- sites.php starts -----
<?php
* text snipped *

$sites['drupal2.example.com'] = 'example.com';
?>
----- sites.php ends -----

Yeah you read it right, I also included the closing tag for php as there's none there. Then I need to copy default.settings.php and put it as settings.php inside drupal2.example.com folder.

$ sudo cp sites/default/default.settings.php sites/drupal2.example.com/settings.php

Now to edit this file. I need to find and edit the $databases = array () occurances and change it to this.

----- drupal2 settings.php starts -----
$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'drupal2',
      'username' => 'drupal',
      'password' => 'password',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'pgsql',
      'prefix' => '',
    ),
  ),
);
----- drupal2 settings.php ends -----

Remember this. I'm using PostgreSQL. This file is to set up my currently-non-existant new drupal2.example.com site's database. This part of the setup is complete.

2) Set up the database.
The command for PostgreSQL is:

$ createdb -U drupal -E UTF8 drupal2

For clarification, refer to my previous post about Drupal 7's installation. Basically I'm creating a black database using the "drupal" username with UTF8 encoding (needed!) and the name of that database is "drupal2". Make sure that the previous settings.php is configured according to this informations.

3) Set up the (local) domain.
I edited the /etc/hosts file.

----- /etc/hosts starts -----
127.0.0.1 drupal2.example.com
----- /etc/hosts ends -----

There's also other entries inside that file but I'm just showing the changes.

4) Configure HTTPd.
I edited the /etc/httpd.conf and inserted these text.

----- /etc/httpd.conf starts -----
server "juadah.example.com" {
        listen on $ext_addr port 80

        directory {
                index "index.php"
        }

        location "*.php*" {
                fastcgi socket "/run/php-fpm.sock"
        }

        root "/htdocs/drupal7"
}
----- /etc/https.conf ends -----

This is just a basic configuration. This should be it. Now to install the new site. I open up my browser, and type the new URL drupal2.example.com.

PDOException: SQLSTATE[42P01]:

Wha..?. I received errors instead talking about some PDO stuff. Ouch. After searching for a while, I found the answer. Wrong URL. The correct one for installation is:

drupal2.example.com/install.php

Then the installation went through. I got 2 warning when installing. 1 is for the files directory not writeable (hence the steps above) and the other one is about the unicode issue, refer my previous post as I need to patch the Drupal installation again because, hey, I'm following -CURRENT. Later.

No comments:

6.5 amd64: Modify existing certbot certificates.

Hi, It's been quite some time eh. As you can see, I still upgrade my OpenBSD system regularly but currently I do not have the time to ...