Install Moodle on NS7

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…

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.

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

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

EDIT:

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
</Directory>

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

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

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
</Directory>

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://127.0.0.1:9071"
  </FilesMatch>
</Directory>

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 https://smart-ict.services/mirror/mrmarkuz/7/noarch/nethserver-rh-php71-php-fpm-0.0.1-1.ns7.noarch.rpm
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
wget https://download.moodle.org/download.php/direct/stable34/moodle-latest-34.tgz
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
mysql
create database moodle character set utf8mb4 collate utf8mb4_bin;
grant all privileges on moodle.* to moodle@localhost identified by 'SECRET';
exit;
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://127.0.0.1:9071"
  </FilesMatch>
</Directory>
EOF
cat << EOF > /etc/my.cnf.d/moodle.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
EOF
systemctl restart httpd
systemctl restart mysqld
systemctl restart rh-php71-php-fpm
1 Like

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)

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?

2 Likes

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…

1 Like

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://127.0.0.1:9071"
      </FilesMatch>
    </Directory>

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/
1 Like

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:

6 Likes

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

3 Likes

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

5 Likes

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

yum install http://mirror.de-labrusse.fr/NethDev/nethserver-php-scl/nethserver-php-scl-1.1.3-1.ns7.sdl.x86_64.rpm

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

no more problem of nethgui …I hope :smiley:

3 Likes

I did a quick test on a fresh installed VM…

phpinfo in /var/www/html:

grafik

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

4 Likes

here it is https://github.com/NethServer/nethserver-rh-php71-php-fpm
It will be tested

3 Likes

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.

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

2 Likes