Salta al contenuto principale

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


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

# Clear Composer's physical global user cache to prevent metadata conflicts
rm -rf ~/.composer/cache
composer clear-cache

IMPORTANTE: sostituisci in tutta la guida "tuodominio.it" con il tuo dominio reale (es. "test26.sviluppo.host").


2️⃣ Step 2

📋 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

📋 Copy via SSH

# Copy all visible contents from the web folder to the current directory (silencing empty warnings)
cp -R web/* . 2>/dev/null

# 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

4️⃣ Step 4

//* 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": {
            "//2": "Force core entry scripts (index.php, .htaccess) to populate directly on current root",
            "locations": {
                "web-root": "./"
            },
            "//3": "Disable symbolic links generation to bypass restricted hosting server rules",
            "symlinks": false,
            "//3b": "Authorize scaffold plugin to generate files safely on the root folder",
            "allowed-packages": [
                "*"
            ]
        },
        "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"]
        }
    }
}

5️⃣ Step 5

Return to the drupal11tmp temporary folder

📋 Copy via SSH

# Step 1: Whitelist and authorize the core composer scaffold plugin explicitly
composer config allow-plugins.drupal/core-composer-scaffold true

# Step 2: Update dependencies and generate a clean unified lock file bypassing proxy filters
composer update --no-plugins

# Step 3: Extract core packages, modules, and themes physically onto the filesystem
composer install

# Step 4: Run the scaffold with native plugins enabled to generate root entry files
composer drupal:scaffold

# Step 5: Build a clean mapping file for the PHP class loader
composer dump-autoload

6️⃣ Step 6

📋 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

7️⃣ Step 7

📋 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

8️⃣ Step 8

📋 Copy via SSH

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

9️⃣ Step 9

🌐 Website URL

https://website.com

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 →