Skip to content

Instantly share code, notes, and snippets.

@ionixjunior
Last active September 3, 2015 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ionixjunior/7da9856e2bacdc8768e7 to your computer and use it in GitHub Desktop.
Save ionixjunior/7da9856e2bacdc8768e7 to your computer and use it in GitHub Desktop.
Moodle installation for Cent OS 6.5
#!/bin/sh
# Warning: this script it is unfinished.
MYSQL_ROOT_PASSWORD=12345
MYSQL_MOODLE_PASSWORD=12345
yum -y update
# Expect
yum -y install expect
# Apache - instructions: https://www.howtoforge.com/quick-n-easy-lamp-server-centos-rhel
yum -y install httpd
yum -y install httpd-devel
/etc/init.d/httpd start
# Mysql - not finished
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum --enablerepo=remi,remi-test -y install mysql mysql-server
/etc/init.d/mysqld start
expect <<EOF
spawn /usr/bin/mysql_secure_installation
expect "Enter current password for root (enter for none):"
send "\r"
expect "Set root password?"
send "Y"
send "\r"
expect "New password:"
send "$MYSQL_ROOT_PASSWORD"
send "\r"
expect "Re-enter new password:"
send "$MYSQL_ROOT_PASSWORD"
send "\r"
expect "Remove anonymous users?"
send "Y"
send "\r"
expect "Disallow root login remotely?"
send "n"
send "\r"
expect "Remove test database and access to it?"
send "Y"
send "\r"
expect "Reload privilege tables now?"
send "Y"
send "\r"
expect eof
EOF
expect <<EOF
spawn mysql -u root -p
expect "Enter password: "
send "$MYSQL_ROOT_PASSWORD"
send "\r"
expect "mysql>"
send "USE mysql;"
send "\r"
expect "mysql>"
send "CREATE DATABASE moodle;"
send "\r"
expect "mysql>"
send "GRANT ALL PRIVILEGES ON moodle.* TO 'moodle'@'%' IDENTIFIED BY 'moodle' WITH GRANT OPTION;"
send "\r"
expect "mysql>"
send "UPDATE user SET Password=PASSWORD('$MYSQL_MOODLE_PASSWORD') WHERE user='moodle';"
send "\r"
expect "mysql>"
send "FLUSH PRIVILEGES;"
send "\r"
expect "mysql>"
send "quit"
send "\r"
expect eof
EOF
# PHP 5.5 - instructions: https://webtatic.com/packages/php55/
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
yum -y install php55w
yum -y install php55w-devel
yum -y install php55w-opcache
yum -y install php55w-mysql
yum -y install php55w-gd
yum -y install php55w-mbstring
yum -y install php55w-mcrypt
yum -y install php55w-xml
yum -y install php55w-soap
yum -y install php55w-intl
yum -y install php55w-xmlrpc
# open /etc/php.ini and set date.timezone value
/etc/init.d/httpd restart
# Git
yum -y install git
# Moodle
git clone --depth=1 -b MOODLE_29_STABLE git://git.moodle.org/moodle.git /var/www/html/moodle
chown -R root /var/www/html/moodle
chmod -R 0755 /var/www/html/moodle
find /var/www/html/moodle -type f -exec chmod 0644 {} \;
chown -R apache:apache /var/www/html/moodle
mkdir /var/www/moodledata
chmod 0777 /var/www/moodledata
chown -R apache:apache /var/www/moodledata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment