COAP:COAP-3110/week6: Difference between revisions

The educational technology and digital learning wiki
Jump to navigation Jump to search
Line 64: Line 64:


(2) Create a new database
(2) Create a new database
* On free hosting platforms, you probably will only be allowed to use a single database and you cannot change its name.
* On free hosting platforms, you probably only will be allowed to use a single database and you cannot change its name.
* Usually, you cannot use phpmyadmin for that, try to figure out how to do it through the administration interface. Database names also will include a prefix (tied to your username in general)
* Usually, you cannot use Phpmyadmin for database creation, try to figure out how to do it through the administration interface. Database names also might include a prefix tied to your username.
* The database usually will not sit on "locallost", but on another server
* The database server usually will not sit on "localhost" (same machine as PHP), but on another server
* Write down:
* Write down:
** full name of the database,  
** full name of the database,  
Line 79: Line 79:
* With an FTP client move the wordpress directory
* With an FTP client move the wordpress directory


(2) On the local host (again):
(2) Create a new configuration file. On the local host (again):
* Create a backup copy of wp-config.php, e.g. wp-config.local.php
* Create a backup copy of wp-config.php, e.g. wp-config.local.php
* Create a new copy of wp-config.php, e.g. wp-config.new.php
* Create a new copy of wp-config.php, e.g. wp-config.new.php
* Edit config.new.php and configure it with the parameters for the new host.
* Edit config.new.php and configure it with the parameters for the new host.


(3) Import the w.sql database file, using PhPMyAdmin or another client
(3) Import the database
* Make sure to select the right database first (if you got a choice)
* Import the w.sql database file to the target site, using PhPMyAdmin or another client


(4) Copy the local wp-config.new.php file to the target site and rename it to wp-config.php
(4) Copy the local wp-config.new.php file to the target site and rename it to wp-config.php
Line 106: Line 108:
'''Trouble'''
'''Trouble'''


* You provide may use an old mysql version that does not support the extend utf8mb4 caracter set. Open the *.sql file in a text editor and replace <code>utf8mb4</code> by <code>utf8</code>. If that is the case, you also need to make change in wp-config.php.
* Your provider may use an old mysql version that does not support the extend utf8mb4 character set. Open the *.sql file in a text editor and replace <code>utf8mb4</code> by <code>utf8</code>. If that is the case, you also need to make change in wp-config.php.

Revision as of 11:53, 24 September 2016

Week 6 learning goals

  • Plugin installation and management (continued)
  • Migrating from a development server to a hosting company
  • A first glance at the REST protocol

Monday

Plugin installation continued.

Wednesday

Web hosting providers

Free hosting exists (see below). Prices for low cost hosting start around 3 Euros / month, but you have to add fees for a domain name to that if you want your own.

Well-known free (read the fine print)

You can search the web for alternatives, e.g. read TechRadar, but be careful. Cross-check information about a provider.

Well-known cheap, HostGator is best according to PC Mag

Recommended local (Geneva, Switzerland)

  • Infomaniak (10 CHF / month). Probably one of the best in that range (quality/speed)
  • HostPoint (10CHF/month, 30 day trial)

Domain name registration

  • Most hosting companies will provide that service
  • You many check if they are accredited with ICANN (i.e. first-level registrars)

Moving a platform from a local server to a hosting organization

  • Moving a Wordpress from a local server to an other target is fairly easy most of the time. However, many things can go wrong ...

Executive summary:

  • Create a new database and database user on the target site.
  • Move all PHP files (or install a new system)
  • Move the database files (dump SQL locally and import on the target)
  • Repair the configuration file (database name, database user, etc.)

Local preparation

In order to migrate you will have to:

  • copy all the WordPress files using an FTP or SFTP client or a WebClient (depending on the hosting company)
  • dump the whole database to a *.sql file, e.g. w.sql
  • Create a copy of the wp-config.php file and edit some settings (see below)

New host preparation

Frequently, the hosting company will not let you create random database names since a same MySQL server is shared with many many users. You will have to use a specific tool from the control panel to create databases and database users.

(1) Carefully read the FTP (File transfer) instructions.

  • You will need a hostname (not necessarily the same as your website name), a user and a password.
  • You may have to install an FTP client on your machine. We recommend WinSCP (Windows) and Cyberduck (Mac), but there are many other alternatives.
  • Most cheap hosting companies only allow for unencrypted FTP (port 21). Good FTP clients like WinSCP will suggest secure "SFTP" transfer per default. You will have to change that to "FTP"

(2) Create a new database

  • On free hosting platforms, you probably only will be allowed to use a single database and you cannot change its name.
  • Usually, you cannot use Phpmyadmin for database creation, try to figure out how to do it through the administration interface. Database names also might include a prefix tied to your username.
  • The database server usually will not sit on "localhost" (same machine as PHP), but on another server
  • Write down:
    • full name of the database,
    • database user name,
    • database user password,
    • database server name

Transfer php files, configuration file and database dump

(2) Move all the PHP files from local to new target

  • Your target directory may not be writeable. The administration interface allows to unlock
  • With an FTP client move the wordpress directory

(2) Create a new configuration file. On the local host (again):

  • Create a backup copy of wp-config.php, e.g. wp-config.local.php
  • Create a new copy of wp-config.php, e.g. wp-config.new.php
  • Edit config.new.php and configure it with the parameters for the new host.

(3) Import the database

  • Make sure to select the right database first (if you got a choice)
  • Import the w.sql database file to the target site, using PhPMyAdmin or another client

(4) Copy the local wp-config.new.php file to the target site and rename it to wp-config.php

Example taken from 000webhost.com:

as you can see the hosting organization may force you to adopt some prefix, i.e. the a3966289 would represent your user id.

define('DB_NAME', 'a3966289_w');

/** MySQL database username */
define('DB_USER', 'a3966289_user');

/** MySQL database password */
define('DB_PASSWORD', 'XXXXXXXX');

/** MySQL hostname */
define('DB_HOST', 'mysql5.000webhost.com');

Trouble

  • Your provider may use an old mysql version that does not support the extend utf8mb4 character set. Open the *.sql file in a text editor and replace utf8mb4 by utf8. If that is the case, you also need to make change in wp-config.php.