Monday, September 30, 2013

Drupal 7 multi-site install on CentOS6

Tricks to getting a multi-site Drupal7 installed on CentOS w/ Apache2, mySQL.

Follow these two posts, more or less. The biggest point of advice is that for each url that isn't a subdomain should point to the same url (i.e. [] v. [] v. [])

These are suggested reading sites, but none of them are exact, always referencing ubuntu or other linux distros...mine was a little different.

The most important thing is to have drush installed (mentioned in my other post). That makes installing everything else move quite quickly.

This doesn't have to be the same for everyone, but here are my steps:
1) cd /var/www/vhosts/drupal7 (if vhosts or drupal7 doesn't exist, create them)
2) drush dl drupal
before step 3, make sure to create the databases you need
pre-3a) mysql -u userName -p (this user is your sql admin user name, same or different from drupal db's)
pre-3b) create database YourMySQLDbName;
pre-3c) grant all on YourMySQLDbName.* to YourMySQLUserName@localhost identified by 'PasswordYouSet';
3) drush site-install standard --account-name=admin --account-pass=admin --db-url=mysql://YourMySQLUserName:PasswordYouSet@localhost/YourMySQLDbName
4) vi /etc/http/conf.d/drupal7.conf (make this if it doesn't exist yet)
5) paste the following in, save, then quit:

Alias drupal7

<Directory /var/www/vhosts/drupal7>
Options +FollowSymLinks
AllowOverride All
order allow,deny
allow from all

6) vi /etc/http/conf.d/00_drupal.conf (make this if it doesn't exist yet)
one thing I've learned about apache is that the apache configuration file works alphabetically, and this file is the configuration for all virtualhosts (which allows us to have the multi-sites installed correctly)
7) paste the following in, save, then quit:
NameVirtualHost *:80

<Directory /var/www/vhosts>
  AllowOverride All

<VirtualHost *:80>
   ServerPath /drupal7
   DocumentRoot /var/www/vhosts/drupal7
   ServerName drupal7

8) apachectl restart

you should still be in the /var/www/vhosts/drupal7 directory
9) cp -a default/ sites/ (create it if it doesn't exist)
this should move over the files/ folder, settings.php and default.settings.php

10) chmod a+w sites/
chmod a+w sites/

11) vi sites/sites.php
at the bottom of the file, you should add a line for each site you're installing. This hash is useful for finding the website and folders based on the apache setup (we'll get to that shortly).  Add the following:

$sites['nickname'] = '' (this is the folder path in drupal7/sites/

save and exit

12) now for your newly added site, we need to append info to the conf file so apache knows to redirect correctly to the sites.php file which will redirect to the correct folder which will show the correct site
vi /etc/http/conf.d/00_drupal.conf

at the bottom, add:

<VirtualHost *:80>
   DocumentRoot /var/www/vhosts/drupal7/sites/
   ServerName nickname

repeat for each new site

13) Finally change the settings for the newest site added:
vi sites/

change the database information for your new site

14) now setup your site:

15) after setup, change the folder and file permissions back

16) pat yourself on the back, it's all done :) - maybe a drush script for multi-site would be useful?

1 comment: