Installing Drupal
You wouldn't think it would be this complicated to install, but...
I had been working through https://www.drupal.org/documentation/the-essentials-7, and was struggling to create a drupal project on my local machine. I tried following https://www.drupal.org/docs/getting-started/installing-drupal, but was hoping to be able to start a site that wasn’t the quick-start demo site Drupal provides. It took a bit of poking around, googling error messages, and guesswork, but I managed to assemble this set of instructions that reliably allows me to set up a new Drupal project that’s persistent and independent from other projects on my machine. This is on a Mac Mini running Sonoma 14.3.
- I understand you need to have PHP <= 8.1 installed, as well as Composer,
so best to
check that before proceeding:
php --version,composer --version cd <directory-in-which-you-want-your-project-to-live>composer create-project drupal/recommended-project <some-directory>- This command creates a directory called
<some-directory>, downloads some necessary files, and puts them in that directory
- This command creates a directory called
cd <some-directory>php web/core/scripts/drupal install, selectingstandard(or, optionally,minimal- you do you) when promptedcd web(without moving to this directory, you’ll get an error message along the lines ofIn Connection.php line 124: SQLSTATE[HY000] [14] unable to open database filewhen you try to run the next command)-
php core/scripts/drupal server-
If the server hangs after a little while using the above command,
you can try running
php -S 127.0.0.1:8888 .ht.router.phpinstead, as suggested here.
-
If the server hangs after a little while using the above command,
you can try running
- now there’s a server running serving your site, and you can visit it
in the browser at
http://127.0.0.1:8888 - when you want to stop the server,
Ctrl-C
If you want to start another project, follow the same steps,
specifying a different directory for the
composer create-project command. To switch back to the
first project, navigate to <some-directory>/web and
run php core/scripts/drupal server. Changes made on both
projects should be independent and persistent.
Posted: May 28, 2024. Last updated: Jun 06, 2024.