DEV Community

Amulya
Amulya

Posted on

Install Drupal 11 w/ Composer

Your step by step guide for installing Drupal 11 with PHP 8.3:

Prerequisites

  • PHP 8.3: Ensure PHP 8.3 is installed and configured.
  • Composer: Ensure Composer is installed.
  • Database: Latest version of MySQL, MariaDB, PostgreSQL, or SQLite.
  • Web Server: Apache, Nginx, or another compatible web server.

Step 1: Install PHP 8.3

If PHP 8.3 is not installed, you can install it depending on your OS:

On Ubuntu/Debian:

  1. Add the PHP repository:
   sudo add-apt-repository ppa:ondrej/php
   sudo apt-get update
Enter fullscreen mode Exit fullscreen mode
  1. Install PHP 8.3:
   sudo apt-get install php8.3 php8.3-cli php8.3-fpm php8.3-mysql php8.3-xml php8.3-gd php8.3-mbstring php8.3-curl php8.3-zip php8.3-soap php8.3-intl php8.3-bcmath
Enter fullscreen mode Exit fullscreen mode

On CentOS/RHEL:

  1. Enable the EPEL and REMI repositories:
   sudo dnf install epel-release
   sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
Enter fullscreen mode Exit fullscreen mode
  1. Install PHP 8.3:
   sudo dnf module reset php
   sudo dnf module install php:remi-8.3
   sudo dnf install php php-cli php-fpm php-mysqlnd php-xml php-gd php-mbstring php-curl php-zip php-soap php-intl php-bcmath
Enter fullscreen mode Exit fullscreen mode

Verify the installation:

php -v
Enter fullscreen mode Exit fullscreen mode

Step 2: Create a Project Directory

  1. Open your terminal.
  2. Navigate to the directory where you want to install Drupal:
   cd /path/to/your/webroot
Enter fullscreen mode Exit fullscreen mode
  1. Create a new directory for your Drupal project:
   mkdir drupal11-project
   cd drupal11-project
Enter fullscreen mode Exit fullscreen mode

Step 3: Install Drupal 11 with Composer

  1. Run the following Composer command to create a new Drupal 11 project:
   composer create-project drupal/recommended-project .
Enter fullscreen mode Exit fullscreen mode

This command will:

  • Create a new Drupal project in the current directory.
  • Download Drupal core and all required dependencies.
  • Set up a web directory where Drupal's web-accessible files will be stored.

Step 4: Set Up the Web Server

  1. Apache: Create a virtual host for your Drupal site, pointing the document root to the web directory:
   <VirtualHost *:80>
       ServerName yoursite.local
       DocumentRoot /path/to/your/drupal11-project/web

       <Directory /path/to/your/drupal11-project/web>
           AllowOverride All
           Require all granted
       </Directory>

       ErrorLog ${APACHE_LOG_DIR}/error.log
       CustomLog ${APACHE_LOG_DIR}/access.log combined
   </VirtualHost>
Enter fullscreen mode Exit fullscreen mode

Then, enable the site and restart Apache:

   sudo a2ensite yoursite.local.conf
   sudo systemctl restart apache2
Enter fullscreen mode Exit fullscreen mode
  1. Nginx: Configure your server block to point to the web directory:
   server {
       listen 80;
       server_name yoursite.local;
       root /path/to/your/drupal11-project/web;

       index index.php index.html index.htm;

       location / {
           try_files $uri /index.php$is_args$args;
       }

       location ~ \.php$ {
           include snippets/fastcgi-php.conf;
           fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
       }

       location ~ /\.ht {
           deny all;
       }
   }
Enter fullscreen mode Exit fullscreen mode

Then, restart Nginx:

   sudo systemctl restart nginx
Enter fullscreen mode Exit fullscreen mode

Step 5: Set Up the Database

  1. Create a new database for Drupal. For MySQL or MariaDB:
   CREATE DATABASE drupal11;
   CREATE USER 'drupaluser'@'localhost' IDENTIFIED BY 'your_password';
   GRANT ALL PRIVILEGES ON drupal11.* TO 'drupaluser'@'localhost';
   FLUSH PRIVILEGES;
Enter fullscreen mode Exit fullscreen mode

Step 6: Run the Drupal Installation

  1. Open your web browser and navigate to http://yoursite.local.
  2. Follow the installation wizard:
    • Select the installation language.
    • Choose an installation profile (Standard is recommended for most users).
    • Configure the database settings with the details you created in Step 5.
    • Complete the installation by entering your site details and admin account information.

Step 7: Finalize Configuration

  1. Set the appropriate file permissions:
   chmod -R 755 /path/to/your/drupal11-project
   chmod -R 644 /path/to/your/drupal11-project/web/sites/default/files
Enter fullscreen mode Exit fullscreen mode
  1. (Optional) Enable clean URLs by adding the following to your .htaccess file if using Apache:
   RewriteEngine on
   RewriteBase /
Enter fullscreen mode Exit fullscreen mode

Step 8: Secure Your Installation

  • Remove the install.php file after installation.
  • Regularly update your Drupal installation and modules.

Your Drupal 11 installation with PHP 8.3 is now complete and ready to use!

Install Drupal 11 on Windows 10

To install drupal 11 with composer on your operating system, simply watch this video for practical step by step guide.

Top comments (0)