Content Management System aka CMS makes website building easy.
But, what if you have more than one cms website? Definitely, you have to remember site logins for each website.
Luckily, Craft CMS multisite is one of the quick solutions that allows managing multiple cms websites through a single Craft 3 install.
Today, we’ll see how our Support Engineers set up Craft CMS multisite and fix related errors
How we set up Craft CMS multisite
Basically, Craft 3 allows hosting multiple websites in a single Craft installation. So, let’s see how our Support Engineers install Craft CMS with the following steps.
1. Initially, we download the craft cms either by Composer or by manually downloading a zip or tar.gz archive.
Note that, when using Composer, there is no need to extract the downloaded Craft files.
composer create-project craftcms/craft <Path>
But, in the manual downloading method, we need to extract the files after downloading the zip files.
2. So, we extract the archive into a new directory wherever we want this new Craft project to live.
3. Next, we set the file permissions to the site user who owns the actual folders/files. Also, when we use the Composer to download Craft, it will automatically assign the permission to the site user.
4. After that, we switch to the project’s root directory and set a security Key by run the following command.
4. Then, we create a database for the Craft project.
5. Also, we configure a Web Server. So that the site should point to the document root which is web/ directory.
6. Next, we run the following command to run the Setup Wizard.
Now, we should be able to access the new Craft site from the web browser. The sample page shows up as:
For the multisite setup, we can simply create multiple sites under the same Craft CMS. The option to create sites lies under Settings >> Sites >> New site
To enable a unique link for each of the websites, we need to tick the checkbox “This site has its own base URL.”
Further, our Dedicated Engineers replicate sections for each of the websites in Craft CMS.
Common problems after setting up multisite via Craft CMS
1. PHP version mismatch
Basically, PHP is one of the most frequently used scripting languages for websites. Also, PHP compatibility is a major problem for craft websites.
Because when we install craft cms, it is necessary to have at least PHP version 7 on the server. Otherwise, it may cause errors like :
Craft requires PHP 7.0 or later. Script @php craft setup/welcome handling the post-create-project-cmd event returned with error code 1
The above errors showed up when the customer ran the command to
./craft setup/security-key set up a security key.
2. Database error
Recently, one of our customers had a problem while installing Craft cms on the server. He was getting an error while installing craft. Also, the error said,
Database Connection Error – crafterrorsDbConnectException Craft CMS can’t connect to the database with the credentials in config/db.php.
On checking, our Support Engineers found that the user’s database settings in file .env was incorrect. He had set up the MySQL server as DB_SERVER=”localhost”. However, his MySQL was listening to the internal IP address. So, we changed the settings of DB_SERVER =”localhost” to DB_SERVER = “internal IP”.
This fixed the problem and Craft CMS started loading fine.
[Having trouble while setting up craft cms multisite? We’ll fix it for you.]
In short, Craft CMS multisite option allows the managing of multiple websites through a single Craft 3 install. Today, we saw how our Support Engineers set up multisite in craft cms and fix related errors.