Install Drupal 9 using composer

Composer can be used to manage Drupal and all dependencies (modules, themes, libraries). Make sure you have composer installed on your local machine before executing any Composer commands

  • Create/Download Project using composer
  • Install Drush
  • Install Drupal site using drush and configured Database
  • configured local site: apache vhost file
  • configured local site : windows host file
  • Open browser and hit local configured websites
  • Login and check drupal and PHP version

Related: Download & install drupal 9 using composer with lando

To Create/Download Drupal Project

command: sudo composer create-project drupal/recommended-project headlessproject

download-and-create-project using composer
download-and-create-project using composer part – 1
download-and-create-project using composer
download-and-create-project using composer part – 2

Install Drush

Command: sudo composer require drush/drush

Install drush using composer
Install drush using composer

Install Drupal site using drush and configured Database

command: drush site:install

Install Druapl site part - 1
Install Druapl site part – 1
Install Druapl site part - 2
Install Druapl site part – 2

Configured local site: apache vhost file

command: sudo vi /etc/apache2/sites-available/vhosts.conf

<VirtualHost *:80>
  ServerName drupalheadless.test
  ServerAlias www.drupalheadless.test
  DocumentRoot "/var/www/drupalvm/drupalprojects/headlessproject/web"

  <Directory "/var/www/drupalvm/drupalprojects/headlessproject/web">
    AllowOverride All
    Options -Indexes +FollowSymLinks
    Require all granted
  </Directory>
  <FilesMatch \.php$>
  SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>

</VirtualHost>

Copy the above code and past in this terminal and save using: Esc + :wq

Configured website in vhost file at your local computer

  • search notepad in your windows
  • right click on notepad and open as administrator
Open notepad as adminstrator

Click on file and Open path: C:\Windows\System32\drivers\etc

C:\Windows\System32\drivers\etc
C:\Windows\System32\drivers\etc
hosts file
hosts file
Select All files and select vhost file to open
Select All files and select host file to open
configured website in localhost
configured website in localhost and save

Re-start server

command: sudo service apache2 restart

re-start server
re-start server

Clear cache

command: drush cr

Open any browser and hit in URL: drupalheadless.test

drupalheadless.test
drupalheadless.test

click on login and enter your user name: admin and password: 2iKW6NeUEQ (which is generated by drupal when we have installed using drush)

Main navigation : Reports
Main navigation : Reports
See details of Drupal and PHP Version
See details of Drupal and PHP Version

Pradip Mehta

I am a well-organized professional in Drupal Development and PHP web development with strong script handling knowledge or automation process with PHP. I have advanced computer skills and am a proficient multitasker.

Leave a Reply