KnowledgebaseWeb Development

Install Drupal CMS in Root Directory

Using Composer

Access Your Server via SSH and Navigate to the Directory where Drupal Will be Installed

  1. In Command Line Interface, type: ssh username@serverip -p yourportnumber, replacing username, serverip, and yourportnumber with your specific credentials for your server,
  2. Once prompted for your password, type it or paste it,
  3. Once your SSH session has been authenticated, navigate to the directory where Drupal will be installed by using a command similar to the following: cd path/to/your/drupal/directory, or
  4. Make the directory with command: mkdir directorynamehere.

Using a web browser

  1. Go to drupal.org/download and copy the provided composer command,
  2. Add the --no-install option,
  3. Your command should look similar to this: composer create-project --no-install drupal/cms,
  4. Paste the command into your SSH command line interface.

Move the ‘web’ directory to the root directory

  1. There should be a directory named, “cms” with some files and a folder called “web”,
  2. Move all files and directories from “cms” folder to root directory: mv cms/* ./,
  3. Delete “cms” folder: rmdir cms,
  4. Move all files and directories from web folder to root directory: mv web/* ./,
  5. Delete web folder: rmdir web.

Edit composer.json File

  1. Type: vi composer.json,
  2. Type: i to enable insert mode,
  3. Find and change web-root and installer-paths directives from web directory to root directory.
"drupal-scaffold": {
            "locations": {
                "web-root": "web/"
            }
        },       
 "installer-paths": {
            " web/core": ["type:drupal-core"],
            " web/libraries/{$name}": ["type:drupal-library"],
            " web/modules/contrib/{$name}": ["type:drupal-module"],
            " web/profiles/contrib/{$name}": ["type:drupal-profile"],
            " web/themes/contrib/{$name}": ["type:drupal-theme"],
            "./drush/Commands/contrib/{$name}": ["type:drupal-drush"],
            " web/modules/custom/{$name}": ["type:drupal-custom-module"],
            " web/profiles/custom/{$name}": ["type:drupal-custom-profile"],
            "./recipes/{$name}": ["type:drupal-recipe"],
            "web/themes/custom/{$name}": ["type:drupal-custom-theme"]
        },
  1. Change the above to:
"drupal-scaffold": {
            "locations": {
                "web-root": "./"
            }
        },       
 "installer-paths": {
            "./core": ["type:drupal-core"],
            "./libraries/{$name}": ["type:drupal-library"],
            "./modules/contrib/{$name}": ["type:drupal-module"],
            "./profiles/contrib/{$name}": ["type:drupal-profile"],
            "./themes/contrib/{$name}": ["type:drupal-theme"],
            "./drush/Commands/contrib/{$name}": ["type:drupal-drush"],
            "./modules/custom/{$name}": ["type:drupal-custom-module"],
            "./profiles/custom/{$name}": ["type:drupal-custom-profile"],
            "./recipes/{$name}": ["type:drupal-recipe"],
            "./themes/custom/{$name}": ["type:drupal-custom-theme"]
        },
  1. Press Esc key to exit insert mode,
  2. Type: :wq to save file and exit.

Install Drupal

  1. For developer site, type: composer install.
  2. For production site, type: composer install --no-dev.
  3. Create your database.
  4. Run the interactive installer via a web browser.
  5. Follow the steps provided in the INSTALL.txt file located in the core directory to complete your setup and secure your site.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top button