|
|
(45 intermediate revisions by 10 users not shown) |
Line 1: |
Line 1: |
| {{stub}}This is a starting guide to install Moodle with Nginx/PHP-fpm/Postgres on the [http://releases.ubuntu.com/ latest Ubuntu LTS]. It is important to take note that Moodle is heavily tested on Apache2 environment, not on Nginx environment. This document is for people having previously installed a Moodle site and a Ubuntu distribution, and having some basic knowledge of Linux command lines (vim, linux permissions..).
| | Please see https://docs.moodle.org/en/Nginx |
| | |
| == Nginx ==
| |
| sudo apt-get update
| |
| | |
| sudo apt-get upgrade
| |
| | |
| sudo apt-get install python-software-properties
| |
| | |
| sudo add-apt-repository ppa:nginx/stable
| |
| | |
| sudo apt-get update
| |
| | |
| sudo apt-get install nginx
| |
| | |
| sudo mkdir -p /home/nginx/localhost/{public,private,log,backup}
| |
| | |
| sudo vim /etc/nginx/sites-available/default
| |
| <code bash>
| |
| server {
| |
| root /home/nginx/localhost/public;
| |
| index index.html index.htm index.php;
| |
| | |
| server_name yourdomainname.com;
| |
| | |
| location / {
| |
| # First attempt to serve request as file, then
| |
| # as directory, then fall back to index.html
| |
| try_files $uri $uri/ /index.html;
| |
| }
| |
| | |
| location ~ \.php$ {
| |
| fastcgi_pass 127.0.0.1:9000;
| |
| fastcgi_index index.php;
| |
| include fastcgi_params;
| |
| }
| |
| }
| |
| </code>
| |
| | |
| == Postgres 9.0.3 ==
| |
| | |
| sudo apt-get install autoconf2.13 libssl-dev libcurl4-gnutls-dev libjpeg62-dev libpng12-dev libmysql++-dev libfreetype6-dev libt1-dev libc-client-dev libevent-dev libxml2-dev libtool libmcrypt-dev<br/>
| |
| Note: require for compiling PHP too.
| |
| | |
| cd /usr/local/src
| |
| | |
| sudo apt-get install build-essential libreadline6-dev zlib1g-dev
| |
| | |
| wget http://wwwmaster.postgresql.org/redir/333/h/source/v9.0.3/postgresql-9.0.3.tar.gz
| |
|
| |
| tar zxvf postgresql-9.0.3.tar.gz
| |
| | |
| cd postgresql-9.0.3
| |
| | |
| ./configure
| |
| | |
| make
| |
| | |
| sudo make install
| |
| | |
| sudo vim /etc/profile
| |
| <code bash>
| |
| Add to the end of /etc/profile:
| |
| export PATH="/usr/local/pgsql/bin:${PATH}"
| |
| </code>
| |
| | |
| source /etc/profile
| |
| | |
| sudo adduser postgres
| |
| | |
| sudo mkdir /usr/local/pgsql/data
| |
| | |
| sudo chown postgres /usr/local/pgsql/data
| |
| | |
| sudo su postgres
| |
| | |
| /usr/local/pgsql/bin/initdb-E UTF8 -D /usr/local/pgsql/data
| |
| | |
| /usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data
| |
| | |
| exit
| |
| | |
| psql -U postgres
| |
| | |
| \password
| |
| | |
| createdb -E UTF8 -O postgres -T template0 -U postgres moodle
| |
| | |
| \q
| |
| | |
| == PHP 5.3.3 ==
| |
| Note: if you use postgres to not take PHP 5.3.5, pg_set_client_encoding() will crash with a http 500 error.
| |
| | |
| sudo apt-get install libltdl-dev
| |
| | |
| cd /usr/local/src
| |
| | |
| sudo wget -O php-5.3.3.tar.gz http://us.php.net/get/php-5.3.3.tar.gz/from/us.php.net/mirror/
| |
| | |
| tar zxvf php-5.3.3.tar.gz
| |
| | |
| cd php-5.3.3
| |
| | |
| ./configure --enable-fpm --with-gd --with-mcrypt --enable-mbstring --with-openssl --with-jpeg-dir=/usr/lib --enable-gd-native-ttf --with-libxml-dir=/usr/lib --with-curl --enable-zip --enable-sockets --with-zlib --enable-exif --enable-ftp --with-iconv --with-gettext --enable-gd-native-ttf --with-t1lib=/usr --with-freetype-dir=/usr --prefix=/usr/local/php --with-fpm-user=www-data --with-fpm-group=www-data --with-pgsql=/usr/local/pgsql --enable-tokenizer --with-xmlrpc --enable-soap --enable-ctype
| |
| | |
| Note: this is to support postgres. TODO: intl extension is not enabled. If you not how to do it edit this document ;)
| |
| | |
| sudo make
| |
| | |
| sudo make install
| |
| | |
| sudo cp php.ini-production /usr/local/php/lib/php.ini
| |
| | |
| sudo chmod 644 /usr/local/php/lib/php.ini
| |
| | |
| sudo cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
| |
| | |
| sudo cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
| |
| | |
| sudo chmod 755 /etc/init.d/php-fpm
| |
| | |
| sudo update-rc.d -f php-fpm defaults
| |
| | |
| sudo touch /var/run/php-fpm.pid
| |
| | |
| sudo vim /etc/init.d/php-fpm
| |
| <code bash>
| |
| change location of pid (remove ${prefix}) to:
| |
| php_fpm_PID=/var/run/php-fpm.pid
| |
| </code>
| |
| | |
| sudo vim /usr/local/php/etc/php-fpm.conf
| |
| <code bash>
| |
| Changes these values
| |
| --------------------------------
| |
| pid = /var/run/php-fpm.pid
| |
| error_log = /var/log/php-fpm.log
| |
| --------------------------------
| |
| Uncomment the lines for:
| |
| -------------------------
| |
| pm.start_servers = 20
| |
| pm.min_spare_servers = 5
| |
| pm.max_spare_servers = 35
| |
| </code>
| |
| | |
| sudo service php-fpm start
| |
| | |
| sudo /etc/init.d/nginx restart
| |
| | |
| vim /home/nginx/localhost/public/index.php
| |
| <code bash>
| |
| Enter:
| |
| <?php
| |
| phpinfo();
| |
| ?>
| |
| </code>
| |
| | |
| Check it is available.
| |
| | |
| == Install APC ==
| |
| With APC, Moodle will be a lot faster.
| |
| | |
| sudo /usr/local/php/bin/pecl config-set php_ini /usr/local/php/lib/php.ini
| |
| | |
| sudo /usr/local/php/bin/pecl install apc
| |
| | |
| sudo vim /usr/local/php/lib/php.ini
| |
| add (if not already existing): extension=apc.so
| |
| | |
| == Moodle ==
| |
| [https://docs.moodle.org/en/Installing_Moodle Install Moodle] into /home/nginx/localhost/public/. Note that it is recommended to install Git and to get the Moodle files with Git.
| |
| | |
| In the Moodle administration, disable 'slash arguments' (http://YOURMOODLESITE/admin/search.php?query=slashargument).
| |
| | |
| == More to do ==
| |
| * follow [https://docs.moodle.org/en/Security Moodle security page]
| |
| * Secure SSH (see this [http://articles.slicehost.com/2009/3/31/debian-lenny-setup-page-1 slicehost debian setup page])
| |
| * Enable SSL (you can use [http://blurringexistence.net/archives/5-nginx-and-StartSSL.html to install a free SSL certificate with startSSL])
| |
| * Setup firewall ([http://ubuntuforums.org/showthread.php?t=159661 ubuntu documentation])
| |
| * Install SMTP server ([https://help.ubuntu.com/community/Postfix Ubuntu documentation with working main.cf], [http://library.linode.com/email/postfix/dovecot-system-users-ubuntu-10.04-lucid Linode documentation], [http://helpdesk.bluehost.com/index.php/kb/article/000294 documentation about MX-record])
| |
| | |
| | |
| There are still a lot more to do (setting up your domain name, establishing a maintenance plan...). Be patient and have fun.
| |
| | |
| == Related document ==
| |
| * Nginx/PHP-fpm [http://bestsiteinthemultiverse.com/2011/01/installing-nginx-with-php-fpm-on-ubuntu-10-04/ blog post]
| |
| * Compiling Postgres 9 [http://www.johnwulff.com/2010/05/04/how-to-compile-and-install-postgresql-9-beta-on-ubuntu blog post]
| |