Join the community today
Become a Member

Drupal Drupal9 webroot question

Discussion in 'Blogs & CMS usage' started by dce, May 18, 2022.

  1. dce

    dce Member

    33
    6
    8
    Feb 21, 2018
    Ratings:
    +7
    Local Time:
    6:49 PM
    eva2000, I have one other question to ask you, if you don't mind.

    I have a few Drupal 7 servers I have to move to Drupal 9 (composer). Drupal 9 (and other symphony apps) install in "web" docroot folder.

    Is it possible to change webroot from "public" to "web", and if so, how best to go about it? I just need to do it manually on specific drupal installs after the normal centmin generic vhost install.


    Thanks
     
  2. eva2000

    eva2000 Administrator Staff Member

    48,899
    11,189
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,423
    Local Time:
    8:49 AM
    Nginx 1.21.x
    MariaDB 10.x
    Not a Drupal user myself. Googled and probably best way is to install Drupal with changing the /web directory to /public. Quick Google had these 3 links but probably more guides out there you can try on a test Drupal 9 install attempting to install by default the web root to /public instead of /web.
    Centmin Mod some scripts do look for /public web roots for determining certain things so while you can just change the root directive in your Nginx vhost domain.com.conf or domain.com.ssl.conf, it's probably better long term if you changed how you install Drupal if you have the option to do so.
     
  3. eva2000

    eva2000 Administrator Staff Member

    48,899
    11,189
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,423
    Local Time:
    8:49 AM
    Nginx 1.21.x
    MariaDB 10.x
    My first time in years trying Drupal install but did some Googling and reading and came up with steps for this in Github gist Drupal 9 Centmin Mod install in /public. Should get you started.

     
  4. dce

    dce Member

    33
    6
    8
    Feb 21, 2018
    Ratings:
    +7
    Local Time:
    6:49 PM
    Thanks eva2000.

    With Drupal, the composer workflow is to develop in a local environment and push to the server with git etc.

    I like to use DDEV for my local environment (trusted local ssl cert etc) but I have not found a way to do the usual drupal procedure (as you mentioned) to change the default docroot folder in the DDEV docker environment. Composer throws errors. That is the problem I am facing.

    I was worried about possible negative side effects if I changed the root directive in the Ngnix vhost configs, hence I reached out to you.

    Based on your information, for my drupal use cases on centmin servers, I will just use a VM or Lando to set up my local dev environments if I can't find a way to get DDEV to work on the local side of things.

    Thanks again.....
     
  5. dce

    dce Member

    33
    6
    8
    Feb 21, 2018
    Ratings:
    +7
    Local Time:
    6:49 PM
    Just saw this post after I posted my first reply. Read through the script. Well done. The only thing to add is drush.

    If I can't find a solution for DDEV (I reached out on their github page), I am going to use centmin on a VM for my local development and utilize the script and information to setup on the VM.

    That will be my local dev and then it is a simple matter to commit and push to the server and run composer install --no-dev etc to keep synced with dev. All I have to do on the server is configure the vhost config to run drupal as detailed in the latter part of your document (very similar to what I currently have to run Drupal 7).

    Thank you very much eva2000, you have been very helpful, much appreciated.
     
  6. eva2000

    eva2000 Administrator Staff Member

    48,899
    11,189
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,423
    Local Time:
    8:49 AM
    Nginx 1.21.x
    MariaDB 10.x
    Is that the drush command listed at https://www.lullabot.com/articles/goodbye-drush-make-hello-composer to do actual install instead of via the browser? I can update the gist for that.

    Can't you change composer.jsonin in Docker on your dev environment?

    But DDEV I assume is capable of defining the web root path at setup time for composer installs according to Google searched docs at Using the CLI - DDEV-Local Documentation
     
  7. dce

    dce Member

    33
    6
    8
    Feb 21, 2018
    Ratings:
    +7
    Local Time:
    6:49 PM
    Yes, regarding drush, it is incredibly useful when used along with composer. Drupal 9 drupal/recommended-project template does not install it as a composer requirement anymore. You need to run "composer require drush/drush", usually after composer install.

    ddev config command (which initializes a project container) will create a specified docroot for the docker container. The problem I was having was getting drupal composer install to use that custom docroot directory created by ddev config (even after editing composer.json). It would throw errors in the browser when I tried to open the site.

    I got it to work by deleting the "public" folder (public docroot directory for centmin mod) that ddev created right after running:
    ddev config --project-type=drupal9 --docroot=public --create-docroot

    Then:

    ddev start

    ddev composer create "drupal/recommended-project" --no-install

    edit composer.json to change default "web" docroot instances to "public"

    ddev composer install (this recreates the initial public directory I deleted)

    and finally "ddev launch" to launch a browser with a drupal install instance.

    DDEV is very nice. Quick and easy to spin up project containers with working local development enviroment ssl certs out of the box.

    Thank you for the script / information to get a drupal composer install running on centmin mod. Very comprehensive and nicely done - you have server administration down to a fine art! Should make life much easier for anyone needing to run Drupal on centmin mod.
     
  8. eva2000

    eva2000 Administrator Staff Member

    48,899
    11,189
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,423
    Local Time:
    8:49 AM
    Nginx 1.21.x
    MariaDB 10.x
    Glad it was helpful :) Definitely helps that I developed Centmin Mod so know my way around it :D