0% found this document useful (0 votes)
155 views11 pages

Installation: It Might Be Useful

The document discusses enabling full UTF-8 support in MySQL, which allows storing 4-byte characters. It recommends setting the file format to Barracuda, enabling file-per-table, and using large prefixes. It provides steps to upgrade an existing Moodle database, including running a CLI script to change the collation to utf8mb4_unicode_ci and modifying config.php and MySQL settings. Verifying full support involves adding emojis to Moodle.

Uploaded by

agus utomo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
155 views11 pages

Installation: It Might Be Useful

The document discusses enabling full UTF-8 support in MySQL, which allows storing 4-byte characters. It recommends setting the file format to Barracuda, enabling file-per-table, and using large prefixes. It provides steps to upgrade an existing Moodle database, including running a CLI script to change the collation to utf8mb4_unicode_ci and modifying config.php and MySQL settings. Verifying full support involves adding emojis to Moodle.

Uploaded by

agus utomo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

The standard OPcache extension is strongly recommended; since Moodle 2.

6, it is the only
solution officially supported by PHP developers. The benefits are increased performance and
significantly lower memory usage. However, opcode caching extensions (including OPcache,
eAccelerator and APC) aren't compatible with servers configured to use some common types of
high-security PHP handlers such as suPHP (the default on WHM / cPanel Linux servers).

Installation
The OPcache extension is distributed as part of PHP 5.5.0 and later. It is available also for older
stable PHP releases from PECL under the original name ZendOPcache.
NOTE: If you are running PHP 5.3 or 5.4 you can safely ignore the Environment Check
message about OpCache. Nonetheless, it might be useful to upgrade Operating
System/PHP and get to 5.5 or newer; as there have been all sorts of problems described
on PHP 5.2 and 5.3, and upgrading PHP turned out to be the easier solution.

Configuration
PHP.ini settings:

[opcache]

opcache.enable = 1

opcache.memory_consumption = 128

opcache.max_accelerated_files = 8000

opcache.revalidate_freq = 60

; Required for Moodle

opcache.use_cwd = 1

opcache.validate_timestamps = 1

opcache.save_comments = 1

opcache.enable_file_override = 0

; If something does not work in Moodle

;opcache.revalidate_path = 1 ; May fix problems with include paths

;opcache.mmap_base = 0x20000000 ; (Windows only) fix OPcache crashes with e


vent id 487

; Experimental for Moodle 2.6 and later

;opcache.fast_shutdown = 1
;opcache.enable_cli = 1 ; Speeds up CLI cron

;opcache.load_comments = 0 ; May lower memory use, might not be compatible


with add-ons and other apps.

When using non-Windows platforms, you have to use the zend_extension configuration to load
the OPcache extension into PHP by adding to php.ini.

zend_extension=/full/path/to/opcache.so

When using IIS you will need PHP 5.5 and you will need to add the extension for opcache under
the ExtensionList section of the php.ini file. For PHP 5.3 and 5.4 you can download the binaries
separately from [1] and you will also need to enter full absolute path to the module dll in php.ini.

[ExtensionList]

...

zend_extension=php_opcache.dll

memory_consumption
From: PHP's OPCache extension review

The size of the memory segment can be told using the opcache.memory_consumption INI
setting (Megabytes). Size it big, don't hesitate to give space. Never ever run out of shared
memory space, if you do, you will lock your processes, we'll get back to that later.

Size the shared memory segment according to your needs, don't forget that a production
server dedicated to PHP processes may bundle several dozens of Gigabytes of memory, just
for PHP. Having a 1Gb shared memory segment (or more) is not uncommon, it will depend
on your needs, but if you use a modern application stack, aka framework based, with lots of
dependencies etc... , then use at least 1Gb of shared memory.

Having that in mind, set opcache.memory_consumption to a value high enough to avoid filling it
up (as long as your RAM usage allows you to), and then monitor the OPCache to adjust that
value to its optimal size.

max_accelerated_files
From: php.net max-accelerated-files

The maximum number of keys (and therefore scripts) in the OPcache hash table. The actual
value used will be the first number in the set of prime numbers { 223, 463, 983, 1979, 3907,
7963, 16229, 32531, 65407, 130987 } that is bigger than the configured value. Only numbers
between 200 and 100000 are allowed.
As Moodle 3.3 contains over 9000 php files it is recommended above that
opcache.max_accelerated_files should be set to 8000 to accommodate this (16229 will actually
be used as per the explanation above). If you have several instances of Moodle you should
multiply that value by the number of instances.
If many additional plugins are installed so that your total PHP files exceed 16229 then the next
most suitable value for max_accelerated_files should be used.

MySQL full unicode support


1 UTF-8

o 1.1 File format


o 1.2 File per table

o 1.3 Large prefix


2 Steps to upgrade

UTF-8
UTF-8 is a character encoding that most websites use. It encodes each of the 1,112,064 valid
code points. To store all of this information, four bytes is required. The most popular values are in
the three byte region. MySQL by default only uses a three byte encoding and so values in the
four byte range (eg. Asian characters and Emojis) can not be stored. Any attempt to enter a text
that contains four byte characters will result in a Moodle database error.
MySQL does provide full four byte UTF-8 support, but it requires certain database settings to be
configured. From version 3.3 on Moodle uses full UTF-8 for both MySQL and MariaDB by
default. Existing databases will still run with partial support, but it is recommended to move over
to full support.
Moodle comes with a Command Line Interface (CLI) script for converting to full UTF-8 for MySQL
(and MariaDB). Before Moodle versions 3.1.5 and 3.2.2 this conversion tool would only change
the Collation to some variant of 'utf8_bin'. 'utf8_unicode_ci' was the recommended Collation. We
now recommend using 'utf8mb4_unicode_ci' which supports four byte characters
(utf8_unicode_ci only supports three).
This script will attempt to change the database Collation, Character set, default table settings and
column definitions.
To summarise:

Fresh installs of Moodle 3.1.5 and 3.2.2 onwards will use utf8mb4 by default, if the database
server is configured appropriately (see below).
Sites upgrading to Moodle 3.1.5 or 3.2.2 can use the script to update to utf8mb4. In Moodle
3.3 a warning will show that the database isn't using full UTF-8 support and suggest moving
to 'utf8mb4_unicode_ci', but you may choose to keep using 'utf8_*'.
File format
To allow for large indexes on columns that are a varchar, a combination of settings needs to be
set. The file format for the system needs to be using "Barracuda". This allows for the row format
to be set to "Compressed" or "Dynamic". To enable this setting see the upgrade steps listed
below.

File per table


To enable this setting see the upgrade steps listed below.

Large prefix
This in conjunction with the row format being either "Compressed" or "Dynamic" allows for large
varchar indexes above 191 characters. To enable this setting see the upgrade steps listed below.

Steps to upgrade
Most important: Please backup your database before making any changes or running the CLI
script.

Change configuration settings for MySQL (exactly the same for MariaDB). This step is
optional. You can run the script and it will try and make these changes itself. If errors occur
then try manually changing these settings as listed below.
o On Linux based systems you will want to alter my.cnf. This may be located in
'/etc/mysql/'.
o Make the following alterations to my.cnf:

[client]

default-character-set = utf8mb4

[mysqld]

innodb_file_format = Barracuda

innodb_file_per_table = 1

innodb_large_prefix

character-set-server = utf8mb4

collation-server = utf8mb4_unicode_ci

skip-character-set-client-handshake
[mysql]

default-character-set = utf8mb4

Restart your MySQL server.


Run the CLI script to convert to the new Character set and Collation (requires Moodle 3.1.5,
3.2.2 or newer):

$ php admin/cli/mysql_collation.php --collation=utf8mb4_unicode_ci

NOTE: For large sites, this script will be slow. It is recommended to dump and reimport
your data according
to https://docs.moodle.org/33/en/Converting_your_MySQL_database_to_UTF8#Default_M
ysql_character_set

Adjust the $CFG->dboptions Array in your config.php to make sure that Moodle uses the
right Collation when connecting to the MySQL Server:

$CFG->dboptions = array(

'dbcollation' => 'utf8mb4_unicode_ci',

);

If you only have access to the database command line (or something like phpmyadmin) you can
try the following sql commands:

SET GLOBAL innodb_file_format = barracuda

SET GLOBAL innodb_file_per_table = 1

SET GLOBAL innodb_large_prefix = 'on'

Try adding some Emojis (e.g. ) to your Moodle site to verify that the upgrade was
MySQL full unicode support
(Redirected from admin/environment/custom check/mysql full unicode support)

Main page Managing a Moodle site Server settings Environment MySQL full unicode support

SERVER SETTINGS

System paths
Session handling
HTTP
Maintenance mode
Cleanup
Environment
Site registration

CONTENTS
[hide]

1 UTF-8

o 1.1 File format

o 1.2 File per table

o 1.3 Large prefix


2 Steps to upgrade

UTF-8
UTF-8 is a character encoding that most websites use. It encodes each of the 1,112,064 valid
code points. To store all of this information, four bytes is required. The most popular values are in
the three byte region. MySQL by default only uses a three byte encoding and so values in the
four byte range (eg. Asian characters and Emojis) can not be stored. Any attempt to enter a text
that contains four byte characters will result in a Moodle database error.
MySQL does provide full four byte UTF-8 support, but it requires certain database settings to be
configured. From version 3.3 on Moodle uses full UTF-8 for both MySQL and MariaDB by
default. Existing databases will still run with partial support, but it is recommended to move over
to full support.
Moodle comes with a Command Line Interface (CLI) script for converting to full UTF-8 for MySQL
(and MariaDB). Before Moodle versions 3.1.5 and 3.2.2 this conversion tool would only change
the Collation to some variant of 'utf8_bin'. 'utf8_unicode_ci' was the recommended Collation. We
now recommend using 'utf8mb4_unicode_ci' which supports four byte characters
(utf8_unicode_ci only supports three).
This script will attempt to change the database Collation, Character set, default table settings and
column definitions.
To summarise:
Fresh installs of Moodle 3.1.5 and 3.2.2 onwards will use utf8mb4 by default, if the database
server is configured appropriately (see below).
Sites upgrading to Moodle 3.1.5 or 3.2.2 can use the script to update to utf8mb4. In Moodle
3.3 a warning will show that the database isn't using full UTF-8 support and suggest moving
to 'utf8mb4_unicode_ci', but you may choose to keep using 'utf8_*'.

File format
To allow for large indexes on columns that are a varchar, a combination of settings needs to be
set. The file format for the system needs to be using "Barracuda". This allows for the row format
to be set to "Compressed" or "Dynamic". To enable this setting see the upgrade steps listed
below.

File per table


To enable this setting see the upgrade steps listed below.

Large prefix
This in conjunction with the row format being either "Compressed" or "Dynamic" allows for large
varchar indexes above 191 characters. To enable this setting see the upgrade steps listed below.

Steps to upgrade
Most important: Please backup your database before making any changes or running the CLI
script.

Change configuration settings for MySQL (exactly the same for MariaDB). This step is
optional. You can run the script and it will try and make these changes itself. If errors occur
then try manually changing these settings as listed below.
o On Linux based systems you will want to alter my.cnf. This may be located in
'/etc/mysql/'.
o Make the following alterations to my.cnf:

[client]

default-character-set = utf8mb4

[mysqld]

innodb_file_format = Barracuda

innodb_file_per_table = 1
innodb_large_prefix

character-set-server = utf8mb4

collation-server = utf8mb4_unicode_ci

skip-character-set-client-handshake

[mysql]

default-character-set = utf8mb4

Restart your MySQL server.


Run the CLI script to convert to the new Character set and Collation (requires Moodle 3.1.5,
3.2.2 or newer):

$ php admin/cli/mysql_collation.php --collation=utf8mb4_unicode_ci

NOTE: For large sites, this script will be slow. It is recommended to dump and reimport
your data according
to https://docs.moodle.org/33/en/Converting_your_MySQL_database_to_UTF8#Default_M
ysql_character_set

Adjust the $CFG->dboptions Array in your config.php to make sure that Moodle uses the
right Collation when connecting to the MySQL Server:

$CFG->dboptions = array(

'dbcollation' => 'utf8mb4_unicode_ci',

);

If you only have access to the database command line (or something like phpmyadmin) you can
try the following sql commands:

SET GLOBAL innodb_file_format = barracuda

SET GLOBAL innodb_file_per_table = 1


SET GLOBAL innodb_large_prefix = 'on'

Try adding some Emojis (e.g. ) to your Moodle site to verify that the upgrade was
successful.

Transitioning to HTTPS
(Redirected from admin/environment/custom check/site not https)

Main page Managing a Moodle site Security Transitioning to HTTPS

SECURITY

Security recommendations
Security overview report
Site policies
Site notifications
Password salting
Increasing privacy
Reducing spam
Security FAQ

There are numerous benefits to running your moodle site using HTTPS. This increases the level
of security especially involving sessions and passwords.

CONTENTS
[hide]

1 Steps

o 1.1 Before you start

o 1.2 Setting up an SSL certificate

o 1.3 Setting up your server

o 1.4 Setting up your Moodle

o 1.5 Redirecting the HTTP address to the new HTTPS address

o 1.6 Updating content

o 1.7 Login HTTPS


2 See also

Steps
Before you start
Check all the content you use supports https. You will not be able to embed HTTP content over
HTTPS. If some content is only available over HTTP, you can convert it from a direct embedding
to a link.
To help you do this, the HTTPS replace tool is available on github.
Make sure you have a staging environment. You will want to set up HTTPS the first time on a
staging environment rather than updating your live site. It will take some time to convert to https
and you will need to update content (see below).

Setting up an SSL certificate


The first thing you will need to do is acquire an SSL certificate. You can create these yourself,
but this is only helpful for development purposes. Instead you will want to get your SSL certificate
from a certificate authority, so that the certificate will be publicly verified.
The cost of certificates has been somewhat prohibitive, they come at various costs from a few
dollars to hundreds of dollars per year. For the budget constrained, the "price is right" with a new
initiative brought to us by the Internet Security Research Group (ISRG). Free domain-validated
certificates can be acquired from Let's Encrypt. Let's Encrypt also tries to make the process of
installing and managing certificates as painless as possible and there are numerous methods
and clients available.

Setting up your server


Then you will need enable SSL on your web server to add your certificate. This process will vary
depending on your web server of choice.
If you are using a proxy or load balancer, depending on your setup you will most likely want to
set up the SSL certificate on your proxy server

Setting up your Moodle


On a basic Moodle site, it will be simple to set up https. Simply edit config.php and change http://
to https:// in $CFG->wwwroot.
However if you are using a proxy or load balancer, depending on your setup you may need to set
$CFG->sslproxy to 1, and not use SSL on the Moodle server. Then the load balancer or proxy
server can communicate directly to your Moodle site, but serve to the clients over SSL.

Redirecting the HTTP address to the new HTTPS address


You may want to add a redirection so that users who have the current http:// address to your site
will be redirected automatically to the https:// address instead of getting a page with a message
such as "For security reasons only https connections are allowed, sorry."
There are several ways to do redirections, depending on your web server, hosting, and how you
prefer to do this. A common solution on Apache web servers is to create an .htaccess file with a
rewrite rule such as:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80

RewriteRule ^(.*)$ https://www.yourmoodle.com/$1 [R,L]

or in general

RewriteEngine On

RewriteCond %{SERVER_PORT} 80

RewriteRule ^(.*)$ {SERVER_NAME}/$1 [R,L]

Be sure to look up current ways to do this for your web server and host, such as the how-to
article Force HTTPS connections in an Apache server environment.

Updating content
You will need to change all embeded content from being requested over http. Links do not
matter. But you will need to update images and iframes, scorm modules, and LTI external tools.
You can modify external tools to open in a new window instead of in an iframe and they will work
fine.
There is plans to work on a new tool to aid in this process. See MDL-46269 for details.

Login HTTPS
If you were previously using the Login HTTPS setting you will need to make sure it's turned off.

You might also like