Salta al contenuto principale

Installing Drupal 11 on Shared Hosting: How to Overcome the web/ Directory Limitation

Installing Drupal 11 on Shared Hosting

1️⃣ Step 1

📋 Copy via SSH

# Move to the target public folder
cd ~/domains/tuodominio.it/public_html

# Purge all visible files and folders
rm -rf *

# Purge all hidden files and system dotfiles
rm -rf .[^.]* 2>/dev/null

2️⃣ Step2

📋 Copy via SSH

# Download the initial Drupal configuration files into a nested sandbox directory
composer create-project drupal/recommended-project drupal11tmp --no-install

# Enter the newly generated sandbox directory
cd drupal11tmp

3️⃣ Step 3

📋 Copia via SSH

# Enter the newly generated sandbox directory
cd drupal11tmp

4️⃣ Step 4

📋 Copy via SSH

# Copy all visible contents from the web folder to the current directory drupal11tmp
cp -R web/* .

# Copy all hidden files (dotfiles) from the web folder to the current directory
cp -R web/.[^.]* . 2>/dev/null

# Remove the empty web directory
rm -rf web

5️⃣ Modifica il file composer.json per la struttura FLAT

Open the `composer.json` file located in the temporary folder (using your hosting provider's editor or a text editor via SSH, such as `nano composer.json`) and configure it for the FLAT structure.

We need to make three precise changes: set the web root to `./`, remove the `web/` prefix from all entries in `installer-paths`, and, most importantly add the directive to disable symbolic links.

The file must look exactly like this:

📋 Copy via composer.json

{
    "name": "drupal/recommended-project",
    "type": "project",
    "repositories": {
        "drupal": {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    },
    "require": {
        "composer/installers": "^2.3",
        "drupal/core-composer-scaffold": "^11.4",
        "drupal/core-recipe-unpack": "^11.4",
        "drupal/core-project-message": "^11.4",
        "drupal/core-recommended": "^11.4",
        "drupal/metatag": "^2.2"
    },
    "config": {
        "allow-plugins": {
            "composer/installers": true,
            "drupal/core-composer-scaffold": true,
            "drupal/core-recipe-unpack": true,
            "drupal/core-project-message": true,
            "symfony/runtime": true
        }
    },
    "extra": {
        "drupal-scaffold": {
            "locations": {
                "web-root": "./"
            },
            "symlinks": false
        },
        "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"],
            "themes/custom/{$name}": ["type:drupal-custom-theme"],
            "recipes/{$name}": ["type:drupal-recipe"]
        }
    }
}

6️⃣ Step 6

📋 Copy via SSH

# Authorize the core composer scaffold plugin explicitly
composer config allow-plugins.drupal/core-composer-scaffold true

# Download the complete Drupal codebase packages into the sandbox
composer install

# Execute the core scaffolding to generate index.php and server files
composer drupal:scaffold

# Rebuild the autoload class mapping for the FLAT environment
composer dump-autoload

7️⃣ Step 7

📋 Copy via SSH

# Move all visible deployment files and folders up to public_html
mv * ..

# Move all hidden configuration files and dotfiles up to public_html
mv .[^.]* .. 2>/dev/null

8️⃣ Step 8

📋 Copy via SSH

# Step back up into your main web document root (public_html / httpdocs)
cd ..

# Remove the empty sandbox directory safely
rmdir drupal11tmp

# Provision the system uploads folder and set directory permissions for shared hosting
mkdir -p sites/default/files
chmod 775 sites/default/files

9️⃣ Step 9

📋 Copy via SSH

# Regenerate the autoloader configuration targeting the final FLAT filesystem map
composer dump-autoload

🔟 Installa Drupal dal browser

🌐 Website URL

https://tuodominio.it

SCRIVIMI

Contatti e supporto tecnico

Il sito di Progettimultimediali.com raccoglie contenuti tecnici su Drupal e sviluppo web in diversi formati:

  • Ebook su Amazon KDP - guide e approfondimenti strutturati
  • Articoli sul sito - guide e approfondimenti
  • YouTube - contenuti selezionati e dimostrativi

Se hai domande sui contenuti trattati, puoi contattarmi descrivendo brevemente la tua situazione

Scrivimi →