Installing Drupal 8

I'm new to Drupal. So new that I didn't begin to research Content Management System's until after Drupal 8 was released. When I looked for a guide to install it on my server I found this one on Ubuntu for D6 & D7, and a few others (that I cannot rediscover), which outline the Composer method & the Drush method. The Ubuntu method didn't work when I tried modifying it for a specific Drupal 8 file. It seems that the official instructions from Drupal for release 8 have been made easy, so me attempting to modify an older guide is counterproductive; have a look at Installing Drupal 8 | and you'll get a good idea of what I do in the video.

Installation of Drupal 8 is a pretty simple operation that I found a way to make very difficult on my first attempt. It can be as simple as downloading and unzipping the Drupal core files in the folder of your website, installing the composer program, running one command with composer, and then opening the default page of the "Drupal" directory. That's what I did on my second attempt.

If you follow along the official Installing Drupal 8 instructions, you can skip the section called Before installation, because you already did more than they what they're asking you to do, that is if you're following my whole guide. Just skip to Step 1: Get the Code; that's about where my video below begins. If you got to this page in my guide and don't intend to install Drupal 8 on a Ubuntu/Linux web-server, you will probably like their Local server setup instructions. That page also has useful links for backup and development copies.

Things I needed to do for my special case:

  • Others => File Manager
    • Go to the root directory for Virtual Host, like for me it's /var/www/outsourcedmath
    • If you have no site in your V.Host folder (no files and folders), skip to "Also semi-optional, get Git going now"
    • If you have a site now, you need a place to move it to before you proceed; mine is going into /var/www/html, but you'll have to make an appropriate place for your own.
    • If you can't see all the folders and files in your equivalent of my /var/www/outsourcedmath, change the "Show [_____] entries" value to get them all displaying on one page.
    • Click the Others => File Manager => "Select All" checkbox tool.
    • Click Others => File Manager => Edit => Cut
    • Navigate back into your destination directory, your equivalent of my /var/www/html
    • Click Others => File Manager => Edit => Paste
    • Navigate back to your version of my /var/www/outsourcedmath and confirm the folder is empty. If not move the rest to your cold storage folder, e.g. /var/www/html

Also semi-optional, get Git going now

If you plan to use the Git management system to safely deploy your website, now is a good time to make a repository somewhere, and link the Virtual Host's root directory to it. For this example I'm using my own internal GitLab server to store the repository. See my Setting up a GitLab Server page in this guide for details about other places you can store your Git Repository.

  • On a GitLab server while logged in to the web interface
    • Click the "New" or "+" tool then select New Project
    • Although you have many options on the New Project dialogue page, all you need to do is name it. I just went with outsourcedmath for my project. The combination of the GitLab server name, the user name associated at creation time and the project name determines the full URL to access the project remotely. If you forget to put the (optional) description in, you can do it later via the projects Settings => General page.
    • Repeat this step for any other logical project like other Virtual Servers/FQDN's and so forth.
  • If you are doing command line on a repository server:
    • If it's your first time there:
      • git config --global "Big Boy Pants"
      • git config --global ""
    • git init outsourcedmath
    • cd outsourcedmath
    • echo "Still tired from the move" > DayZeroTestFile.txt
    • git add DayZeroTestFile.txt
    • git commit -m "Okay, I [bigboypants] just started time"
  • On your web-server using Webmin, connect the web site directory with your Git Repository
    • "Alt-K" Terminal window
    • git config --global "Big Boy Pants"
    • git config --global ""
    • cd /var/www
    • git clone http://<user ID>:<Password>@WNYmathGuy/<repository owners ID>/outsourcedmath <root folder of your V.Host>
    • cd outsourcedmath
    • Check to see that their is a ".git" folder in your V.Host's root folder.
      • ls -al
  • On a Ubuntu Workstation using the "gitg" program
    • Click the link to "set up your git profile"
      • Name: "Big Boy Pants"
      • E-mail: ""
    • Click the button to "Clone" a repository
      • In the Remote URL: field, put the URL that GitLab told you after you created a project, e.g. http://WNYmathGuy/bigboypants/outsourcedmath.git
      • In the Local Folder: field, select the directory above the one you want to clone from GitLab, e.g. www
      • check or uncheck the Bare Repository as appropriate. Mine wasn't checked.
      • Click the "Clone" button in that dialogue box.
      • A new dialogue pop's up to receive user ID and password.
        • Username: "bigboypants"
        • Password: "How should I know that?"
    • Then in a terminal window...
      • cd www/outsourcedmath, or whatever your local repository is stored in
      • git pull http://WNYmathGuy/bigboypants/outsourcedmath.git
      • Use your GitLab password
    • Your gitg program will need to refresh to be able to graphically display the changes you made from the pull command.

This is how to do the Drupal 8 install (but NOT the one with Drupal Commerce):

A funny note here is in the week it took me to go from prepping to actually installing while recording an update from 8.3.6 to 8.3.7 occurred. I forgot how to do that update and relearned on the fly by reading Update procedure (minor version change) | while recording the video. Just know that updating or installing your version (unless maybe it's Drupal 9) will be the same as what's below.

  1. Get the link for your Drupal download from Download & Extend, like for me the download button points to 8.3.6 a.k.a.
    • Navigate back into /var/www/ (or anywhere really) because you just need to get that compressed drupal-8.3.6.tar.gz file on your server to unpack it.
    • Others => File Manager => Files => Download from remote URL
      • paste in the textbox for "URL of file to download"
      • Click the Download button
    • In the Action column, click the "Extract Archive" tool which is where the "Edit" tool usually is on the row for the drupal-8.3.6.tar.gz bundle
    • After it's done, enter the folder named "drupal-8.3.6"
    • If you can't see all the folders and files (maybe 22 items), change the "Show [_____] entries" value to get them all on one page.
    • Click the Others => File Manager => "Select All" checkbox tool.
    • Others => File Manager => Edit => Cut
    • Go back to the root directory for Virtual Host, e.g. /var/www/outsourcedmath
    • Others => File Manager => Edit => Paste
    • Navigate back to /var/www/drupal-8.3.6 and confirm the folder is empty. If not move the rest to your V.Host, e.g. /var/www/outsourcedmath
    • Unless you plan on doing many Drupal installs, navigate back to /var/www and select check-boxes for drupal-8.3.6 & drupal-8.3.6.tar.gz
    • Click the "Remove Selected" icon, which should be a red square with a white garbage can in it
    • Double check the owner & group for /var/www/outsourcedmath is "www-data" by recursive chown
      • Others => File Manager
      • Navigate to your V.Host's parent folder, e.g. /var/www/
      • Check the box to the left of your V.Hosts root folder.
      • Others => File Manager => Tools => Change ownership (aka: recursive chown)
      • Type "www-data" (or whatever the standard on your system is for web server ownership) into both the User name and Group name fields.
      • Check the box for Recursive
      • Click the button for Change
    • And might as well do the Git thing now if you're doing Git at all:
      • "Alt-K" Terminal window
      • cd /var/www/outsourcedmath
      • git add --all
      • git commit -m "Okay bigboypants just started time"
      • git push origin master
  2. If you haven't already, installed the Composer software you need to do it now. See the official Composer page for details, but their's a few ways to go about it. One is with Ubuntu shell commands, another shown at "How do I install Composer programmatically?" is by doing a shell script file, and they hyperlink you to even another method. I think the Composer way I show on Web Server Preparations is best so go there now, install it and come back here for procedure item 3.
    • VERY IMPORTANT NOTE: on 8/27/2017 while editing the video I realized I was missing the unzipping tool in PHP 7 and the composer install command was a failure. I had to run this in a terminal window (not the Alt-K)... You can try it with the Software Packages interface like Composer was done above.
      • ssh <root user name>@<localhost machine name>e.g. ssh
      • sudo apt install zip unzip php7.0-zip
        • Y
      • Run the composer install command for the Drupal 8 site in its directory. It may be php ~/bin/composer install or php /home/<your user name>/bin/composer install for you if you did it via the method I recommended.
  3. Create a Database! As that linked Drupal page tells you, you can do it a variety of methods, including the hyped method of phpMyAdmin. I recommend the phpMyAdmin method if you've put that on your server like I suggested you should. If you only have Webmin, these are the instructions for using that method:
    • Open Servers => MySQL Database Server
    • If you never used this module before, sign in to MySQL as the "root" user
    • Click User Permissions, then in the Global Options section, then click Create new user
    • In the User name row, click the radio button for the blank field, then enter the username that you want to use, e.g. SpongeBob
    • In the Password row, click the radio button for Set to..., then enter a great password, remember this is a public facing entry point to your site.
    • In the Hosts row, click the radio button for the blank field, then write localhost
    • DO NOT! click anything in the Permissions chooser! Those are global permissions not database specific.
    • Click the green Create button
    • Click the blue Return to database list button, then in the MySQL Databases section click Create a new database
    • In the Database name field, enter your desired database name, e.g. KrustyKrab
    • In the Character set field, select "utf8mb4 (UTF-8 Unicode)".
    • In the Collation order field, select "utf8mb4_unicode_ci (UTF-8 Unicode)". BTW the _ci means case insensitive sorting of data.
    • Click the green Create button
    • Click the blue Return to database list button, then in the Global Options section, then click Database Permissions, then click Create new database permissions
    • In the Databases row, click the radio button for Selected, then use the drop-down to find your database name, e.g. KrustyKrab
    • In the Username row, click the radio button for the blank field, then enter the username you created above, e.g. SpongeBob
    • In the Hosts row, click the radio button for the blank field, then write localhost
    • In the Permissions chooser, Click the top item, then Shift-Click the bottom item to select all permissions, and then hold the Ctrl button and click only the line item for "Grant privileges" to deselect it. Holding Ctrl while clicking one item at a time to select the just ones you want works also.
    • Click the green Create button
    • Click the blue Return to database permissions button, to see what you created.
  4. Configure your installation! This part is something I showed in Prepare Apache for Websites using Virtual Hosts, so you probably are already done with this step, if not, go to Prepare Apache for Websites and git-er-dun
  5. Go to your host URL and it should now launch the Drupal system's initialization page, for me it's, but you should know what your's is by now. ;)
  6. In the Drupal 8 web interface go to Administration => Reports => Status report
    • Fix any problems if they exist, then to tighten security...
    • Others => File Manager
      • Go to the root directory for Virtual Host then into sites/default; for me it's /var/www/outsourcedmath/sites/default
      • Edit settings.php by clicking the "Edit" Actions icon, then search (Ctrl-F) for the "Trusted host configuration" section and below all the comment lines (*/) add:
        • $settings['trusted_host_patterns'] = [
        • '^www\.<your FQDN>\.com$',
        • '^<your FQDN>\.com$',
        • ];
      • After you save and close that file, refresh the directory and see if the Permissions for settings.php are 0444. If they aren't select it's check-box and
        • Others => File Manager => Tools => Change Permissions
          • Uncheck any/all of the boxes in the Write row, then click Change.

Some other items I'm doing:

If you did a Drupal install, the .htaccess file they made has most of these hacks, you just need to un-comment them. They have instructions above all the hacks so it's pretty self explanatory.

Do the www remover thing and this related Apache page :

  • Edit .htaccess in the root folder of the V.Host you are working on.
    • RewriteEngine On
    • RewriteBase /
    • RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    • RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
  • Servers => Apache Webserver => ? V. Host ? => Networking and Addresses => Alternate virtual server names
    • Add and, etc. separated by starting a new line for each entry and then save the V.Host and reload Apache

If appropriate, do redirect thing for any of your sub-domains:

  • Servers => Apache Webserver => ? V. Host ? => Aliases and Redirects => Regexp URL redirects
    • From := ^/GinoC/(.+), subfolder of a subdomain "/GinoC/" implies "/var/www/wnymathguy/GinoC/"
    • Status := 301, implies a permanent redirection
    • To :=$1, name of the URL/V.Host of a subdomain
  • Whatever the client wrote after the "/GinoC/" will get concatenated onto where $1 is; (.+) catches and $1 delivers.

Number the default servers :

  • Internal IP of server goes into, Servers => Apache Webserver => ? V. Host ? => Virtual Server Details => Address
    • 192.168._?_._?_ where the number represents your servers IP number inside your network.

9/25/2017 Update Internal Machine IP Numbers

In Apache, all the Virtual Hosts I created I wrote the specific internal number of the machine that was hosting, e.g., but later I found things to work better if I left that set to "Any Address". All my V.Hosts now listen on Any Address => *. I also made use of the default server with the most prominent host on the machine.

10/19/2017 Update Fixing Spelling Errors in the Clients Request for a Sub-domain

I was using the "Networking and Addresses" section in a V.Host to add "Alternate virtual server names" so misspelled sub-domains would still resolve to the right host. It would not rewrite the misspelling to the correct one though. I tried various things with redirects and all were kludgie. I found some useful code after a bit of searching and now inside the .htaccess file for the default port 80 server I have code like this:

  • RewriteEngine On
  • RewriteCond %{HTTP_HOST} ^ [NC]
  • RewriteRule ^(.*)$$1 [R=301,L]
  • RewriteCond %{HTTP_HOST} ^ [NC]
  • RewriteRule ^(.*)$$1 [R=301,L]
  • ...and so on...
  • RewriteCond %{HTTPS} off
  • RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

That's perfect! It's quick and does exactly what I wanted it to. Because misspellings are almost random, patterns are not a way to rewrite, so you need a pair of lines to take any possible spelling to the correct one.


So after you are all settled in and your site is running, do the Fail2ban thing we talked about back in Activate Fail2ban NOW!!! for the "drupal-auth" filter action jail, then head to this gem, Syslog module overview | For me, I selected "Errors and warnings" from the options of which Error messages to display and I keep 1000 messages.

10/10/2017 Update about installing a Drupal 8 site with Drupal Commerce:

  • The website "" say's all you need to do is go in your websites top folder in a terminal window and execute "composer create-project drupalcommerce/project-base mystore --stability dev". Well! It didn't go that easy for me! I got an error message when I tried to sudo the composer program, so I had to run it as my user ID, but then it didn't run, so I had to uninstall Composer from the system and reinstall it as the instructions on the site says. Here's some prerequisites I needed to do on my system after I got composer on it the Composer way instead of the Ubuntu way (for my Composer install details see "Web Server Preparations"):
    • Check that the composer in my /home/username/ folder was owned by me. Somehow I had it in there as owner:group = root:root. Do a recursive chown on it if it's not owned by your login ID.
    • Check that the root folder of the website is owned by your username. e.g. owner:group = wcfeilds:www-data not www-data:www-data. If you can't write files and directories to it, the php composer command will fail.
    • Alter the base directory in Apache for the site from /var/www/outsourcedmath-ssl to /var/www/outsourcedmath-ssl/web.; if you use a text editor instead of Webmin, look for DocumentRoot and <Directory ... where the directory path matches document root path and add /web to the end of both path's. If you don't do this, Drupal will let users open directories and folders they shouldn't have access to with their browser when they go to your base site of instead of going to Like they could open and read any file contents in your site that has world read access (almost all of them). Since Drupal's file structure is public to anybody that ever downloaded it, it wouldn't take long for the most vital information to be read by a hacker in the know.
  • For me the command to build a Drupal Commerce site with the latest stable Drupal 8 software in the directory outsourcedmath-ssl was:
    • php ~/bin/composer create-project drupalcommerce/project-base /var/www/outsourcedmath-ssl --stability dev
      • Note: the composer command was "create-project" and the project creator/name was "drupalcommerce/project-base". And if the "~" is new to you, it's Linux speak for "look around for my home directory and write that in where I put the "~".
  • When the install is done you are asked "Do you want to remove the existing VCS (.git, .svn..) history? [Y,n]?", to which I know the proper response is "n".
  • This type of Drupal site has files normally found in the root directory for the site down in the "web" sub-directory.
    • Modify your newly created web/.htaccess file as desired:
      • I uncommented the lines for
        • RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
        • RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]
      • I add this to web/sites/settings.php around line 746:
        • $settings['trusted_host_patterns'] = [
        • '^www\.<my domain name>\.com$',
        • '^<my domain name>\.com$',
        • ];

  • To launch the first time, go to your base URL like a normal Drupal install. The following were errors I saw while proceeding and how I solved them:
    • The pretest of the system detected that the "../config/sync" folder either didn't exist or didn't have write privileges. See this link for the general output I saw.
      • No folder existed like that, but the "../" was ambiguous because that just means up one directory from where I'm looking. I put it in the web/sites directory, so web/sites/config/sync. That didn't work, but I noticed somehow the entire Drupal site and folders were all mine; owner:group = wcfeilds:wcfeilds. I changed them recursively to wcfeilds:www-data, but that didn't work. I moved the config/sync to the top level directory, so outsourcedmath-ssl/config/sync and that worked. That's the same directory as where the web folder resides.
    • The BCMath error! "Commerce requires the bcmath PHP extension." This one was a booger. I tried many things other people said they did but the results were all #fail.
      • The first productive move was to try reinstalling it with APT; sudo apt-get install php-bcmath. This produced results; php-bcmath was upgraded and php7.0-bcmath was newly installed. I rebooted the server. The next try with the Drupal site setup, was successful.

After I put in my database name, user ID and password in, and the site finished installing, I saw a message about removing write permissions on two items for security reasons. Do not ignore that message if you see it. I changed the site's sub-folder /web/sites/default from 775 to 755. This drops the write permission off of the www-data group but still allows reading and executing the folder. And I changed the /web/sites/default/settings.php file permissions from 666 to 640, which removes write permission from the www-data group and both write and read access from the rest of the world (who needed access to it during installation prior to having a username and password for the site but doesn't now because your MySQL user ID and password is in that file!). I, wcfeilds, as the site files + directory owner still have write privileges, but I probably don't need them. If you want to experiment on your own, change the permissions to 555 and 440 respectively and see if you ever have a problem. I don't think you will.

I'm not confident about this statement, but I think based on this Drupal Commerce slide (launched from this Drupal Commerce page) that I'm supposed to run this Composer command "php ~/bin/composer config repositories.drupal composer" from the top level directory of my Drupal 8 site. My best guess is that if I composer install a module, it will look for a Drupal 8 approved version first via the packages link.

About Modules from vendors other than Drupal Core. They have to be installed using the "Drupal Console" which is a bit like Composer. It's hard to notice, but look at the "Tips:" section of Installing a New Site. Drupal console is in the bin sub-directory of your commerce site. Let's assume you want to have the Google Analytics module on your site ( So get to your top directory of your Drupal Commerce website and execute the command: (I assume you are in maintenance mode already; .com/admin/config/development/maintenance. I don't know if you have to be, but...)

  • ./bin/drupal module:install google_analytics
    • at the prompt pick your version, I chose option 0 which was version 8.x-2.2

Let's assume you want to have the AddToAny Share Buttons module on your site (

  • ./bin/drupal module:install addtoany
    • at the prompt pick your version, I chose option 0 which was version 8.x-2.2
  • ./bin/drupal module:install simple_sitemap
    • at the prompt pick your version, I chose option 0 which was version 8.x-2.10

It's a good practice to after each alteration of modules, libraries, etc. you check the database maintenance with your .com/update.php script page. After that finishes, go back to your .com/admin/config/development/maintenance page and leave maintenance mode.

See for all the possible commands.

You will see those modules in the Extend area of your Drupal 8 site (, and they will already have their check-boxes checked, so you can go ahead and configure them like normal.

Oh, and if the "./" is new to you, a dot (or .) in a path statement means "this directory" so it finds the bin folder from where you type the command instead of maybe accidentally looking for it in some path preference setting for another directory called bin.

As a minor aside, AMP is a thing that Google respects for your SEO type concerns. It is a way of making your sites pages be very mobile friendly. If you are going to put on the AMP module you need the AMP theme & Library too, but I haven't found good instructions for doing that yet. I hope these suffice:

  • Get the latest AMP Theme zip file ( into your /web/themes/ folder and unzip it (then delete the zip file). Going to your sites .com/admin/appearance section will allow you to activate the two new related AMP themes. Don't forget to change the ownership of the theme to whatever the rest of the site is set as.
  • Get (or git) the libraries for AMP from Lullabot and put the files into a /sites/all/libraries/ directory of your site (make it if it's not there yet). From a terminal window in the /libraries directory execute the following commands:

Switch back to your main site directory and execute the following:

  • ./bin/drupal module:install adsense
    • at the prompt pick your version, I chose option 0 which was version 8.x-1.0
  • ./bin/drupal module:install token
    • at the prompt pick your version, I chose option 0 which was version 8.x-1.0
  • ./bin/drupal module:install amp
    • at the prompt pick your version, I chose option 0 which was version 8.x-1.0
  • php ~/bin/composer require lullabot/amp

Just for good measure, execute this:

That's the end of the AMP minor aside on this page.

Later on with your Drupal Commerce site you'll do maintenance like this:

Something that might go wrong is Drupal Console "./bin/drupal" may change your Composer repository for your drupal site ( <= wrong!). The "php ~/bin/composer config repositories.drupal composer" command will repair that error.

Want to add a Theme? Just unzip one of the download 8.x, tar.gz files in your site's ./web/core/themes/ folder. If things go well you 'll see a new folder appear with the name of the theme (e.g. ./web/core/themes/nero), then back at your drupal site's "/admin/appearance" page you'll see the new theme waiting to be installed. Make sure the right owner is listed; not root:root.

Wondering what to add to your site, these links may wet your appetite:

So here we're near our end. In parting, I noticed a nicely done Git quick-reference guide that hyperlinks to drill-down if you need full details. I'm personally going to the Drupal 8 User Guide | site now to learn developing in Drupal 8 (starting 8/16/2017). When you get to the part of your Drupal site called Extend, don't activate any of the unchecked modules until you understand what they are and need them, see to get more information on any of the Core modules.

I'm a big fan of the Talking Drupal podcast, and to a lesser extent the Drupal Easy podcast. I'm sure you'll find plenty of places to learn by looking around. Good luck to you!

Next Page: Drupal User Guide | Next Section: Installing WordPress 4.7