Drupal

From WebarchDocs
Jump to navigation Jump to search

Drupal on Webarchitects Servers

Some notes on running Drupal 7 and 8 on Webarchitects shared hosting servers.

We are able to provide a Drupal 8 download with any of the Webarchitects shared hosting packages which have at least one MySQL database, you simply need to run the web based installer using the MySQL database details you should have been sent in an email when the hosting account was created.

SSH access and Drush

On our new shared hosting servers we can optionally offer SSH access (rather than SFTP, which is provided by default) and this allows the use of drush.

Directives allowed in .htaccess files

Lines starting with Options in .htaccess files generate Internal Server Errors.

The Apache configuration we have on our shared hosting servers doesn’t allow all overrides, this means that if you have these default Drupal directives in a .htaccess file:

# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

Then you will generate an error like this in the error.log file:

[Tue Mar 26 17:21:09 2013] [alert] [client 12.34.56.7] /home/example/sites/default/.htaccess: Options not allowed here, referer: http://example.org/ 

The example above is taken from the default .htaccess file that comes with Drupal, the way we work around this issue is to have a specific Apache configuration for sites running Drupal.

The reason we don’t have all overides enabled is to ensure the privacy of clients data.

If you have a Webarchitects shared hosting account which uses our Drupal Apache configuration as above then you can probably remove (or move) the default .htaccess file or comment out the Options and IfModule sections.

Since Drupal generates lots of .htaccess files with Options in we have a script we can run to quickly comment them out, if you have SSH access then you can run it, or ask us to run it for you:

/usr/local/bin/htaccess-fix 

Setting PHP variables is also not allowed so if you have a block like this it will need commenting:

 # PHP 5, Apache 1 and 2.
 #<IfModule mod_php5.c>
 #  php_flag magic_quotes_gpc                 off
 #  php_flag magic_quotes_sybase              off
 #  php_flag register_globals                 off
 #  php_flag session.auto_start               off
 #  php_value mbstring.http_input             pass
 #  php_value mbstring.http_output            pass
 #  php_flag mbstring.encoding_translation    off
 #</IfModule>

Temporary Directory

The file_temporary_path is set to use your private tmp directory, /home/example/tmp, this variable is available to set from Home » Administration » Configuration » Media using the web interface,

In Drupal 6 and 7 you can also set it using drush:

drush vset file_temporary_path /home/$USER/tmp

In Drupal 8 you can also set it in the ~/sites/default/sites/default/settings.php file (replace example with your username):

$config['system.file']['path']['temporary'] = '/home/example/tmp';

Private Directory

The file_private_path should be set to /home/example/private, this variable can viewed from Home » Administration » Configuration » Media using the web interface.

With Drupal 6 or 7 you can set this variable using the web interface or this command if you have drush access:

drush vset file_private_path /home/$USER/private

With Drupal 8 you need to set it in the ~/sites/default/sites/default/settings.php file (replace example with your username):

$settings['file_private_path'] = '/home/example/private'

On Drupal 8 you have a warning:

Private files directory Not fully protected

See https://www.drupal.org/SA-CORE-2013-003 for information about the recommended .htaccess file which should be added to the directory to help protect against arbitrary code execution.

This is safe to ignore as your ~/private directory is outside the Apache DocumentRoot of your site (a sub-directory of ~/sites).

Trusted host configuration

In Drupal 8 you need to edit the ~/sites/default/sites/default/settings.php file to add the domains that your site uses, for example:

$settings['trusted_host_patterns'] = array(
  '^example\.webarch\.net$',
  '^example\.com$',
  '^www\.example\.com$',
  '^example\.org$',
  '^www\.example\.org$',
);

Piwik

If you want to use our Piwik server to generate stats from your Drupal site then the best way to do this is to install the Piwik Web Analytics Drupal Module. This give you a web interface to set various things like tracking by role etc.