November 10

Moodle/Nginx install on Centos .6.6

 

http://mirror.hmc.edu/centos/6.6/isos/x86_64/CentOS-6.6-x86_64-minimal.iso
cat /etc/sysconfig/network-scripts/ifcfg-eth0 first make sure ethernet card is setup on boot:

to make sure you have :  ONBOOT = “yes”

sudo yum install rpm-build
yum install wget
cd /usr/local/src
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
cd /etc/yum.repos.d
  add in the repo to grab latest nginx vi nginx.repo:
     #nginx.repo
     [nginx]
     name=nginx repo
     baseurl=http://nginx.org/packages/centos/6/$basearch
     gpgcheck=0
     enabled=1
  vi remi.repo
     set [remi]  enabled = 1  AND [remi-php55] enabled = 1 AND [remi-php55-debuginfo] enabled=1
yum update -y
yum install php php-fpm php-gd php-mbstring php-mcrypt php-mysql php-apc php-common php-curl php-intl php-soap php-xmlrpc  -y
yum --enablerepo=remi list mysql mysql-server
yum install git mysql mysql-server -y

vi /etc/php-fpm.d/www*

listen = /tmp/php5-fpm.sock
listen.owner = nginx
listen.group =nginx
user =nginx
group =nginx

vi /etc/php.ini

  • cgi.fix_pathinfo=1
  • add opcache:
    [opcache]
    opcache.enable=1
    opcache.memory_consumption=128
    opcache.interned_strings_buffer=8
    opcache.max_accelerated_files=4000
    opcache.revalidate_freq = 60
    opcache.max_wasted_percentage=5
    ; Required for Moodle
    opcache.use_cwd=1
    opcache.validate_timestamps=1
    opcache.save_comments = 1
    opcache.enable_file_override = 0
  • ; If something does not work in Moodle
    ;opcache.revalidate_path = 1 ; May fix problems with include paths
    ;opcache.mmap_base = 0x20000000 ; (Windows only) fix OPcache crashes with event id 487; Experimental for Moodle 2.6 and later
    ;opcache.fast_shutdown = 1
    ;opcache.enable_cli = 1 ; Speeds up CLI cron
    ;opcache.load_comments = 0 ; May lower memory use, might not be compatible with add-ons and other apps.

intall nginX:

yum install nginx

intall moodle:

  • mkdir /usr/local/src cd /usr/local/src
  • get url for moodle from https:/download.moodle.org/local/downloadmoodleorg/stats.php
  • wget http://download.moodle.org/download.php/direct/moodle/moodle-latest.zip
  • unzip moodle-latest.zip
  • mkdir /var/www/yoursite.com/
  • mv moodle/* /var/www/yoursite.com/
  • chown nginx:adm yoursite.com
  • chmod 755 yoursite.com
  • mkdir /var/www/moodledata
  • chown nginx:adm moodledata -R
  • chmod 755 moodledata -R
  • update config  with sql user/pass and moodledata path at /var/www/moodlesite/config-dist.php

nginx configuration:

rewrite ^/(.*.php)(/)(.*)$ /$1?file=/$3 last;

vi /etc/nginx/conf.d/yoursite.com.conf

 

### yourwebsite.com

server {
root /var/www/yourwebsite.com;
#access_log logs/yourwebsite.com-access_log;
#error_log logs/yourwebsite.com-error_log crit;

listen 80;
server_name yourwebsite.com www.yourwebsite.com;

location / {
index index.php index.html index.htm;

# moodle rewrite rules
rewrite ^/(.*.php)(/)(.*)$ /$1?file=/$3 last;
}

# php parsing
location ~ .php$ {
try_files $uri =404;
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;

}

}
service mysqld restart
mysql -u root
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('password');
exit;
chkconfig --levels 235 mysqld on
chkconfig --levels 235 nginx on
chkconfig --levels 235 php-fpm on
service nginx restart
service php-fpm restart

see next post for certs



October 17

Moodle instal 2.6 stable on VirtualBox

  • install centOS 6.5, download iso and install after setting up an image on VBox
  1. on virtual box open up the different ports:(*port forwarding rules)
  2. Host port 8888 to Guest Port 80
  3. sshAccess HostPort 22 to Guest Port 22
  • install php modules
    • yum install git php-common php-mysql php-gd php-intl php-curl
    • yum install php-ldap php-apc php-mbstring php-dom php-soap php-xmlrpc
    • yum install php php-mysql
    • yum install php-pear php-devel httpd-devel pcre-devel gcc make
    • pecl install apc
      • vi /etc/php.d/apc.ini
      • extension=apc.so
         apc.enabled=1
      • apc.ttl=72000
         apc.user_ttl=72000
         apc.gc_ttl=3600
      • apc.shm_size=1024M
      • apc.stat=1
      • apc.enable_cli=1
      • apc.file_update_protection=2
      • apc.max_file_size=1M
      • apc.num_files_hint=200000
      • apc.user_entries_hint=20000
  • install moodle
    • mkdir  /var/moodle
    • cd /var/moodle
    • git clone -b MOODLE_26_STABLE https://github.com/moodle/moodle.git www
    • mkdir /var/moodle/data
    • chmod 755 all
    • cd /var/moodle/www
    • cp config-dist.php config.php
    • vi config.php and make sure the below is accurate
    • $CFG->dbtype    = 'mysqli';
      $CFG->dblibrary = 'native';
      $CFG->dbhost    = 'localhost';
      $CFG->dbname    = 'moodle';
      $CFG->dbuser    = 'moodle';
      $CFG->dbpass    = 'secretpassword';
      $CFG->prefix    = 'mdl_';
      $CFG->wwwroot   = 'http://localhost';
      $CFG->dataroot  = '/var/moodle/data';
  • install apache
    • yum install httpd
    • update file permissions in moodle
    • chown -R apache:apache /var/moodle
    • chmod -R 755 /var/moodle
    • vi /etc/httpd/conf/httpd.conf
    • add the following at the end
    • <VirtualHost *:80>
          ServerAdmin webmaster@tecadmin.net
          DocumentRoot /var/moodle/www
          ServerName localhost
          CustomLog logs/moodle.tecadmin.net_log combined
      </VirtualHost>
    • in Section 2: ‘Main’ server configuration add:
    • ServerName  localhost
  • install mysql
    • rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
    • make sure your clock is correct or epel will not install.
    • If meta error occurs for EPEL  switch from HTTPS to http by commenting out mirrors in /etc/yum.repos.d/epel.repo
    • yum install mysql55w mysql55w-server
    • mysql -u root -p
    • CREATE DATABASE moodle;
    • GRANT ALL ON moodle.* TO 'moodle'@'localhost' IDENTIFIED BY 'secretpassword';
    • ALTER DATABASE moodle CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;
    • FLUSH PRIVILEGES;
    • quit
  • service httpd start
  • service mysqld start
  • to start on reboot:
    • chkconfig httpd on
    • chkconfig mysqld on