Based on this links:
- https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-12-04
- https://docs.moodle.org/dev/Install_Moodle_On_Ubuntu_with_Nginx/PHP-fpm
$ cd /usr/share/nginx/html/
# git clone --depth=1 -b MOODLE_28_STABLE git://git.moodle.org/moodle.git
sudo apt-get install php5-fpm php5-mysql php5-dg php5-curl
Edit:
sudo nano /etc/php5/fpm/php.ini
Replace ; cgi.fix_pathinfo=1
for cgi.fix_pathinfo=0
sudo nano /etc/php5/fpm/pool.d/www.conf
Replace listen = 127.0.0.1:9000
for listen = /var/run/php5-fpm.sock
Restart PHP-fpm
sudo service php5-fpm restart
sudo nano /etc/nginx/sites-available/default
- Add
index.php
atindex
line inserver {}
. - Pass the PHP scripts to FastCGI server listening on the php-fpm socket
- Add
rewrite ^/moodle/(.*\.php)(/)(.*)$ /moodle/$1?file=/$3 last;
insideserver
.
Example:
server {
listen 80;
root /usr/share/nginx/www;
rewrite ^/moodle/(.*\.php)(/)(.*)$ /moodle/$1?file=/$3 last;
index index.php index.html index.htm;
# pass the PHP scripts to FastCGI server listening on the php-fpm socket
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
...
}
Create file in public folder.
sudo nano /usr/share/nginx/www/info.php
Add in the following lines:
<?php
phpinfo();
?>
Run these commands with your name and key.
mysql> CREATE DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO <USER>@localhost IDENTIFIED BY '<PASSWORD>';
Go to http://localhost/moodle
and setup Moodle as usual.
Hi @vladyslav2,
the official Moodle docs tells about using
PATH_INFO
directly and not in the old way via the rewrite rule to present the 'slasharguments' using the HTTP GETfile
param: https://docs.moodle.org/34/en/Nginx#Nginx .HTH,
Matteo