Thursday, June 14, 2012

Creating a new moodle instance using Apache Vhost configuration

I am creating a second moodle instance on my server that has been only hosting a single instance for the past few months.  The first thing I did was remote into the moodle server and browse to the web root.  I am using a WAMP configuration, my webroot is c:\wamp\www.  I created a new folder and called it content.  I created a simple index.html file with "hello from content instance"  and saved it into the wamp\content folder.

Next, I opened the Apache configuration file httpd.conf, located at c:\wamp\bin\apache\apache2.2.21\conf and activated the vhost directive Include conf/extra/httpd-vhosts.conf. in the supplemental configuration section toward the bottom of the file. I should note that I had to go to our network guys and get the new DSN for the moodle instance added to whatever registry it needs to live in to be accessible.

I then opened the http-vhost.conf file and added a new definition for the soon to be installed moodle instance This is part of what that file looks like.

VirtualHost *:80
    DocumentRoot "drive:/pathtowebroot/content"
    ServerName name.registered.withnetworkguys
    ErrorLog "drive:\pathtoerrorlog\content_error.log"
    CustomLog "drive:\pathtoaccesslog\content_access" common

I saved the file, restarted Apache service and browsed to my ServerName value and saw "hello from content instance" rendered from the index.html file at its root.  This was a good sign. I looked in the access and error folders and saw new log files for each instance, that was another good sign.

Get Latest moodle 2.2 build, download, extract and copy extraction content

After verifying that there was not another more recent stable moodle 2.2 release, I unzipped the moodle-lastest-22.zip file and then extracted its content into a temporary location.  When the extraction was done, I browsed into the moodle folder in the extraction directory, since I did not want to include the moodle folder and copied its content into the www\content folder where www is my webroot.

Once the files where in place, I only needed to refresh my browser that was pointing to www/content.

The moodle installation begins. Specifics to follow.

Choose a language - simple.
Confirm paths: I was presented with this:
   Web Address  - http://content.edutech.org
   moodle directory c:\wamp\www\content
   Data directory c:\wamp\www\moodledata

The first two items where not avail for me to edit, the Data directory was, and surprisingly, was defaulting into the web root?  Its a better practice to place the data folder outside the web root.  I changed the value outside the web root.

Choose database driver - easy for me native/myslqi

Database settings
Here, it was important to have created the database first. I had to think for a minute about whether I needed to create a new user and password, for this installation process, where it would ask for a user with rights to create tables in the currently empty DB. I realized that I had done that with the initial moodle install on the server.  I was able to use an existing user in the mysql DB that was created upon installation of MySQL.  The only problem I ran into was not knowing the password of the user account I wanted to use.  The user who I use to connect with in the config.php file did not have proper permission to alter tables.  I ended up updating the permissions of my user connecting from config.php, since I could see what that password was.  I could have created another new user for this installation, but I did not want to do that.  I specified the user and password for the account I just updated and proceeded.  I was greeted with a fatal error that said DDL sql execution error "alter command denied for user...". hmmm? I thought I had just given this account permission to do this very thing? I browsed to the DB via phpMyAdmin and looked at the DB and saw the table trying to be created, I deleted the table, refreshed database and tried again, and got the same result.  hmmmm. then it occurred to me that I had not restarted MySQL and perhaps my newly minted permissions for the account where not recongnized.  I restarted the MySQL service, via the Wamp icon, I deleted the table from the DB and tried again and this time had success, and saw all the tables being created in my DB.

Copyright notice
When the DB was complete, I clicked to the next step of the installation and saw the Moodle Modular bla bla screen and excepted the copyright notice. That was a good sign.

Server Checks
I was then greeted with the Server Checks form where everything looked good, since I took care of the server requirements on the initial install of moodle. Nice.

Admin credentials
I then specified credentials for the admin account in moodle.

Front page settings
I then specified front page settings

And now, I am complete. Yea.

Overall experience not bad.  If I could have remembered the password of the user account who had all the permissions to begin with, this process would have been very seamless.  It was nice to skip right over the Server setup stuff, which was a bit of work when initially setting up PHP.  Since the same set of core PHP code is serving this instance, not need to do any work. Nice.






No comments:

Post a Comment