Drupal

From WebarchDocs
Jump to: navigation, search

Drupal on Webarchitects Servers

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

We are able to provide a free Drupal install with any of the Webarchitects and Ecodissident shared hosting packages which have at least one MySQL database.

The only shared hosting servers we have that allow ssh and drush access are the Ecohost ones, however we do intend to setup some Webarchitects shared hosting servers with locked down ssh access to enable the use of git and drush.

Directives allowed in .htaccess files

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

# 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>

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:

<VirtualHost *:80>
  <IfModule mpm_itk_module>
    AssignUserID example example
    MaxClientsVHost 60
  </IfModule>
  ServerName example.host1.webarch.net
  ServerAlias example.org www.example.org
  ServerAdmin  example@example.org
  SetEnv TMPDIR /home/example/tmp
  Redirect /phpmyadmin https://example.host1.webarch.net/phpmyadmin
  DocumentRoot /home/example/sites/default
  <Directory /home/example/sites/default>
    Options -Indexes -SymlinksIfOwnerMatch -MultiViews -IncludesNOEXEC -ExecCGI
    DirectoryIndex index.html index.php index.htm wsh.shtml
    AddHandler cgi-script .cgi .pl
    <IfModule mod_php5.c>
      php_admin_value doc_root /home/example/sites/default
      php_admin_value open_basedir /home/example/:/tmp/
      php_admin_value upload_tmp_dir /home/example/tmp
      php_admin_value uploadprogress.file.contents_template /home/example/tmp/upload_contents_%s
      php_admin_value uploadprogress.file.filename_template /home/example/tmp/upt_%s.txt
      php_admin_value session.save_path /home/example/tmp
      php_admin_value soap.wsdl_cache_dir /home/example/tmp
      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
      <FilesMatch "\.ph(p3?|tml)$">
        SetHandler application/x-httpd-php
      </FilesMatch>
      <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source
      </FilesMatch>
      <FilesMatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$">
        Order allow,deny
      </FilesMatch>
      <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresDefault A1209600
        <FilesMatch \.php$>
          ExpiresActive Off
        </FilesMatch>
      </IfModule>
      <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteBase /
        RewriteRule "(^|/)\." - [F]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_URI} !=/favicon.ico
        RewriteRule ^ index.php [L]
        <IfModule mod_headers.c>
          RewriteCond %{HTTP:Accept-encoding} gzip
          RewriteCond %{REQUEST_FILENAME}\.gz -s
          RewriteRule ^(.*)\.css $1\.css\.gz [QSA]
          RewriteCond %{HTTP:Accept-encoding} gzip
          RewriteCond %{REQUEST_FILENAME}\.gz -s
          RewriteRule ^(.*)\.js $1\.js\.gz [QSA]
          RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1]
          RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1]
          <FilesMatch "(\.js\.gz|\.css\.gz)$">
            Header set Content-Encoding gzip
            Header append Vary Accept-Encoding
          </FilesMatch>
        </IfModule>
      </IfModule>
    </IfModule>
    AllowOverride AuthConfig Indexes FileInfo Limit
    Order allow,deny
    allow from all
  </Directory>
  ErrorDocument 404 /index.php
  CustomLog /var/log/apache2/example_access.log bandwidth
  LogLevel error
  ErrorLog  /home/example/logs/error.log
  CustomLog /home/example/logs/access.log combinedio
 </VirtualHost>

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 Aapache configuration as above then you can probably remove (or move) the default .htaccess file (or comment out the Options and IfModule sections).

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, we set it using drush:

drush vset file_temporary_path /home/example/tmp

Private Directory

The file_private_path is set to /home/example/private, this variable is set from Home » Administration » Configuration » Media using the web interface or using this command if you have drush access:

drush vset file_private_path /home/example/private

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.