2

I setup Drupal 8 in my localhost, i want to run multisite using one database and one instance (under one drupal installation) How do i achieve this?

Also, i want the url will work like this : site1 : http://localhost/site1 site2 : http://localhost/site2

Thank you.

1
  • What you are talking about is 2 different pages within the same site. When you say site it refers to different domain name or host name + port number combination
    – Bhuvana
    Mar 16, 2016 at 10:19

2 Answers 2

5

First, read this page on Drupal 8 multisite, https://www.drupal.org/node/2297419.

It should give you a good idea of what you have to do in order to get multisite working and also explain some of the things you should consider. Following are generic steps, there are many things you can customize using settings.php.

The documentation inside the settings.php file is also very helpful, read that too by viewing the source of the file here https://api.drupal.org/api/drupal/sites!default!default.settings.php/8.

Briefly, the steps are,

  1. Multi-site requires the existence of the sites.php file in the sites directory. This file does not exist by default.
  2. Add your sites to a $sites array in this file, instructions are mentioned here https://www.drupal.org/node/2297419
  3. Create a site directory inside sites/, the path should be sites/site1.
  4. Each new site directory must have a settings.php file in order for Drupal to recognize it.
  5. Visit the URL of site1, site1.yourdomain.com to install it.
2
  • Thanks for pointing out the requirement clearly, now i achieve multi-site installation with different database. Can there be a way to have multi-site using 1 database and share the same tables but site1 and site2 will have different themes and web contents? or what will be the closest i can achieve?
    – Gabriel
    Mar 21, 2016 at 11:30
  • Check about sharing tables via table prefix.
    – Kimi
    Apr 11, 2016 at 10:41
3

In your settings.php there is the database connection setting. In there, you just need to provide table prefix that will distinguish tables for different sites.

Have a look at the settings.php file, it is well documented in there.

1
  • I do not want to separate site1 and site2 database. i want both the site should share the same database and contents. So, site1 contents can be seen from site2, the only difference will be themes. The main idea is - The main site will take care of all the other sites contents. Hope this make sense.
    – Gabriel
    Mar 18, 2016 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.