由于在centos7 + nginx + moodle4安装配置篇中已经详细的说明了如果安装moodle,本篇就写的相对简单点,只不过换了个操作系统而已。
- apt-get update
- apt-get -y install nginx php7.4 php7.4-fpm mysql-server php7.4-mysql php7.4-xml php7.4-mbstring \
- php7.4-curl php7.4-zip php7.4-gd php7.4-intl php7.4-xmlrpc php7.4-soap
- cd /var/www/html/
- wget https://download.moodle.org/stable400/moodle-4.0.1.zip
- unzip moodle-4.0.1.zip
- chown -R www-data:www-data moodle
- mkdir moodledata
- chown -R www-data:www-data moodledata/
-
这里使用的是php7.4 + nginx + mysql8 的环境来安装moodle。
由于使用的是mysql8的版本,对应的密码修改方式有些变化:1是使用mysqladmin -u root -p password 新密码的方式修改密码,不过复杂度不够的时候,是不会提示修改不成功的,这里推荐第二种,直接使用SQL指令修改,不过这里较之前的版本有个变化,之前MySQL的密码认证插件是“mysql_native_password”,而现在使用的是“caching_sha2_password”。对应的修改密码命令是:
- use mysql;
- ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'NewPassword@135';
- FLUSH PRIVILEGES;
-
SQL
因类opcache已经默认包含了,这里只修改最大上传参数:
- sed -i 's/max_input_vars = 1000/max_input_vars = 5000/g' /etc/php/7.4/fpm/php.ini
-
- root@ecs-6f59:/etc/nginx/sites-available# grep -v \# default
-
- server {
- listen 80 default_server;
- listen [::]:80 default_server;
-
-
- root /var/www/html/moodle;
-
- index index.php index.html index.htm index.nginx-debian.html;
-
- server_name _;
-
- location / {
- try_files $uri $uri/ =404;
- }
-
- location /dataroot/ {
- internal;
- alias /var/www/html/moodledata/;
- }
-
- location ~ ^(.+\.php)(.*)$ {
- include snippets/fastcgi-php.conf;
- fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- }
-
- location ~ /\.ht {
- deny all;
- }
- }
-
- systemctl start mysql.service
- systemctl enable mysql.service
- systemctl start nginx.service
- systemctl enable nginx.service
- systemctl start php7.4-fpm.service
- systemctl enable php7.4-fpm.service
-
后面的步骤就一样了,就里就不再贴了,包括一键安装的方式,基本也和之前一样,不过数据库连接类型在这里需要修改为mysqli用行了。