Install Moodle on NS7


(Rob Bosch) #41

Then we should look into this css problem… I think it is wortth a try to find out because with vhost you can select php7.1 for just that vhost and you don’ t have to force php7.1 globally…

(Markus Neuberger) #42

You are right with using a virtual host. I found out that the CSS problem occurs when using https, with http it’s working. I think the problem is (missing) rewriting.

(Rob Bosch) #43

Throw a letsencrypt cert at it? Or isn’t that an issue?

(Markus Neuberger) #44

I have letsencrypt on my VPS, I don’t think that’s an issue.


It works on default virtual host with following /etc/httpd/conf.d/moodle.conf assuming moodle is in /usr/share/moodle but you may change as you like:

Alias /moodle /usr/share/moodle/

<Directory /usr/share/moodle/>
    Require all granted

I’ll try similar approach with a vhost via templates…

(Rob Bosch) #45

@mrmarkuz, Did you manage to go past the problem on your VPS?

(Markus Neuberger) #46

Yes, it does work but not with the NS virtualhost module…for now.

I had some problems with PHP7 and nethserver-mail2 but I reinstalled now and it seems to work:

  • I installed PHP70 instead of 7.1 as it’s enough for moodle -> yum -y install nethserver-mysql nethserver-php-scl php70-php-opcache php70-php-xmlrpc php70-php-intl
  • I used usr/share/moodle as webroot and /var/lib/nethserver/moodledata as data directory just to force better backup integration by having important files in /var/lib/nethserver
  • Following /etc/httpd.conf/moodle.conf is used:
Alias /moodle /usr/share/moodle/
<Directory /usr/share/moodle/>
    Require all granted

(Markus Neuberger) #47

With this /etc/httpd/conf.d/moodle.conf moodle uses PHP71 and php settings in web UI could be set to default to make httpd-admin work:

Alias /moodle /usr/share/moodle
<Directory /usr/share/moodle>
  Require all granted
  <FilesMatch \.php$>
        SetHandler "proxy:fcgi://"

(Markus Neuberger) #48

I cloned nethserver-rh-php56-php-fpm, which is used in nethserver-nextcloud, to nethserver-rh-php71-php-fpm that installs rh-php71-fpm to provide php7 next to httpd-admin.

I used /usr/share/moodle as www dir and /var/lib/nethserver/moodledata for moodledata dir.

After installation browse to https://NETHSERVER/moodle.

Full moodle installation
yum -y install
yum -y install nethserver-mysql rh-php71-php-mysqlnd rh-php71-php-gd rh-php71-php-intl rh-php71-php-mbstring rh-php71-php-xmlrpc rh-php71-php-soap rh-php71-php-opcache
tar -xzf moodle-latest-34.tgz
mv moodle /usr/share/
mkdir /var/lib/nethserver/moodledata
chown -R apache:apache /var/lib/nethserver/moodledata /usr/share/moodle
create database moodle character set utf8mb4 collate utf8mb4_bin;
grant all privileges on moodle.* to moodle@localhost identified by 'SECRET';
cat << EOF > /etc/httpd/conf.d/moodle.conf
Alias /moodle /usr/share/moodle
<Directory /usr/share/moodle>
  Require all granted
  <FilesMatch \.php$>
        SetHandler "proxy:fcgi://"
cat << EOF > /etc/my.cnf.d/moodle.cnf
default-character-set = utf8mb4
innodb_file_format = Barracuda
innodb_file_per_table = 1
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
default-character-set = utf8mb4
systemctl restart httpd
systemctl restart mysqld
systemctl restart rh-php71-php-fpm

(Stéphane de Labrusse) #49

You should not use the same port I used in my module :smiley:

We might have issues when the two modules will be installed together or better use a unix socket (check my module)

(Markus Neuberger) #50

And I should not reinvent the wheel when your module already has the function. :smiley:
So it would just be ok to install nethserver-php-scl and use the SetHandler.

I did not recognize that the open ports came from your module because I installed php packages like crazy to get moodle work and then I tried the fpm approach and wondered why php71 opens port 9000 instead of 9071 and solved it with an additional config file. At least I learned something…

Would it be possible to have your module as “light” version without remi repo and UI, just fpm working? It’s the ideal php-fpm environment. Don’t take me wrong, I really like the flexibility of your module but it may be too much when just needing php for a specific app. Just an idea. Or in other words: Why does nextcloud not use your module?

(Rob Bosch) #51

I noticed that the ‘old’ moodle module was broken too… so it either needs some attention, or be marked as broken…
I will give it a try to get moodle 3.4 working on my VPS…

(Stéphane de Labrusse) #52

validated, drop a simple conf file

[root@NS7 ~]# cat  /etc/httpd/conf.d/www.conf
    # Further relax access to the default document root:
    <Directory "/var/www/html">
      <FilesMatch \.php$>
            SetHandler "proxy:fcgi://"

restart httpd and you will use php71 for the whole /var/wwwhtml

When I started this rpm, remi was the only who proposed a lot of versions and rpm available both for php56,70,71 (as a side now he proposes php72). Now you can see that much more versions are available

yum list \*php??-php\*

Because I proposed to load a different version of php for the whole server I decided to bring a lot of php package to satisfy all my modules (wordpress, phpmyadmin, …) but it was a design choice rather the rpm of @giacomo which aims to be used by developers. The example of nextcloud illustrates it well,
nethserver-rh-php56-php-fpm brings only php56-fpm, all others dependencies come with nethserver-nextcloud.

Now if I use the php-fpm for /var/www/htlm maybe it makes no sense to bring so much rpm except to simplify the life of less techy people.

I’m quite sure that you/we can clone the rpm nethserver-rh-php56-php-fpm to bring other php-fpm version, probably apart the path which is not the same and some sed actions, it should be easy

[root@NS7 ~]# ll /etc/e-smith/templates/opt/remi/php56/root/etc/php
php-fpm.d/ php.ini/ 
[root@NS7 ~]# ll /etc/e-smith/templates/etc/opt/remi/php70/php
php-fpm.d/ php.ini/ 
[root@NS7 ~]# ll /etc/e-smith/templates/etc/opt/remi/php71/php
php-fpm.d/ php.ini/

(Giacomo Sanchietti) #53

Next few days, @alep will fork the nethserver-rh-php56-php-fpm repository and create a new one for PHP 7.
The work is needed for nextcloud 13 :wink:

(Stéphane de Labrusse) #54

same for me, new version is coming and I get rid of php-mod in my module, full php-fpm in /var/www/html, I would like to bring also php72

(Marc) #55

Concerning PHP, some time ago Remi wrote an article with some tips:

(Stéphane de Labrusse) #56

please @robb @mrmarkuz or anyone, can you check this version of php-scl

yum install

the purpose is to enable php-fpm in /var/www/html

no more problem of nethgui …I hope :smiley:

(Markus Neuberger) #57

I did a quick test on a fresh installed VM…

phpinfo in /var/www/html:


moodle uses php-fpm now in /var/www/html and MailAddresses in UI is still working. :sunglasses:

(Alessandro Polidori) #58

here it is
It will be tested

(Markus Neuberger) #59

I tested it with moodle and it worked. :+1: I had to stop rh-php56-php-fpm and restart rh-php71-php-fpm to make it work because both use port 9000.

(Stéphane de Labrusse) #60

Like said, this two versions are for dev but you can drop your specific configuration to adjust your need