Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Drupal 7 Multi Sites Configuration
  • Table Of Contents Toc
Drupal 7 Multi Sites Configuration

Drupal 7 Multi Sites Configuration

By : Matt Butcher
4.2 (9)
close
close
Drupal 7 Multi Sites Configuration

Drupal 7 Multi Sites Configuration

4.2 (9)
By: Matt Butcher

Overview of this book

Drupal is one of the most powerful PHP Content Management Systems there is. However, why would you install a CMS for every site you build? With just one copy of Drupal you can host several sites. Drupal has long had multi-site support, and Drupal 7's support is even better than previous versions. Drupal 7 Multi-Sites Configuration will teach you how to host several websites on a single copy of Drupal. You will learn how to create different sites, each with its own domain, content, and theme. This valuable information will help you to save time by managing modules and sharing them across several sites as well as administering your sites all in one place.This book will show you how to configure a system for multi-site, and then install several sites on one copy of Drupal, all with their own domain name and database. Learn how to install and share modules and themes, configure Apache, PHP, and MySQL for multi-site, and then manage the site. Once your site system is successfully set up, discover some of the advanced configurations possible with Drupal multi-site, as well as how to upgrade and maintain your sites.
Table of Contents (11 chapters)
close
close

Configuring MySQL

In the previous section we configured Apache. Now we will set up MySQL with three databases—one for each of our sites. Again, if you are using the Vagrant-based virtual host, you will not need to do this part. It has been done already.

Again, we will assume that MySQL is already set up and running, and we will also assume that you can access the MySQL database as a privileged user and create user accounts and databases.

The first thing to do is create three new databases, one for each site. We will call these databases books_local, cooks_local, and looks_local to correspond to our three hostnames.

From a MySQL monitor (such as mysql on the command line), issue the following command:

CREATE DATABASE books_local;
CREATE DATABASE cooks_local;
CREATE DATABASE looks_local;

That is all that is required to create our databases. But we need to explicitly grant permissions for another MySQL user to access these databases. We will configure our Drupal sites to use this account to authenticate to the database. You can create a separate account for each site if you'd like, but we will just create one.

GRANT ALL
ON books_local.*
TO 'drupal'@'localhost'
IDENTIFIED BY 'secret';
GRANT ALL
ON looks_local.*
TO 'drupal'@'localhost'
IDENTIFIED BY 'secret';
GRANT ALL
ON cooks_local.*
TO 'drupal'@'localhost'
IDENTIFIED BY 'secret';

This will give the user drupal, whose password is secret, sufficient privileges to access all three of our databases. Notice that the Drupal account has been restricted to connections from the localhost. This is designed to prevent a remote user from connecting as our Drupal user.

It is a good idea to test these credentials using another MySQL client. This will help us preemptively troubleshoot. Here is an example from a UNIX shell using the mysql client.

$ mysql -u drupal -p secret books_local
mysql> SHOW TABLES;
Empty set (0.00 sec)

The snippet above shows that we connected to the database with our credentials, then successfully executed the SHOW TABLES SQL statement.

At this point, MySQL should be ready for Drupal, and we are done preparing the environment.

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Drupal 7 Multi Sites Configuration
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon