Install Drupal 8 content management system

Note

Drupal is a web site content management system serving web pages to the internet.

Prepare

Install Apache2 web server if not already installed.

Enable Apache2 rewrite module:

$ sudo a2enmod rewrite

Configure Apache2:

$ gksudo gedit /etc/apache2/apache2.conf

Specify, keeping "<" and ">":

<Directory /var/www/>
    Options Indexes FollowSymLinks
    # AllowOverride None # replaced with next line
    AllowOverride All
    Require all granted
</Directory>

Restart Apache2 service:

$ sudo systemctl restart apache2
or
$ sudo service apache2 restart
Install MySQL server + PHP5 + phpMyAdmin, and create a user with database both called "drupal8".

Co-exist with Drupal7

Change "web" below to "web2" to create another set of folders to co-exist with Drupal7 currently using "web", otherwise, just use "web".

Install

Download Drupal 8.2.4 (filename drupal-8.2.4.tar.gz) from https://drupal.org/project/drupal, usually to own "Downloads" directory.

Use the file manager to extract the contents of the compressed file under the "Downloads" directory as "drupal-8.2.4".

Create a folder for Drupal but using a directory name of "web" instead of the default of "drupal":

$ sudo mkdir /var/www/web

Move the contents under drupal-8.2.4:

$ sudo mv /home/<own account name>/Downloads/drupal-8.2.4/* /var/www/web/

See if there are hidden files beginning with ".", e.g. ".htaccess", ".gitignore":

$ sudo ls -la /home/<own account name>/Downloads/drupal-8.2.4

Move the hidden files also:

$ sudo mv /home/<own account name>/Downloads/drupal-8.2.4/<hidden file name> /var/www/web

Create a location for site files:

$ sudo mkdir /var/www/web/sites/default/files

Change ownership:

$ sudo chown www-data:www-data /var/www/web/sites/default/files

Create the initial configuration file for the default site:

$ sudo cp /var/www/web/sites/default/default.settings.php /var/www/web/sites/default/settings.php

Change ownership:

$ sudo chown www-data:www-data /var/www/web/sites/default/settings.php

Restart Apache2 service:

$ sudo systemctl restart apache2
or
$ sudo service apache2 restart

Complete the Drupal Installation through a Browser by pointing to http://localhost/web/install.php, and follow the instructions there, using:

  • Choose language: English language
  • Choose profile: Standard
  • Setup database: MySQL
  • MySQL database name, user name and password as defined above
  • Site name: www.kctang.com.hk
  • Site e-mail address: <>@kctang.com.hk
  • Site maintenance username:
  • Site maintenance user e-mail address: <>@kctang.com.hk
  • Default country: Hong Kong S.A.R., China
  • Default time zone: Asia/Hong Kong
  • Check for updates automatically
  • Receive e-mail notifications

Change folder permissions:

$ sudo chmod 555 /var/www/web/sites/default
$ sudo chmod 444 /var/www/web/sites/default/settings.php

Permit installation of additional modules:

$ sudo chown www-data:www-data -R /var/www/web/modules
$ sudo chown www-data:www-data -R /var/www/web/themes
$ sudo chown www-data:www-data -R /var/www/web/sites

Increase upload file size limit:

$ gksudo gedit /etc/php/7.0/apache2/php.ini

Change existing to:

post_max_size = 200M
upload_max_filesize = 50M
max_file_uploads = 100

Restart Apache2 service:

$ sudo systemctl restart apache2
or
$ sudo service apache2 restart

Migrate from Drupal7 (as of 1 January 2017)

Log in as an administrator if not already in.
Choose "Manage" > "Extend" > "Book" module under Core > "Install" at the bottom, to allow users to create and organize related content in an outline.
Choose "Manage" > "Extend" > "Statistics" module under Core > "Install" at the bottom, to log content statistics.
Similarly, enable modules in Drupal8 that are enabled in Drupal7.
Click open the explanatory note of "Statistics". Select "Configure" > "Count content views" > "Save configuration" > "Continue".
Choose "Manage" > "Extend" > "Migrate", "Migrate Drupal" and "Migrate Drupal UI" modules under Core (Experimental) > "Install" at the bottom, to allow users to create and organize related content in an outline.
Click open the explanatory note of "Migrate Drupal UI". Select "Configure" > "Continue" > "maintenance mode" > "Put site into maintenance mode" > "Save configuration".
Move web page back to the Upgrade page. Choose "Continue".
Under SOURCE DATABASE, enter: 
  • Database host: localhost
  • Database name: drupal7
  • Database username: drupal7
  • Database password: <>

Under SOURCE FILES, assuming under "oldweb" enter:

  • /var/www/oldweb

Re-direct http path without "www" or "web"

Move ".htaccess" file up one level:

$ sudo mv /var/www/web/.htaccess /var/www

Edit ".htaccess" file:

$ sudo nano /var/www/.htaccess

Specify:

# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/... will be redirected to http://example.com/...)
# uncomment the following:
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]
# last 2 lines uncommented
 
# RewriteBase /drupal
# add the next line after the last line
RewriteBase /web
 
RewriteRule ^ index.php [L]
# add the next line after the last line to change "http:/[ ]/" to ["http:/[ ]/web/welcome"
RewriteRule ^$ web/index.php [L]

Restart Apache2 service:

$ sudo systemctl restart apache2
or
$ sudo service apache2 restart