Note: You are currently viewing documentation for Moodle 4.0. Up-to-date documentation for the latest stable version of Moodle may be available here: RedHat Linux installation.

RedHat Linux installation: Difference between revisions

From MoodleDocs
No edit summary
Line 1: Line 1:
Note : These instructions apply to RedHat version 8. They have also been found to work for RedHat 9.0 and for Fedora Core 1 and 2. '''Fedora Core 3 requires the php-gd package in addition to php.''' I see no reason why they should not work for later versions. In addition, later distributions of Fedora (after 7) contain a moodle yum package. Installation is as easy as '''yum install moodle'''.
{{Note|This document is about installing Moodle 3.7 in an RedHat Enterprise Linux (RHEL) 8}}


Redhat installation considerations: There are many installation options available when installing Redhat. I assume that you are installing on a server and will have selected a Server type install. There is however no reason why this should not work on a desktop or Workstation installation.
== Server Installation ==
 
== Make sure you have installed the following packages ==
(You will need to select the option to customize the default set of packages on installation OR bring up the package manager by putting disk 1 back in the drive for an existing system):
 
* X Windows System (not vital but easier)
* Gnome or KDE desktop environment (as above)
* Server Configuration Tools
* Web Server
* Web Server
** Click "Details" and make sure all PHP modules are ticked (except ODBC and PGSQL, they're not neccesary)
** RHEL8 comes with PHP7.2[https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/8.0_release_notes/index#web-servers-databases-dynamic-languages] and Moodle 3.7 needs PHP7.1.
** make sure not to miss the MYSQL-PHP module (not installed by default)
** Also the default version of Apache web server 'httpd' from RHEL7 won't work with the PHP7 from extra repo. We will install 'httpd24' to replace it, but there is no harm to install 'httpd' here first.
* SQL Database
** Or use the PHP7 packages from "remi-safe" repository, it works with the default "httpd" package.
** Click "Details" and tick MySQL server box
* Database
* Also make sure you set up the firewall. You probably only need to enable HTTP (and perhaps FTP and SSH) access to your server machine, unless you know different.
** Install MariaDB (MySQL is replaced by MariaDB since RHEL7.3).
* Also BEWARE OF the 'Server with a GUI' option, it may not work as expected.


If you want a minimal system, startging with RHEL6 (and clones) there is the possiblity of installing a minimal system.
Note: Set up the firewall if necessary. You probably only need to enable HTTP/HTTPS (and perhaps FTP and SSH) access to your server machine, unless you know the difference.


== Configure hostname and domain name==
== Configure hostname and domain name==
Line 22: Line 16:
Type system-config-network to open the GUI editor.  Click on the DNS tab. In the "DNS Search Path" fill in your domain name for example myuniversity.edu. Now ensure the "Hostname" contains the computer name you will use and click activate to make changes
Type system-config-network to open the GUI editor.  Click on the DNS tab. In the "DNS Search Path" fill in your domain name for example myuniversity.edu. Now ensure the "Hostname" contains the computer name you will use and click activate to make changes


== A word about SELinux ==
== Adding extra repo ==
Default RedHat Enterprise Linux comes with SELinux set to enforcing. If you are not used to SELinux and setting permissions it's (maybe less secure but) often easier to lower the SELinux level to permissive, see the CentOS [https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security-Enhanced_Linux/sect-Security-Enhanced_Linux-Working_with_SELinux-Changing_SELinux_Modes.html]
To install the httpd24 and PHP7 we need, add extra repo:
<pre>
subscription-manager repos --enable rhel-server-rhscl-7-rpms
</pre>
 
or the "remi-safe" repo, or any other repo you want.
 
== System Registration ==
* To receive package updates, create a user account at redhat.com, and then login and register as developer at https://developers.redhat.com/
* Subscribe the system by:
<pre>
subscription-manager register --auto-attach
</pre>
Enter the username, password as requested.
* Update the system and then reboot
<pre>
yum update
reboot
</pre>
See [https://developers.redhat.com/rhel8/install-rhel8-vbox/]
 
== SELinux ==
Default RedHat Enterprise Linux comes with SELinux set to 'enforcing'. But this may cause user problem accessing web content placed at directory other than the default directory (/var/www/html) or other access problem. If you are not used to SELinux and setting permissions, it's (maybe less secure but) often easier to lower the SELinux level to 'permissive' or even 'disabled'.
 
<pre>
# vi /etc/sysconfig/selinux
 
SELINUX=disabled
</pre>
 
See the CentOS [https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security-Enhanced_Linux/sect-Security-Enhanced_Linux-Working_with_SELinux-Changing_SELinux_Modes.html]
 
== Firewall ==
The internal firewall (RHEL 7 uses 'firewalld' instead of 'iptables' by default) is on by default. It will block the access to the web server. You may stop it first to test connection:
 
<pre>
service firewalld stop
</pre>


== A word about the PHP packages in RHEL ==
and then either disable it:
RedHat EL - or 'the upstream vendor' if you are using a clone - will not introduce newer PHP packages unless there is an exception (php53 in EL5.6+). Moodle has quite a some PHP dependencies which cannot be fullfilled solely by installing all RHEL-provided packages.
 
<pre>
chkconfig firewalld off
</pre>
 
or enable permanent HTTP access to it, you may want to enable HTTPS as well:
<pre>
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
</pre>
 
Check the allow status:
<pre>
firewall-cmd --zone=public --list-services
</pre>
 
To use iptables instead of firewalld, see [https://access.redhat.com/solutions/1264743]
 
== MariaDB / MySQL ==
 
* Make sure at least 'mariadb' and 'mariadb-server' packages are installed.
** (use "mysql" and "mysql-server" for MySQL)
<pre>
yum install mariadb mariadb-server
</pre>
*Then get the daemon running, it is not running by default. And set it to auto-start. See also [https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/selinux_users_and_administrators_guide/chap-managing_confined_services-mariadb]
** (use "mysqld" for MySQL)
<pre>
service mariadb start; chkconfig mariadb on
</pre>
*Edit /etc/my.cnf (May be different for MySQL)
 
<pre>vi /etc/my.cnf</pre>
 
Scroll down to the [mysqld] section and under Basic Settings add the following line under the last statement.
 
<pre>innodb_file_format = Barracuda</pre><br />
<pre>innodb_file_per_table = 1</pre><br />
<pre>innodb_large_prefix</pre>


You have therefore to make a choice:
* If you haven't yet, as root, change the MySQL root password
* Use RH and pay attention your Moodle version supports it + PHP modules from and maintain them on your own
** mysqladmin -u root password mysqlpass (<-- should change this to something of your own)
* Install the whole (latest) PHP from source on your own (and maintain it)
** Or run 'mysql_secure_installation' to set password for root and secure the system
* Install PHP packages from a third party repo (but you won't get support from Redhat if you run into problems):
* Next, set up the MySQL database (see http://moodle.org/doc/?file=install.html#Database for more details)
** [rpms.famillecollet.com] Maintains recent MySQL and PHP packages for supported EL version (a EPEL contributor)
* Launch MySQL as root
** RPMFusion and others also have newer PHP packages
** mysql -u root -p
*** (at the password prompt, enter the password from above)
* At the '>' MySQL prompt, enter the following commands (MySQL commands are ended with a ';')
** CREATE DATABASE mymoodle CHARSET 'utf8mb4';
*** ('mymoodle' is the name of the database you would like to use, it will be entered to the Moodle 'config.php' later)
** GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON mymoodle.* TO moodleuser@localhost IDENTIFIED BY 'moodlepass';
*** (as above, 'mymoodle', 'moodleuser' and 'moodlepass' will be entered to the Moodle 'config.php' later)
** flush privileges;
** quit
* (! Consider MySQL security - not covered here. If you run a firewall, you don't have too much to worry about.)


== Download Moodle==
== Moodle ==
(I will install under /usr/moodle, data in /usr/moodle_data)
(I will install under /usr/moodle, data in /usr/moodle_data)


=== Download ===
* Download your favourite version of Moodle from moodle.org (.zip archive is easiest)
* Download your favourite version of Moodle from moodle.org (.zip archive is easiest)
* as Root create folder under /usr and copy zip
* as Root create folder under /usr and copy zip
Line 52: Line 131:
** cvs -z3 -d:pserver:anonymous@uk.cvs.moodle.org:/cvsroot/moodle co moodle
** cvs -z3 -d:pserver:anonymous@uk.cvs.moodle.org:/cvsroot/moodle co moodle


== Unpack and set file permission etc ==
=== Unpack and set file permission etc ===


* Still as root we unpack moodle and rename to something appropiate (I have multiple moodle installs, hence this setup). I will call this install mymoodle.
* Still as root we unpack moodle and rename to something appropiate (I have multiple moodle installs, hence this setup). I will call this install mymoodle.
Line 65: Line 144:
** chown -R apache:apache /usr/moodle_data
** chown -R apache:apache /usr/moodle_data


== Setup config.php ==
=== Setup config.php ===


* Still as root copy and edit the config file, you should know the host/domain name for your server
* Still as root copy and edit the config file, you should know the host/domain name for your server
Line 72: Line 151:
** vi config.php (or whatever your favourite editor is!)
** vi config.php (or whatever your favourite editor is!)
* Your config.php settings should be something like...
* Your config.php settings should be something like...
** dbtype = "mysqli"
** dbtype = "mariadb" (use "mysqli" for MySQL)
** dbhost = "localhost"
** dbhost = "localhost"
** dbname = "mymoodle"
** dbname = "mymoodle"
Line 85: Line 164:
* Save your changes and exit from the editor
* Save your changes and exit from the editor


== Setup MySQL ==
== Apache ==
 
* Open a web browser and make sure you can connect to the installed web server and default port (80) of the server. If not OK, it may be blocked by the firewall (see below). Correct the problem.
* First you need to get the MySQL daemon running, it is not running by default.
* The default version (httpd) doesn't work with the PHP7 needed, so we install httpd24 (from extra repo) to replace it:
** On the Desktop find and launch "Services" (on KDE and Gnome it's under System Settings=>Server Settings=>Services, but you might have to hunt around).
<pre>
** Tick the box for MySQL and (with it selected) press the Start icon - ensure it starts up
yum install httpd24-httpd
** Choose "Save Changes" from the menu, and exit the program.
</pre>
* If you haven't yet, as root, change the MySQL root password
or everything<pre>
** mysqladmin -u root password mysqlpass (<-- should change this to something of your own)
yum install httpd24-*
* Next, set up the MySQL database (see http://moodle.org/doc/?file=install.html#Database for more details)
</pre>
* Launch MySQL as root
* Stop the existing version, prevent it from starting after reboot:
** mysql -u root -p
<pre>
*** (at the password prompt, enter the password from above)
service httpd stop; chkconfig httpd off
* At the '>' MySQL prompt, enter the following commands (MySQL commands are ended with a ';')
</pre>
** CREATE DATABASE mymoodle CHARSET 'utf8mb4';
* Start the new version, and make it auto-start after reboot:
*** (the name 'mymoodle' is the same name as the database from Step 4)
<pre>
** GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER ON mymoodle.* TO moodleuser@localhost IDENTIFIED BY 'moodlepass';
service httpd24-httpd start; chkconfig httpd24-httpd on
*** (as above, 'mymoodle', 'moodleuser' and 'moodlepass' are from Step 4)
</pre>
** flush privileges;
* Edit the Apache configuration file <pre>/opt/rh/httpd24/root/etc/httpd/conf/httpd.conf</pre> (For the default version, it's <pre>/etc/httpd/conf/httpd.conf</pre>)
** quit
* Right at the end of the file add the following lines:
* (! Consider MySQL security - not covered here. If you run a firewall, you don't have too much to worry about.)
** <Directory "/usr/moodle/mymoodle"> (the directory used during Moodle installation)
 
== Setup Apache ==
 
* Edit the Apache configuration file at /etc/httpd/conf/httpd.conf
* Right at the end of the file add the following lines: (once again 'mymoodle' as from Step 3)
** <Directory "/usr/moodle/mymoodle">
** DirectoryIndex index.php
** DirectoryIndex index.php
** AcceptPathInfo on
** AcceptPathInfo on
Line 122: Line 195:
* You might also want to run through the rest of the config file and make some other (obvious) changes - administrator email and suchlike. Not vital though.
* You might also want to run through the rest of the config file and make some other (obvious) changes - administrator email and suchlike. Not vital though.
* Run the Services application (same as for Mysql) - tick and start "httpd", then save changes and exit.
* Run the Services application (same as for Mysql) - tick and start "httpd", then save changes and exit.
== PHP ==
* By using the extra repo, install the version of PHP you need (7.0 in this case). See [https://access.redhat.com/solutions/2662201]
<pre>
yum install rh-php70 rh-php70-php rh-php70-php-xml rh-php70-php-xmlrpc rh-php70-php-mysqlnd rh-php70-php-zip rh-php70-php-gd rh-php70-php-intl rh-php70-php-mbstring rh-php70-php-soap rh-php70-php-opcache
</pre>
For remi-safe repo, use:
<pre>
yum install php70 php70-php php70-php-xml php70-php-xmlrpc php70-php-mysqlnd php70-php-zip php70-php-gd php70-php-intl php70-php-mbstring php70-php-soap php70-php-opcache
</pre>
*Check the installed PHP version:
**As the PHP7 was installed to a non-default location, update the PATH variable by editing /etc/bashrc and then run the source command (See [https://medium.com/tensult/install-moodle-in-rhel7-with-php7-and-http24-25695e213bb4]):
<pre>
# vi /etc/bashrc
  export PATH=$PATH:/opt/rh/rh-php70/root/bin:/opt/rh/rh-php70/root/sbin
# source /etc/bashrc
# php -v
</pre>
Or create a link to the php file:
<pre>
# ln -s /opt/rh/rh-php70/root/bin/php /bin/php
# php -v
</pre>
*Create a "phpinfo.php" file within the "/var/www/html" directory with the following content:
<pre>
<?php
phpinfo();
?>
</pre>
And then open web browser and browse to "http://webserver/phpinfo.php" to make sure PHP is working with the web server. Then remove the file.
RedHat EL - or 'the upstream vendor' if you are using a clone - will not introduce newer PHP packages unless there is an exception (php53 in EL5.6+). Moodle has quite a some PHP dependencies which cannot be fullfilled solely by installing all RHEL-provided packages.
You have therefore to make a choice:
* Use RH and pay attention your Moodle version supports it + PHP modules from and maintain them on your own
* Install the whole (latest) PHP from source on your own (and maintain it)
* Install PHP packages from a third party repo (but you won't get support from Redhat if you run into problems):
** [rpms.famillecollet.com] Maintains recent MySQL and PHP packages for supported EL version (a EPEL contributor)
** RPMFusion and others also have newer PHP packages


== Set up the cron job ==
== Set up the cron job ==


As root user edit the /etc/crontab file using vi (or another editor) OR you can add a line to the root user's "personal" crontab (don't do both!).
As root user edit the /etc/crontab file using vi (or another editor) OR you can add a line to the root user's "personal" crontab (don't do both!).
===CLI version===
{{Note| According to Moodle's documentation, users should use the CLI version if possible, as the web version may be removed in future.[https://docs.moodle.org/36/en/Cron#Working_out_the_Moodle_cron_command]}}
* If you wish to place an entry in your root user's crontab use:
** <pre>crontab -e</pre>
** Add the following line:
<pre> */5 * * * * /usr/bin/php /path/to/mymoodle/admin/cli/cron.php</pre>
to run the command every 5 minutes.


===Web version===
{{Note| Web version is kept here for reference only. Use the CLI version if possible.}}
* If you wish to place an entry in your root user's crontab use:
* If you wish to place an entry in your root user's crontab use:
** crontab -e
** crontab -e
Line 153: Line 277:
[[pl:Instalacja_w_RedHat]]
[[pl:Instalacja_w_RedHat]]


== Reference ==
== Setting Apache Document Root ==
Please also see these discussion for GD:
If you want the web site to be served as http://www.whatever.com/ instead of http://www.whatever.com/mymoodle, edit <pre>/etc/httpd/conf/httpd.conf</pre>
 
Change From: DocumentRoot /var/www/html
 
Change To: DocumentRoot /var/www/html/mymoodle
 
Remember to modify the Moodle 'config.php' file and cron job accordingly.
 
==See also==
*[[Unix or Linux Installation]]
*[[Installing Moodle]]

Revision as of 08:34, 15 August 2019

Note: This document is about installing Moodle 3.7 in an RedHat Enterprise Linux (RHEL) 8


Server Installation

  • Web Server
    • RHEL8 comes with PHP7.2[1] and Moodle 3.7 needs PHP7.1.
    • Also the default version of Apache web server 'httpd' from RHEL7 won't work with the PHP7 from extra repo. We will install 'httpd24' to replace it, but there is no harm to install 'httpd' here first.
    • Or use the PHP7 packages from "remi-safe" repository, it works with the default "httpd" package.
  • Database
    • Install MariaDB (MySQL is replaced by MariaDB since RHEL7.3).
  • Also BEWARE OF the 'Server with a GUI' option, it may not work as expected.

Note: Set up the firewall if necessary. You probably only need to enable HTTP/HTTPS (and perhaps FTP and SSH) access to your server machine, unless you know the difference.

Configure hostname and domain name

Type system-config-network to open the GUI editor. Click on the DNS tab. In the "DNS Search Path" fill in your domain name for example myuniversity.edu. Now ensure the "Hostname" contains the computer name you will use and click activate to make changes

Adding extra repo

To install the httpd24 and PHP7 we need, add extra repo:

subscription-manager repos --enable rhel-server-rhscl-7-rpms

or the "remi-safe" repo, or any other repo you want.

System Registration

  • To receive package updates, create a user account at redhat.com, and then login and register as developer at https://developers.redhat.com/
  • Subscribe the system by:
subscription-manager register --auto-attach

Enter the username, password as requested.

  • Update the system and then reboot
yum update
reboot

See [2]

SELinux

Default RedHat Enterprise Linux comes with SELinux set to 'enforcing'. But this may cause user problem accessing web content placed at directory other than the default directory (/var/www/html) or other access problem. If you are not used to SELinux and setting permissions, it's (maybe less secure but) often easier to lower the SELinux level to 'permissive' or even 'disabled'.

# vi /etc/sysconfig/selinux

SELINUX=disabled

See the CentOS [3]

Firewall

The internal firewall (RHEL 7 uses 'firewalld' instead of 'iptables' by default) is on by default. It will block the access to the web server. You may stop it first to test connection:

service firewalld stop

and then either disable it:

chkconfig firewalld off

or enable permanent HTTP access to it, you may want to enable HTTPS as well:

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https

Check the allow status:

firewall-cmd --zone=public --list-services

To use iptables instead of firewalld, see [4]

MariaDB / MySQL

  • Make sure at least 'mariadb' and 'mariadb-server' packages are installed.
    • (use "mysql" and "mysql-server" for MySQL)
yum install mariadb mariadb-server
  • Then get the daemon running, it is not running by default. And set it to auto-start. See also [5]
    • (use "mysqld" for MySQL)
service mariadb start; chkconfig mariadb on
  • Edit /etc/my.cnf (May be different for MySQL)
vi /etc/my.cnf

Scroll down to the [mysqld] section and under Basic Settings add the following line under the last statement.

innodb_file_format = Barracuda


innodb_file_per_table = 1


innodb_large_prefix
  • If you haven't yet, as root, change the MySQL root password
    • mysqladmin -u root password mysqlpass (<-- should change this to something of your own)
    • Or run 'mysql_secure_installation' to set password for root and secure the system
  • Next, set up the MySQL database (see http://moodle.org/doc/?file=install.html#Database for more details)
  • Launch MySQL as root
    • mysql -u root -p
      • (at the password prompt, enter the password from above)
  • At the '>' MySQL prompt, enter the following commands (MySQL commands are ended with a ';')
    • CREATE DATABASE mymoodle CHARSET 'utf8mb4';
      • ('mymoodle' is the name of the database you would like to use, it will be entered to the Moodle 'config.php' later)
    • GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON mymoodle.* TO moodleuser@localhost IDENTIFIED BY 'moodlepass';
      • (as above, 'mymoodle', 'moodleuser' and 'moodlepass' will be entered to the Moodle 'config.php' later)
    • flush privileges;
    • quit
  • (! Consider MySQL security - not covered here. If you run a firewall, you don't have too much to worry about.)

Moodle

(I will install under /usr/moodle, data in /usr/moodle_data)

Download

  • Download your favourite version of Moodle from moodle.org (.zip archive is easiest)
  • as Root create folder under /usr and copy zip
    • su
    • mkdir /usr/moodle
    • mkdir /usr/moodle_data
    • cp moodle_111.zip /usr/moodle
  • If you prefer you can install the GIT version directly for all the latest features. Instead of downloading and copying the zip file. See Git_for_Administrators for details.
  • Or if you prefer you can install the CVS version directly for all the latest features. Instead of downloading and copying the zip file.
    • cd /usr/moodle
    • cvs -d:pserver:anonymous@uk.cvs.moodle.org:/cvsroot/moodle login
    • cvs -z3 -d:pserver:anonymous@uk.cvs.moodle.org:/cvsroot/moodle co moodle

Unpack and set file permission etc

  • Still as root we unpack moodle and rename to something appropiate (I have multiple moodle installs, hence this setup). I will call this install mymoodle.
    • cd /usr/moodle
    • unzip moodle_xxx.zip
    • mv moodle mymoodle
      • (optional step - I have more than one install under /usr/moodle)
    • mkdir /usr/moodle_data/mymoodle
      • (same name as the moodle install above)
    • chown -R apache:apache /usr/moodle
      • (! Giving Apache full rights to your Moodle programs is not secure. Check out the forums for recomendations on how to secure a production environment.)
    • chown -R apache:apache /usr/moodle_data

Setup config.php

  • Still as root copy and edit the config file, you should know the host/domain name for your server
    • cd /usr/moodle/mymoodle
    • cp config-dist.php config.php
    • vi config.php (or whatever your favourite editor is!)
  • Your config.php settings should be something like...
    • dbtype = "mariadb" (use "mysqli" for MySQL)
    • dbhost = "localhost"
    • dbname = "mymoodle"
    • dbuser = "moodleuser"
    • dbpass = "moodlepass" (<-- better make this something of your own)
    • prefix = ""
      • (keep the default 'mdl_' prefix if you plan on sharing the database with other applications)
    • wwwroot = "http://myhost.mydomain/mymoodle"
      • (If you only want to try moodle out and will not be accessing it from other machines you can use "http://localhost/mymoodle")
    • dirroot = '/usr/moodle/mymoodle'
    • dataroot = '/usr/moodle_data/mymoodle'
  • Save your changes and exit from the editor

Apache

  • Open a web browser and make sure you can connect to the installed web server and default port (80) of the server. If not OK, it may be blocked by the firewall (see below). Correct the problem.
  • The default version (httpd) doesn't work with the PHP7 needed, so we install httpd24 (from extra repo) to replace it:
yum install httpd24-httpd

or everything

yum install httpd24-*
  • Stop the existing version, prevent it from starting after reboot:
service httpd stop; chkconfig httpd off
  • Start the new version, and make it auto-start after reboot:
service httpd24-httpd start; chkconfig httpd24-httpd on
  • Edit the Apache configuration file
    /opt/rh/httpd24/root/etc/httpd/conf/httpd.conf
    (For the default version, it's
    /etc/httpd/conf/httpd.conf
    )
  • Right at the end of the file add the following lines:
    • <Directory "/usr/moodle/mymoodle"> (the directory used during Moodle installation)
    • DirectoryIndex index.php
    • AcceptPathInfo on
    • AllowOverride None
    • Options None
    • Order allow,deny
    • Allow from all
    • </Directory>
    • Alias /mymoodle "/usr/moodle/mymoodle"
  • Don't insert a space in "allow,deny" (common mistake!)
  • You might also want to run through the rest of the config file and make some other (obvious) changes - administrator email and suchlike. Not vital though.
  • Run the Services application (same as for Mysql) - tick and start "httpd", then save changes and exit.

PHP

  • By using the extra repo, install the version of PHP you need (7.0 in this case). See [6]
yum install rh-php70 rh-php70-php rh-php70-php-xml rh-php70-php-xmlrpc rh-php70-php-mysqlnd rh-php70-php-zip rh-php70-php-gd rh-php70-php-intl rh-php70-php-mbstring rh-php70-php-soap rh-php70-php-opcache

For remi-safe repo, use:

yum install php70 php70-php php70-php-xml php70-php-xmlrpc php70-php-mysqlnd php70-php-zip php70-php-gd php70-php-intl php70-php-mbstring php70-php-soap php70-php-opcache
  • Check the installed PHP version:
    • As the PHP7 was installed to a non-default location, update the PATH variable by editing /etc/bashrc and then run the source command (See [7]):
# vi /etc/bashrc
  export PATH=$PATH:/opt/rh/rh-php70/root/bin:/opt/rh/rh-php70/root/sbin
# source /etc/bashrc
# php -v

Or create a link to the php file:

# ln -s /opt/rh/rh-php70/root/bin/php /bin/php
# php -v
  • Create a "phpinfo.php" file within the "/var/www/html" directory with the following content:
<?php
phpinfo();
?>

And then open web browser and browse to "http://webserver/phpinfo.php" to make sure PHP is working with the web server. Then remove the file.

RedHat EL - or 'the upstream vendor' if you are using a clone - will not introduce newer PHP packages unless there is an exception (php53 in EL5.6+). Moodle has quite a some PHP dependencies which cannot be fullfilled solely by installing all RHEL-provided packages.

You have therefore to make a choice:

  • Use RH and pay attention your Moodle version supports it + PHP modules from and maintain them on your own
  • Install the whole (latest) PHP from source on your own (and maintain it)
  • Install PHP packages from a third party repo (but you won't get support from Redhat if you run into problems):
    • [rpms.famillecollet.com] Maintains recent MySQL and PHP packages for supported EL version (a EPEL contributor)
    • RPMFusion and others also have newer PHP packages

Set up the cron job

As root user edit the /etc/crontab file using vi (or another editor) OR you can add a line to the root user's "personal" crontab (don't do both!).

CLI version

Note: According to Moodle's documentation, users should use the CLI version if possible, as the web version may be removed in future.[8]


  • If you wish to place an entry in your root user's crontab use:
    • crontab -e
    • Add the following line:
 */5 * * * * /usr/bin/php /path/to/mymoodle/admin/cli/cron.php

to run the command every 5 minutes.

Web version

Note: Web version is kept here for reference only. Use the CLI version if possible.
  • If you wish to place an entry in your root user's crontab use:

---

  • If you wish to add an entry in /etc/crontab:
  • Open the /etc/crontab file in an editor (vi).
  • Add the following line:

---

  • In either case, don't forget to save the file and exit (in vi that is <Esc>, then ':wq')

Try your new installation

http://myhost.mydomain/mymoodle/admin

or, if you are running the browser on the same machine

http://localhost/mymoodle/admin

Setting Apache Document Root

If you want the web site to be served as http://www.whatever.com/ instead of http://www.whatever.com/mymoodle, edit

/etc/httpd/conf/httpd.conf

Change From: DocumentRoot /var/www/html

Change To: DocumentRoot /var/www/html/mymoodle

Remember to modify the Moodle 'config.php' file and cron job accordingly.

See also