_____

Drupal: Installation

By the way: ALWAYS use binary ftp transfers.

In Ascii mode: Many .js and .css files contain very long lines, this causes transfer errors. Also, you do not want to replace newlines with carriage-return-newlines in shell scripts.

For filezilla: go to "Edit -> Settings ... -> FTP: File types" and choose 'Binary' for 'Default transfer type'. ## Using multiple ports Here is my recipe to install drupal on an ubuntu-pc. I find it convenient to have more that one website available on one system. The easiest solution I found is using different port numbers for each site, for example:

  • localhost:8081
  • localhost:8082
  • etc ...

In this example, the host name of the system where the websites are situated is "geranium". So, to access the sites on a local network from another ubuntu-pc:

  • geranium.local:8081
  • geranium.local:8082
  • etc ...

Note: Command line commands are preceded by $, for example:

$ ls -l

Note: in the text below, "geranium.local" is used as (part of) an url. When testing on the system where the installation is done, "localhost" can be used.

Note: make sure your umask is correctly set:

$ umask 022

Note: I use as editor "vim", so I use this in the instructions. Feel free to use another editor.

Note: The example-user is "theboss". Use your own login instead.

Step 1: install apache, the web server

$ sudo apt install apache2

test: a browser on the url: geranium.local, should show the Apache2 Ubuntu Default Page.

Step 2: install ftp server

$ sudo apt install ftpd

Step 3: install php, the language drupal is written in.

$ sudo apt install php libapache2-mod-php
$ sudo a2enmod php7.0  # or php5.0, if php5 is your php version

test: create the file /var/www/html/phpinfo.php with the following content:

<?php phpinfo(); ?>

and test with the url: geranium.local/phpinfo.php . This should show the settings for your php installation.

Step 4: install mysql

Mysql is the database system where drupal saves nearly everything.

$ sudo apt install mysql-client mysql-server

You will be asked to set a password for the root-mysql-user. Note: this has nothing to do with the system-root-password.

Test on geranium:

$ mysql -u root -p -h localhost

should give the mysql prompt to signify that you started a mysql session. End this session with CNTRL-D.

Step 5: install phpmyadmin

Phpmyadmin is a web-based tool to manage the mysql server.

$ sudo apt install phpmyadmin libmcrypt-dev mcrypt

Choose "apache2" as server to configure for.

Click "yes" for configuration with dbconfig-common.

You will be asked for the mysql-root password.

You will be asked to choose a password for the use of phpmyadmin.

$ sudo ln -s /etc/phpmyadmin/apache.conf \
     /etc/apache2/conf-available/phpmyadmin.conf
$ sudo a2enconf phpmyadmin
$ sudo phpenmod mcrypt
$ sudo service apache2 reload

Test: the url geranium.local/phpmydamin should show the phpmyadmin page.

Step 6: enable userdir and clean urls

This step tells apache to use ~/public_html as place for the web pages of an user. This is not really necessary in this process, but can come in handy now and then. Enabling clean urls makes life with drupal easier.

$ sudo a2enmod userdir     # to enable userdir
$ sudo a2enmod rewrite     # to enable clean urls
$ sudo service apache2 restart

$ cd /etc/apache2/mods-enabled

Edit userdir.conf

Change

AllowOverride FileInfo AuthConfig Limit Indexes

into

AllowOverride All

Save

$ sudo service apache2 reload

Test: logged in as usual, for example with user name "theboss":

$ mkdir -p ~/public_html
$ echo "hello" > $HOME/public_html/index.html

The url geranium.local/~theboss should show the word "hello".

Step 7: enable php in user directories

Edit /etc/apache2/mods-enabled/php7.0.conf (or php5.conf)

$ sudo vim /etc/apache2/mods-enabled/php7.0.conf

and follow the instructions at the end of the file. After editing, the end of the file should show something as:

<IfModule mod_userdir.c>
   <Directory /home/*/public_html>
      php_admin_flag engine Off
   <Directory>
<IfModule>

$ sudo service apache2 reload

Test: logged in as "theboss":

$ echo '<?php phpinfo(); ?>' > ~/public\_html/phpinfo.php

The url geranium.local/~theboss/phpinfo.php should show the phpinfo screen.

Step 8: enable php error messages.

If not enabled, you will encounter blank screens or misleading screens when a php5 error occurs.

$ cd /etc/php/7.0/apache2/ # or /etc/php5/apache2
$ sudo cp php.ini php.ini.orig

Edit php.ini, change

display\_errors = Off
  into
display\_errors = On

$ sudo service apache2 reload

Test: logged in as "theboss":

$ echo '<?php apekool(); ?>' > ~/public\_html/apekool.php

The url geranium.local/~theboss/apekool.php should produce an error message in your browser.

Step 9: adapt apache to serve your new drupal website

We will arrange that:

  • Your website is available as geranium.local:8081, or alternatively on the geranium system as localhost:8081

  • The website will be placed in ~theboss/public_html/ratrabbit

        $ cd /etc/apache2/sites-available
        $ sudo cp 000-default.conf ratrabbit.conf

edit ratrabbit.conf. Change

<VirtualHost *:80>
   into
<VirtualHost *:8081>

put after the line

     ServerAdmin webmaster@localhost

The following:

     ServerName geranium:8081

Change the line

     DocumentRoot /var/www/html

into the following lines:

     DocumentRoot /home/theboss/public_html/ratrabbit
     <Directory />
       Options FollowSymLinks
       AllowOverride All
     </Directory>

and save the file.

$ cd /etc/apache2

Edit ports.conf, after:

         Listen 80

add this line:

         Listen 8081

Save

$ sudo a2ensite ratrabbit  # to enable your website
$ sudo service apache2 reload   # to restart apache2

Test: logged in as theboss:

$ cd ~/public_html
$ mkdir ratrabbit
$ cd ratrabbit
$ echo '8081' > index.html

The url geranium.local:8081 should now show '8081'

Step 10: installation of drupal

In this example we use drupal-7.41, but probably there is a newer one available now. Use that version instead.

Logged in as theboss:

$ mkdir ~/drupals              # folder to store drupal-related files
$ cd drupals
$ wget http://ftp.drupal.org/files/projects/drupal-7.41.tar.gz
$ tar xf drupal-7.41.tar.gz
$ rm ~/public_html/ratrabbit/index.html
$ cd drupal-7.41
$ cp -r * .htaccess ~/public_html/ratrabbit

Test: The url geranium.local:8081 should show the configuration screen of drupal. DO NOT CONFIGURE YET.

Step 11: create an mysql user and a drupal database

  • Goto url: geranium.local/phpmyadmin

  • click tab Users -> Add user<br>

      User name: ratrabbit (or whatever you like)
      Host: select Local
      Password: choose password for user ratrabbit

  • Under database for user:<br> 

        choose 'Create database with same name and grant all privileges'
        click 'Go' (right under)

     In the left column should now show database 'ratrabbit',
     and in Users Overview should also show 'ratrabbit'.

Step 12: Configure drupal

  Goto url geranium.local:8081 and follow the instructions carefully.

Now your website should be up and running. If you want another website next to the first one, but with port 8082 in stead of 8081, invent another name for your website, for example "dracula" in stead of "ratrabbit" and follow steps 9-12, replacing "ratrabbit" with "dracula" and "8081" with "8082".

It is not necessary to install drupal in the document-root directory for geranium.local:8081. Following the example above, you could define ~/public_html/ratrabbit as document-root, and install drupal in a subdirectory, for example ~/public_html/ratrabbit/drupal-website.