jason
jason

Reputation: 3615

Create Drupal 8 Multisite on localhost

I want to create a multisite Drupal 8 site. I would like to keep the default site, and then add another site. This is all being done on a WAMP stack and is on a locahost. These are the steps I have taken, but have not worked:

  1. Downloaded most recent Drupal 8 and unzipped (and moved files) to www/my_primary_site

  2. I created two databases in MySQL: site1, site2

  3. in the www/my_primary_site/sites folder, I did the following:

    a. Created a folder called "my_second_site"

    b. Created a file called sites.php.

    c. In sites.php, I have this code:

      $sites = array(
        '8080.localhost.my_primary_site' => 'default',
        '8080.localhost.my_primary_site/my_second_site' => 'my_second_site',
      );
    

I then go to localhost/my_primary_site. This brings me to the Drupal install (localhost/my_primary_site/core/install.php). But, if I go to localhost/my_primary_site/my_second_site, it just redirects me back to localhost/my_primary_site/core/install.php.

I would expect that the second link would take me to a different install path. Is this correct? If not, how would I fix this?

thanks jason

Upvotes: 0

Views: 1276

Answers (3)

Varun Singh
Varun Singh

Reputation: 49

There are two approaches :

  1. Try using sysmlinks functions in file myfile.php

2.Using sites.php in /drupal/sites folder

$sites['site1'] = 'site1';
$sites['site2'] = 'site2';

Upvotes: 0

SeshGeek
SeshGeek

Reputation: 1

Try using this:

$sites['site1.localhost'] = 'site1';
$sites['site2.localhost'] = 'site2';

Also, make sure you add this domain to your etc/hosts file:

127.0.0.1 site1.localhost

127.0.0.1 site2.localhost

Upvotes: 0

Bobbysaul
Bobbysaul

Reputation: 1

Make sure to copy the default settings.php and services.yml to the new folder.

Try using the format of using . instead of /' like this:

 $sites = array(
    '8080.localhost.my_primary_site' => 'default',
    '8080.localhost.my_primary_site.my_second_site' => 'my_second_site',
  );

Make a symbolic link in your root directory that points to the main Drupal folder.

ln -s /drupal /my_primary_site/my_second_site

Upvotes: 0

Related Questions