Skip to main content

Multi site Set up on drupal on Lamp(Linux ,Apache , Mysql, Php )

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

$sites = array(
      'dogs' => 'dogs',
      'cats' => 'cats',
    );
completing the above steps , the drupal configurations for multisite setup is completed


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

Popular posts from this blog

Twig in Drupal 8

                                             Twig in Drupal 8 Introduction   In web development , every developer knows  presenting  a content in a  webpage is more important than any  functional logic inside the website whether the site is for tutoring , just a blog or its site for ecommerce products , how your site going to interact with the user plays major role for your business profit . Its a matter of minute to hold your customer/user in online to make a profit. you may thought , it is inappropriate to discuss those  with the title of this post  twig in drupal 8.   twig is used as presenter of your content in an easy way. Templating Engine in drupal 7     For those who are familiar with drupal 7 already know that php is used as templating engine . So its with an advantage of adding much more logic while creating an template for any page in drupal 7. So it is an necessity for front end developer to know about basic level of php to work with drupal 7.

Redirection In Drupal 8 Programatcially

Redirection In Drupal 8  In this post we can learn about the ways we can make redirect in Drupal 8. You can make a custom redirect according to the context in many ways. Form Redirect      We can use the formstate object to redirect from form.     Currently below two methods are available from Drupal\Core\Form  formstate to build  a    \Symfony\Component\HttpFoundation\RedirectResponse  for redirection. 1) setRedirect  function setRedirect($route_name, array $route_parameters = [], array $options = []) This method will call the setRedirectUrl function inside it. 1) route_parameters - optional argument 2) route_name -  The name of the route name. 3) options -    (optional) An associative array of additional URL options, with the    *   following elements:    *   - 'query': An array of query key/value-pairs (without any URL-encoding)    *     to append to the URL .    *   - 'fragment': A fragment identifier (named anchor) to append to the URL.    *     Do not incl

Things You Must Know Before Trying Forms In Drupal 8.

 You Should Invest In Forms                      What does your customer think?  What do they looking for? will decide the success of any business.    In a digital marketing, Most of the customer requirement is gathered through forms. So its   essential  to spend some  time with forms Example : a user can search a particular product using the search form on an e-commerce website. Form API in Drupal 8          As we know already Drupal use forms for most of the administrative site building. Drupal 8 follows object-oriented style of programming with the integration of symfony . Based on the purpose of the form, it can inherit the basic properties and methods of the below classes. 1.Config Base 2.FormBase 3.ConfirmBase   Note : Routing configuration is done through the yml files in drupal 8 When the user hits the valid url in the browser , Major Responses are 1.Page Content 2.Forms 3.Map..etc. Basic Routing Configuration for Form Internal path-machi