Sunday, November 2, 2014

OpenCPU and rapache Installation

I used a combination of installation instructions from http://rapache.net/manual.html and https://github.com/jeroenooms/opencpu-server/tree/master/debian#readme in order to get OpenCPU installed.  This was a process of trial-and-error.  Eventually there were no critical errors and the commands would work.  Building rApache, I used the instruction from the rapache site.  Building OpenCPU I used the instructions from the github link above.  When I first attempted the build there were a few missing dependencies.  I installed these and then retried the build with success.  Installing OpenCPU I used the following instead of the suggested commands.
sudo dpkg -i opencpu-lib*
sudo dpkg -i opencpu-server*
I also opted to install apparmor using the instructions on the github link

Saturday, November 1, 2014

OpenCPU Installation

The installation of OpenCPU on my Debian system is less than simple.  There is no easy apt-get solution so I am working my way through the instruction on https://github.com/jeroenooms/opencpu-server/tree/master/debian#readme.  So far I made it through 'Building OpenCPU packages'.  When I got to the 'debuild' command I got an error 'debuild command not found'.  This was solved by installing the 'devscripts' package (sudo apt-get install devscripts).    

Frameworks

After careful research and consideration I am going to use Drupal as my full stack framework with Bootstrap for the web layer.  I read lots of recommendations for Bootstrap.  The reviews said Drupal was easier to get going than Django.  Eventually I expect I will shift the web app to Python (Django), but I'd rather just get going at this point.  Hence the decision to go with Drupal (PHP) for now.  Looks like Django can also interface with Bootstrap so I'm thinking the shift will not be that bad if/when I get to that point.  On the other side I decided to use opencpu to interface with R.  Again, I'm hoping this will facilitate any eventual shift to Python/Django since opencpu is a framework agnostic API.  I will also install rApache just for good measure, but I don't currently plan to do any R scripting with PHP/Drupal.

Saturday, October 25, 2014

Curl and RCurl getURL

I wanted to use the getURL function from RCurl so I tried to install the RCurl package.  I received this error Cannot find curl-config. In order to clear the error, I had install curl (apt-get install curl).  This didn't work so I ended up trying (libcurl4-gnutls-dev).  I then had to restart R and install R package bitops.  I ran library(RCurl) just to be sure.  getURL is now working.

Friday, October 24, 2014

User Authentication Parameters in .my.cnf

The RMySQL documentation (http://cran.r-project.org/web/packages/RMySQL/RMySQL.pdf) recommends placing user authentication parameters (user, password, database, and host) in the config file. This file is read from $HOME/.my.cnf.  I found this file did not exist so I copied the my.cnf file from /etc/mysql to my home directory and changed ownership (sudo chown...).  Next I added a group and my authentication parameters to the file.  I could then used 'con <- dbConnect(MySQL(), group = "group name")' in R to connect to my database.  This might be more secure if I were to continue using R Studio server from a separate computer, but my plan is to run R scripts locally initiated from PHP files, so I don't think there is any enhancement security in my case, but it does work.

Thursday, October 23, 2014

RMySQL - dbConnect

Now that R was recognizing the dbConnect function, there was a new error.
Error in mysqlNewConnection(drv, ...) : 
  RS-DBI driver: (Failed to connect to database: Error: Access denied for user 'root'@'localhost' (using password: YES)
I concluded this error was returned from MySQL and started looking for a solution in MySQL.  Using MySQL Workbench I had created a database and connected to it from within Workbench.  However I was unable to connect to MySQL from the command line.  I couldn't even start MySQL from the command line.  When you install MySQL you need to create grant tables.  This is easily accomplished in Workbench using the new instance wizard.  I had to select 'Debian' a few steps into the wizard so it would know the correct file paths.  Once the instance was established I was able to create users and assign them access to my database.  I was then able to connect to MySQL from R using my newly created user.

RMySQL Installation Challenges

I loaded RMySQL package so I could connect R to MySQL.  I used the install feature within R Studio.  The package installed without errors, but when I tried to use the dbConnect function I would get this message Error: could not find function "dbConnect".  I finally tried 'library(RMySQL)' and that did the trick.  Also had to run 'library(DBI)'.  DBI was installed with RMySQL as a dependency.

Background

Several months ago I purchased a used computer to use for a hobby machine with the intent of learning more about programming.  Recently I realized that if I didn't start to capture my experience, there was a good chance I would forget what I had done.  So today I am starting this blog to capture my small achievements.  So far I installed Linux Debian, Apache, MySQL, PHP and R Studio Server.  I installed VNC so I can access my machine remotely.  After some research I also installed NetBeans (PHP and others), PyCharm and MySQL Workbench IDEs.