![]() |
| Source: http://blogs.babycenter.com/wp-content/uploads/2009/01/crawling-baby_191.jpg |
(note, this is NOT me in the picture above)
Although I’d done this in simulation, setting up a “production” site for a company was certainly a fun challenge where “failure was not an option.”
At the command line/terminal, type the following…be ready to write down/remember any usernames and passwords that you are asked to create through the next two steps.
sudo apt-get install tasksel
Per Ubuntu web site, Tasksel is a Debian/Ubuntu tool that installs multiple related packages as a co-ordinated “task” onto your system. We will use that to install Apache/MySQL server:
Step 2 – Install Apache/MySQL
sudo tasksel install lamp-server
Once this step is complete, you should be able to go to http://localhost and see a message saying something along the lines of “It Works!” etc. You will get some errors if you don’t take the next step:
a) Edit the httpd.conf file
sudo nano /etc/apache2/httpd.conf
This will create a blank file to which you can paste the following into the body:
ServerName localhost
b) Restart the web server with the command below:
sudo /etc/init.d/apache2 restart
Note that you can stop the server with this command:
sudo /etc/init.d/apache2 stop
…or “start” it by replacing the word “stop” in the command above.
Step 3 – Install PHP and Other Needed Extensions
Below are steps that you will need to take (there might be some slight overlap) to setup PHP and other needed components for Moodle. You will want to take each line one by one (although you can also combine them as you see fit):
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo apt-get install php5-curl curl php5-xmlrpc php5-gd php5-intl
sudo apt-get install unzip zip aspell-en aspell-fr aspell-de aspell-es
sudo apt-get install php5-ldap php5-odbc
sudo apt-get install libapache2-mod-php5 libapache2-mod-ruby libapache2-mod-python php5 php5-common php5-dev php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-mysql php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
Step 4 – Install AntiVirus
sudo apt-get install clamav-base clamav-freshclam clamav
This will install antivirus tools on the server.
Step 5 – Edit the PHP.ini file
nano /etc/php5/apache2/php.ini
At this point, you will want to restart the server with the following command and begin the process of copying Moodle to the appropriate location, probably /var/www/moodledirectory.
To install Moodle, you will need to do some command line magic with MySQL and copying-n-pasting stuff. Below are my rough notes on the subject:
a) Create MySQL database and a MySQL user @ localhost that will be used during Moodle install configuration
#mysql -u root -pcreate database sandbox default character set utf8;
grant all privileges on sandbox.* to ‘moodleuser‘@’localhost’ identified by ‘yourpassword‘;
flush privileges;
quit
Note that “sandbox” , “moodleuser” could be replaced to be anything else. You can create additional users and assign them rights:
mysql> CREATE USER ‘mguhlin’@’localhost’ IDENTIFIED BY ‘PASSWORD’;
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘mguhlin’@’localhost’ WITH GRANT OPTION;
In the scenario above, a user “mguhlin” is being created.
b) Create Moodledata folder
You will need to create a MoodleData directory. Here’s the command to do it:
sudo mkdir /var/moodledata
Since I like to put all my Moodle instances’ MoodleData folders as subdirectories of MoodleData, I would create new subdirectories in the following way:
sudo mkdir /var/moodledata/sandbox
If I needed to assign write access, I would probably do something like the following:
sudo chmod -R 777 /var/moodledata
c) Download the Moodle installation file
From the command line, you can download the Moodle installation file. For example:
wget “http://download.moodle.org/download.php/stable22/moodle-latest-22.zip”
should enable you to download the Moodle file. Once downloaded, you can unzip the file in this way:
unzip moodle-latest-22.zip
By the way, if the wget command pulls up a blank file (not one that is 30-40 megs in size), you may want to get the direct link for the Moodle install file download (click on the regular link and then before it starts to download, copy-n-paste the link for “direct link”). I sometimes use a URL shortener (goo.gl) to get a shorter link to work with if I have to type, rather than copy-n-paste, the link into the Terminal window.
d) Create folder where Moodle PHP files will be stored.
To create the folder where you will store the Moodle PHP files–these are the files you extracted after downloading and unzipping the file from above. You can create the folder with this command:
sudo mkdir /var/www/sandbox
where sandbox is the name of the proposed Moodle instance.
Then copy the contents of your downloaded, unzipped Moodle install file with this command:
sudo cp -rv /home/yourusername/moodle/* /var/www/sandbox/
e) Begin the web-based install process
Go to your web browser and type in the URL of the server, or, if on your own computer, type
You should see the start of the Moodle installation. Follow the steps suggested. After you’ve installed Moodle, you should see everything pop up as normal.
Your Moodle will need to occasionally run cron jobs. Why is the cron job important?
Cron assists some of Moodle’s modules to perform tasks on a scheduled basis. For example, the cron process might tell Moodle to check all discussion forums so it can mail out copies of new posts to people who have subscribed to that forum. The primary Moodle script that does all this is located in the admin directory, and is called cron.php. However, it can not tell itself to run, so you need to set up a mechanism where this script is run regularly (eg every five or ten minutes). This provides a “heartbeat” so that the script can perform functions at periods defined by each module.
Read Cron – MoodleDocs
You can edit the cron job in the following way:
env EDITOR=nano crontab -e
Paste in a modified line of instructions for every Moodle instance you have running on the server:
*/10 * * * * wget -q -O /dev/null “http://localhost/sandbox/admin/cron.php”
Note that this line of instruction will run the cron job every 10 minutes. There are other ways of accomplishing this task, so be open to the possibilities!
To edit cron jobs, go to /etc/cron.weekly, /etc/cron.hourly, /etc/cron.monthly. For example:
cd /etc/cron.weekly
sudo apt-get install openssh-server unattended-upgrades
Enter your email address:
Delivered by FeedBurner
Discover more from Another Think Coming
Subscribe to get the latest posts sent to your email.



Thanks for sharing this. I've developed a fascination for Ubuntu server. I've practiced setting up Ubuntu server and Moodle using VMWare and Virtualbox. It's been great fun!I have handled the Moodledata folder a bit differently than you describe. Rather than changing the folder permissions, I set change the folder owner: chown www-data \path_to_moodledata. Is there a benefit to changin permissions to 777?Thanks again,Jeff
Thanks for sharing this. I've developed a fascination for Ubuntu server. I've practiced setting up Ubuntu server and Moodle using VMWare and Virtualbox. It's been great fun!I have handled the Moodledata folder a bit differently than you describe. Rather than changing the folder permissions, I set change the folder owner: chown www-data \path_to_moodledata. Is there a benefit to changin permissions to 777?Thanks again,Jeff