Image

- Code Reusability ( Modules/Libraries/Themes )
- Reduced server storage space as reusability of code comes into effect
- This naturally reduces the need to have separate hosting space.
- Better developing environment
- Sharing of SSL certificates for subsites hosted on the same domain.
Performing a multisite setup involves the following two steps:
- Configuring a virtual host
- Modifying “hosts” file
- Configuring httpd.conf
- Drupal Configurations
- Configuring Drupal Codebase
- Subsite Installation
Let’s assume that we are about to create “sub.example.com” as a subsite for a drupal website present at localhost/example
1. MODIFYING “HOSTS” FILE
- For a local setup, the first step is to configure our “hosts” file. This is present at “C:\Windows\System32\drivers\etc” on a Windows OS. If the folder appears blank, try opening it on an editor, this will show all files present in the folder. The “hosts” file will be available at “\etc\” on an Ubuntu machine.
- Add the line 127.0.0.1 sub.example.com at the bottom of the file and save it.
Image

- This should look something like the screenshot above. Adding the line tells the system to redirect to localhost and not search the internet for the website.
2. CONFIGURING HTTPD.CONF – APACHE’S CONFIGURATION FILE
The next step is to configure the apache configuration file “httpd.conf”. This will be present in “C:\xampp\apache\conf” in Windows and “\etc\apache2\” on Ubuntu unless apache is installed on a different location.
At the bottom of the file, add the following lines,
<>
DocumentRoot "C:/xampp/htdocs/example"
ServerName sub.example.com
ServerAlias sub.example.com
Now restart apache. On Ubuntu the command is “sudo /etc/init.d/apache2 restart”
3. CONFIGURING DRUPAL CODEBASE
Create a folder named “subsite” inside your main website’s sites folder( in this case, it should be inside “C:\xampp\htdocs\example\sites”. The structure should be as follows,
Image

- Make a copy of “examples.sites.php” present in the sites folder rename it to “sites.php” and open it.
- Append the following configuration to the end of the contents of the file and save it. $sites['sub.example.com'] = 'subsite';
- The key “sub.example.com” in the above line indicates the domain we provided in the host file and the value “subsite” denotes the subsite folder.
- Now make a copy of “examples.settings.php” found in “sites/default” folder of the main website and paste it inside “sites/subsite”. Rename the file to “settings.php”. This file holds the configuration settings for the subsite. Make sure that the file has “write” permissions enabled at first.
- Create the folders “modules”, “libraries”, “themes” inside the “subsite” folder.
- The folder structure looks as follows
Image

4.SUBSITE INSTALLATION
- The subsite is now ready to be installed as a normal drupal installation.
- Hit the url http://sub.example.com in your browser and Drupal installation screen will appear.
- Make sure to create a blank database first before starting on the installation process. The database will be required in one of the Drupal Installation steps. Complete the installation process.
- Now your subsite will be ready for use. Dash ahead happily with your new Drupal subsite.
Find out how our expert Drupal website maintenance team can help optimize your website! Get in touch with us today!
Call Drupal Geeks @ 312-340-7112 or send an email to [email protected]