Hi all,
In this post , we are going to create a multisite on drupal 8 ,
Two sites namely dogs and cats can share the same codebase and different database
Here am using Ubuntu 16.04 , So that some server configurations may vary depend on your server...
So please follow the below steps to create a multi site on drupal 8
Step1: Download the latest drupal 8 project using the link www.drupal.org.
Note: You can use any other method you follow to download drupal Project ..For Example : Console , Composer
Step 2: Extract the downloaded package inside your Html folder
For Example: var/www/html/drupal-8.4.3(Your downloaded folder here)
Step3: In your Drupal Root Folder (drupal-8.4.3)
In the sites folder create the required sites as shown in the screenshot
Here i create two sites namely cats and dogs sharing the same codebase and different database
Step4: Inside the cats and dog folders copy the default.settings file from the the default folder and rename to settings.php and place the file inside each created sites and create the files folder on each sites like below screenshot
(Cats Site Folder Structure)
(Dogs Site Folder Structure)
Step5: Copy the example.sites.php and rename ito sites.php inside the sites folder
Step6:Inside the sites.php file add the below to lines
Server Side Configuration (Apache)
For Multi site set up you need to set up virtual host
Configurations for Virtual Host Set up:
Step1: In the Terminal edit the hosts file and add the below lines
Your ip address Name of the site
Site 1: xx.xxx.xxx dogs
Site 2: xx.xxx.xxx cats
and save the hosts file .
Step2: In the terminal goto sites-available the directory by etc/apache2/sites-available
create conf files as you needed (Number of conf files and number of sites are equal)
Here i created file by
sudo touch domain1.com.conf and inside the created conf file Paste the Below Code
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName dogs
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/drupal-8.4.3/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Paste the above code and changed the bolded text as your configuration and save the file
Step3: Enable the site using the below command
sudo a2ensite domain2.com.conf
Step4: After enabling the site restart your server
sudo servive apache2 restart
Database Configuaration
Step1: Create the database as you need .Here am using phpmyadmin to create a database
Finally if you enter the url in the browser like this cats/core/install.php , you may end up drupal installation process sucessfully
In this post , we are going to create a multisite on drupal 8 ,
Two sites namely dogs and cats can share the same codebase and different database
Here am using Ubuntu 16.04 , So that some server configurations may vary depend on your server...
So please follow the below steps to create a multi site on drupal 8
Step1: Download the latest drupal 8 project using the link www.drupal.org.
Note: You can use any other method you follow to download drupal Project ..For Example : Console , Composer
Step 2: Extract the downloaded package inside your Html folder
For Example: var/www/html/drupal-8.4.3(Your downloaded folder here)
Step3: In your Drupal Root Folder (drupal-8.4.3)
In the sites folder create the required sites as shown in the screenshot
Here i create two sites namely cats and dogs sharing the same codebase and different database
Step4: Inside the cats and dog folders copy the default.settings file from the the default folder and rename to settings.php and place the file inside each created sites and create the files folder on each sites like below screenshot
(Cats Site Folder Structure)
(Dogs Site Folder Structure)
Step5: Copy the example.sites.php and rename ito sites.php inside the sites folder
Step6:Inside the sites.php file add the below to lines
completing the above steps , the drupal configurations for multisite setup is completed$sites = array('dogs' => 'dogs','cats' => 'cats',);
Server Side Configuration (Apache)
For Multi site set up you need to set up virtual host
Configurations for Virtual Host Set up:
Step1: In the Terminal edit the hosts file and add the below lines
Your ip address Name of the site
Site 1: xx.xxx.xxx dogs
Site 2: xx.xxx.xxx cats
and save the hosts file .
Step2: In the terminal goto sites-available the directory by etc/apache2/sites-available
create conf files as you needed (Number of conf files and number of sites are equal)
Here i created file by
sudo touch domain1.com.conf and inside the created conf file Paste the Below Code
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName dogs
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/drupal-8.4.3/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Paste the above code and changed the bolded text as your configuration and save the file
Step3: Enable the site using the below command
sudo a2ensite domain2.com.conf
Step4: After enabling the site restart your server
sudo servive apache2 restart
Database Configuaration
Step1: Create the database as you need .Here am using phpmyadmin to create a database
Finally if you enter the url in the browser like this cats/core/install.php , you may end up drupal installation process sucessfully
Comments