Created on 03 Jan 2013 ; Modified on 29 Sep 2013 ; Translation: italian
Drupal allows to install multiple web sites using a single instance of the code. This capability was introduced in the core of the system since version 6 (at the time of writing this note, the stable version of Drupal is 7).
This article summarizes the steps necessary to install an additional web site on a server already running Drupal multisite. And is derived from the procedure showed in Drupal documentation.
I would assume that:
cd
commands to the file system of your distribution;httpd
service ;The examples are based on the following parameters:
xx.yy.zz.ttt
;80
;/webroot/drupal
;/webroot/drupal/sites/
;/webroot/drupal/sites/esempio.com
;/etc/httpd/conf/httpd.conf
;/etc/httpd/conf/httpd-hosts.conf
;root
;esempio_db
;esempio_usr
;esempio_pwd
.As you can see, I prefer to have two files in the Apache configuration directory /etc/httpd/conf/
. The httpd.conf
file contains base parameters configuring Apache. While the httpd-hosts.conf
contains virtual hosts sites configurations. The httpd-hosts.conf
is included in the file httpd.conf
using an include directive, such as the following line:
Include "/etc/httpd/conf/httpd-vhosts.conf"
Again, if you want to use some of the following examples to your Drupal installation, be careful to use consistently the directories names of your your installation directories.
We are going to do the following steps:
settings.php
http://sito/install.php
, this will change the settings.php
entering the values necessary for the operation of the new site.Login as administrator on the server, and create the directory in which to host the site contents. For example:
[root@host ~] # cd /webroot/drupal/sites/
[root@host sites] # mkdir esempio.com
[root@host sites] # cp default/settings.php esempio.com/settings.php
[root@host sites] # chown-R apache:apache esempio.com/
Make a backup copy of the file /etc/httpd/conf/httpd-hosts.conf
1, for example:
[root@host sites] # cd /etc/httpd/conf
[root@host conf] # cp httpd-vhosts.conf httpd-vhosts-121228.conf
After that, you edit httpd-hosts.conf
using a text editor to add the following section:
<VirtualHost Xx.yy.zz.ttt:80>
DocumentRoot "/webroot/drupal"
ServerName www.esempio.com
CustomLog "logs/www.esempio.com.access.log" combined
ErrorLog "logs/www.esempio.com.error.log"
<Directory "/webroot/drupal">
Options Indexes FollowSymLinks
AllowOverride All
Order allow, deny
Allow from all
</ Directory>
</ VirtualHost>
Then restart the service:
[root@host sites] # service httpd restart
Stopping httpd: [OK]
Starting httpd: [OK]
hosts
fileThis task is required if the new site isn't added yet to a public DNS, but you should use it (see the next step: run http://www.esempio.com/install.php
).
If you are using a Windows PC with the operating system installed in c:\windows\
, you will need to edit the c:\windows\system32\drivers\etc\hosts
file by adding the line:
xx.yy.zz.ttt www.esempio.com
Now we need to create a database used by the new site, and the user needed by Drupal to use it. We use the mysqladmin
program to create the database, presenting us as MySQL administrators:
[root@host sites] # mysqladmin -u root -p create esempio_db
Enter password:
After that we create the user using the mysql
program. Again, presenting us as MySQL administrators:
[root@host sites] # mysql -u root -p
Enter password:
Welcome to ...
mysql> create user 'esempio_usr' @ '%' IDENTIFIED BY 'esempio_pwd';
mysql> grant select, insert, update, delete, create, drop, index, alter, create temporary tables, lock tables on esempio_db. * to 'esempio_usr' @ '%' IDENTIFIED BY 'esempio_pwd';
mysql> create user 'esempio_usr' @ 'localhost' IDENTIFIED BY 'esempio_pwd';
mysql> grant select, insert, update, delete, create, drop, index, alter, create temporary tables, lock tables on esempio_db. * to 'esempio_usr' @ 'localhost' IDENTIFIED BY 'esempio_pwd';
mysql> exit
As you can see we have configured the user esempio_usr
to work both in connection remotely from every IP address (@'%'
), either locally to the server (@'localhost'
).
http://www.esempio.com/install.php
Using a web browser we go to http://www.esempio.com/install.php
and answer to the program questions. The program install.php
should be used only once, and, based on your answers, it adjusts appropiatly the configuration file of the new Drupal site.
Among other things, this program creates an account for the administration of the site, asking us for name, email and password we want to use. Keep in touch these credentials. If we lost them, will be hart to administer the the site ...
Remember: this file is included in /etc/httpd/conf/httpd.conf
using the directive:
Include "/etc/httpd/conf/httpd-vhosts.conf" ↩