Skip to content

Instantly share code, notes, and snippets.

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 cnsumner/f08cc25cc4afee83ddc2fa698231429d to your computer and use it in GitHub Desktop.
Save cnsumner/f08cc25cc4afee83ddc2fa698231429d to your computer and use it in GitHub Desktop.
Installing LearningLocker on CentOS 7.0
#Installs Remi Collet Repository
sudo yum -y install epel-release
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
sudo yum -y install yum-utils
sudo yum-config-manager --enable remi remi-php56
###############################
#Installs apache, php, and necessary php modules
sudo yum -y install httpd
sudo yum -y install gcc php php-common php-cli php-pear php-devel php-mysqlnd php-pecl-mongo php-gd php-mbstring php-mcrypt php-xml php-bcmath openssl-devel.x86_64
###############################
#install MongoDB
sudo yum -y install mongodb mongodb-server
#install nodejs, npm, and bower
sudo yum -y install nodejs
sudo yum -y install npm
sudo npm install -g bower
###############################
#install git, deltarpm, and update packages
sudo yum -y install git
sudo yum -y install deltarpm
sudo yum -y update
###############################
#install to get semanage command for SELinux config
sudo yum -y install policycoreutils-python
#start and configure firewall, apache, and mongodb
sudo systemctl start firewalld.service
sudo systemctl enable firewalld.service
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo systemctl restart firewalld.service
sudo systemctl start httpd.service
sudo systemctl enable httpd.service
sudo systemctl start mongod
sudo systemctl enable mongod
################################
#install composer and self-update with sudo -H flag to (possibly?) fix a permissions error
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
sudo -H /usr/local/bin/composer self-update
#add current user to apache group and chown www directory recursively to fix permissions (probably)
sudo usermod -a -G apache $USER
sudo chown $USER:apache -R /var/www/
################################
#clone learninglocker and chown the directory, then install with composer
cd /var/www
git clone https://github.com/LearningLocker/learninglocker.git learninglocker
sudo chown $USER:apache -R /var/www/learninglocker
cd learninglocker
composer install
################################
#this allows php to talk to mongodb
sudo setsebool -P httpd_can_network_connect 1
cd /var/www/learninglocker
#collect database credentials and create database and configuration using them
echo "Please enter desired credentials for database."
echo "Username: "
read username
echo "Password: "
read -s password
echo -e "use learninglocker\ndb.createUser({user:\"$username\",pwd:\"$password\",roles:[\"readWrite\"]})" | mongo
rm app/config/database.php
touch app/config/database.php
echo "<?php" >> app/config/database.php
echo "" >> app/config/database.php
echo "return [" >> app/config/database.php
echo "'fetch' => PDO::FETCH_CLASS," >> app/config/database.php
echo "'default' => 'mongodb'," >> app/config/database.php
echo "'connections' => [" >> app/config/database.php
echo "'mongodb' => [" >> app/config/database.php
echo "'driver' => 'mongodb'," >> app/config/database.php
echo "'host' => 'localhost'," >> app/config/database.php
echo "'port' => '27017'," >> app/config/database.php
echo "'username' => '$username'," >> app/config/database.php
echo "'password' => '$password'," >> app/config/database.php
echo "'database' => 'learninglocker'" >> app/config/database.php
echo "]," >> app/config/database.php
echo "]," >> app/config/database.php
echo "'migrations' => 'migrations'," >> app/config/database.php
echo "];" >> app/config/database.php
php artisan migrate
################################
#set up SELinux permissons for server (these might be wrong)
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/learninglocker(/.*)?"
sudo restorecon -Rv /var/www/learninglocker
################################
php artisan key:generate
sudo chown -R apache.apache /var/www/learninglocker
echo "Copy the text below, then hit enter, vi will be launched editing httpd.conf. press i to enter insert mode, navigate to the relevant section (look for DocumentRoot), and replace both pieces with the one section below (it will look the same, it just has a comment between the two sections)"
echo "DocumentRoot \"/var/www/learninglocker/public\""
echo "Alias /learninglocker \"/var/www/learninglocker/public/\""
echo "<Directory \"/var/www/learninglocker/public\">"
echo " Options Indexes FollowSymLinks MultiViews"
echo " AllowOverride All"
echo " Order allow,deny"
echo " Allow from all"
echo " Require all granted"
echo "</Directory>"
echo ""
echo "Press ento to begin editing, hit escape and type :wq and hit enter when done, the script will then resume."
read junk
sudo vi /etc/httpd/conf/httpd.conf
sudo systemctl restart httpd.service
echo "LearningLocker is now *mostly* set up. Make sure to adjust timezone settings in app/config/app.php and email settings in app/config/mail.php"

Prepare CentOS 7.0 Server for Learning Locker LRS

Assumptions:

  • CentOS 7.0 x64 is installed (default install from DigitalOcean Droplet Manager)
  • Logged in via ssh key with root privileges
  • Using MongoDB as database

Install Remi Collet Repository:

yum install epel-release
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum install yum-utils
yum-config-manager --enable remi remi-php56

Install Apache:

yum install httpd

Install PHP and necessary PHP modules:

yum install gcc php php-common php-cli php-pear php-devel php-mysqlnd php-pecl-mongo php-gd php-mbstring php-mcrypt php-xml php-bcmath openssl-devel.x86_64

Install MongoDB

yum install mongodb mongodb-server

Install php MongoDB extension

pecl install mongo

Edit php.ini and add extension=mongo.so to the Dynamic Extensions section

vi /etc/php.ini

Install NodeJs:

yum install nodejs

Install Node Package Manager (NPM):

yum install npm

Install Bower:

npm install -g bower

Install GIT:

yum install git

Install DeltaRPM:

yum install deltarpm

Update CentOS

yum update

Start the Firewall Daemon and enable automatic startup

systemctl start firewalld.service
systemctl enable firewalld.service

Allow HTTP Access through Firewall

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
systemctl restart firewalld.service

Start Apache HTTP Daemon and enable automatic startup

systemctl start httpd.service
systemctl enable httpd.service

Start MongoDB and enable automatic startup

systemctl start mongod
systemctl enable mongod

Install Composer and set global launch

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

Install and Configure LearningLocker

Assumptions:

  • Commands are issued from LL installation directory
  • Using MongoDB as database

Clone LearningLocker via Git:

cd /var/www
git clone https://github.com/LearningLocker/learninglocker.git learninglocker

Install LearningLocker

cd learninglocker
composer install

Create a new MongoDB database:

mongo
use learninglocker

Create MongoDB database user:

db.createUser({user:"username",pwd:"password",roles:["readWrite"]})
exit

Modify app/config/database.php with database credentials:

vi app/config/database.php

Finalize LL MongoDB setup:

php artisan migrate

Allow php to talk to MongoDB

setsebool -P httpd_can_network_connect 1

Set Apache DocumentRoot and Directory Settings:

vi /etc/httpd/conf/httpd.conf
DocumentRoot "/var/www/learninglocker/public"
Alias /learninglocker "/var/www/learninglocker/public/"
<Directory "/var/www/learninglocker/public">
  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny
  Allow from all
  Require all granted
</Directory>

Restart Apache

systemctl restart httpd.service

Set ownership of directories to Apache

chown -R apache.apache /var/www/learninglocker

Adjust url and timezone values in app/config/app.php

Adjust Encryption Key in app/config/app.php

php artisan key:generate

Adjust email settings in app/config/mail.php

Create your admin user at http://yoursite.com/register

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment