MacLochlainns Weblog

Michael McLaughlin's Technical Blog

Site Admin

Archive for the ‘Linux’ Category

Install Ruby on Fedora

with 4 comments

I use a Fedora 20 VM image to teach Oracle and MySQL technology. Last week, I expanded the Fedora VM image to support a full LAMP stack. This blog shows you how to install Ruby on Fedora and successfully generate the Rails gems.

Connect as the root user and use yum to install the libraries. My approach is by library or small groups. Naturally, you start with the ruby library.

yum install ruby

You will see the following:

Loaded plugins: langpacks, refresh-packagekit
mysql-connectors-community                                  | 2.5 kB  00:00     
mysql-tools-community                                       | 2.5 kB  00:00     
mysql56-community                                           | 2.5 kB  00:00     
pgdg93                                                      | 3.6 kB  00:00     
updates/20/x86_64/metalink                                  |  14 kB  00:00     
updates                                                     | 4.9 kB  00:00     
(1/3): mysql56-community/20/x86_64/primary_db               |  80 kB  00:00     
(2/3): pgdg93/20/x86_64/primary_db                          |  80 kB  00:00     
(3/3): updates/20/x86_64/primary_db                         |  13 MB  00:06     
(1/2): updates/20/x86_64/pkgtags                            | 1.4 MB  00:01     
(2/2): updates/20/x86_64/updateinfo                         | 1.9 MB  00:01     
Resolving Dependencies
--> Running transaction check
---> Package ruby.x86_64 0:2.0.0.353-16.fc20 will be installed
--> Processing Dependency: ruby-libs(x86-64) = 2.0.0.353-16.fc20 for package: ruby-2.0.0.353-16.fc20.x86_64
--> Processing Dependency: rubygem(bigdecimal) >= 1.2.0 for package: ruby-2.0.0.353-16.fc20.x86_64
--> Processing Dependency: ruby(rubygems) >= 2.0.3 for package: ruby-2.0.0.353-16.fc20.x86_64
--> Processing Dependency: /usr/bin/ruby for package: ruby-2.0.0.353-16.fc20.x86_64
--> Processing Dependency: libruby.so.2.0()(64bit) for package: ruby-2.0.0.353-16.fc20.x86_64
--> Running transaction check
---> Package ruby-libs.x86_64 0:2.0.0.353-16.fc20 will be installed
---> Package rubygem-bigdecimal.x86_64 0:1.2.0-16.fc20 will be installed
---> Package rubygems.noarch 0:2.1.11-115.fc20 will be installed
--> Processing Dependency: rubygem(rdoc) >= 4.0.0 for package: rubygems-2.1.11-115.fc20.noarch
--> Processing Dependency: rubygem(psych) >= 2.0.0 for package: rubygems-2.1.11-115.fc20.noarch
--> Processing Dependency: rubygem(io-console) >= 0.4.1 for package: rubygems-2.1.11-115.fc20.noarch
---> Package rubypick.noarch 0:1.1.1-1.fc20 will be installed
--> Running transaction check
---> Package rubygem-io-console.x86_64 0:0.4.2-16.fc20 will be installed
---> Package rubygem-psych.x86_64 0:2.0.0-16.fc20 will be installed
--> Processing Dependency: libyaml-0.so.2()(64bit) for package: rubygem-psych-2.0.0-16.fc20.x86_64
---> Package rubygem-rdoc.noarch 0:4.0.1-2.fc20 will be installed
--> Processing Dependency: rubygem(json) < 2 for package: rubygem-rdoc-4.0.1-2.fc20.noarch
--> Processing Dependency: rubygem(json) >= 1.4 for package: rubygem-rdoc-4.0.1-2.fc20.noarch
--> Processing Dependency: ruby(irb) for package: rubygem-rdoc-4.0.1-2.fc20.noarch
--> Running transaction check
---> Package libyaml.x86_64 0:0.1.6-2.fc20 will be installed
---> Package ruby-irb.noarch 0:2.0.0.353-16.fc20 will be installed
---> Package rubygem-json.x86_64 0:1.7.7-101.fc20 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package                 Arch        Version                 Repository    Size
================================================================================
Installing:
 ruby                    x86_64      2.0.0.353-16.fc20       updates       65 k
Installing for dependencies:
 libyaml                 x86_64      0.1.6-2.fc20            updates       55 k
 ruby-irb                noarch      2.0.0.353-16.fc20       updates       86 k
 ruby-libs               x86_64      2.0.0.353-16.fc20       updates      2.8 M
 rubygem-bigdecimal      x86_64      1.2.0-16.fc20           updates       77 k
 rubygem-io-console      x86_64      0.4.2-16.fc20           updates       48 k
 rubygem-json            x86_64      1.7.7-101.fc20          fedora        60 k
 rubygem-psych           x86_64      2.0.0-16.fc20           updates       75 k
 rubygem-rdoc            noarch      4.0.1-2.fc20            fedora       288 k
 rubygems                noarch      2.1.11-115.fc20         updates      224 k
 rubypick                noarch      1.1.1-1.fc20            updates      6.3 k
 
Transaction Summary
================================================================================
Install  1 Package (+10 Dependent packages)
 
Total download size: 3.7 M
Installed size: 13 M
Is this ok [y/d/N]: y
Downloading packages:
(1/11): ruby-2.0.0.353-16.fc20.x86_64.rpm                   |  65 kB  00:00     
(2/11): libyaml-0.1.6-2.fc20.x86_64.rpm                     |  55 kB  00:00     
(3/11): ruby-irb-2.0.0.353-16.fc20.noarch.rpm               |  86 kB  00:00     
(4/11): rubygem-io-console-0.4.2-16.fc20.x86_64.rpm         |  48 kB  00:00     
(5/11): rubygem-json-1.7.7-101.fc20.x86_64.rpm              |  60 kB  00:00     
(6/11): rubygem-psych-2.0.0-16.fc20.x86_64.rpm              |  75 kB  00:00     
(7/11): rubypick-1.1.1-1.fc20.noarch.rpm                    | 6.3 kB  00:00     
(8/11): rubygem-bigdecimal-1.2.0-16.fc20.x86_64.rpm         |  77 kB  00:01     
(9/11): rubygem-rdoc-4.0.1-2.fc20.noarch.rpm                | 288 kB  00:00     
(10/11): ruby-libs-2.0.0.353-16.fc20.x86_64.rpm             | 2.8 MB  00:01     
(11/11): rubygems-2.1.11-115.fc20.noarch.rpm                | 224 kB  00:01     
--------------------------------------------------------------------------------
Total                                              1.4 MB/s | 3.7 MB  00:02     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : ruby-libs-2.0.0.353-16.fc20.x86_64                          1/11 
  Installing : libyaml-0.1.6-2.fc20.x86_64                                 2/11 
  Installing : rubygem-bigdecimal-1.2.0-16.fc20.x86_64                     3/11 
  Installing : rubygem-json-1.7.7-101.fc20.x86_64                          4/11 
  Installing : rubygem-psych-2.0.0-16.fc20.x86_64                          5/11 
  Installing : rubygem-rdoc-4.0.1-2.fc20.noarch                            6/11 
  Installing : ruby-irb-2.0.0.353-16.fc20.noarch                           7/11 
  Installing : rubypick-1.1.1-1.fc20.noarch                                8/11 
  Installing : ruby-2.0.0.353-16.fc20.x86_64                               9/11 
  Installing : rubygems-2.1.11-115.fc20.noarch                            10/11 
  Installing : rubygem-io-console-0.4.2-16.fc20.x86_64                    11/11 
  Verifying  : rubygem-io-console-0.4.2-16.fc20.x86_64                     1/11 
  Verifying  : rubygem-rdoc-4.0.1-2.fc20.noarch                            2/11 
  Verifying  : rubygems-2.1.11-115.fc20.noarch                             3/11 
  Verifying  : rubygem-bigdecimal-1.2.0-16.fc20.x86_64                     4/11 
  Verifying  : ruby-libs-2.0.0.353-16.fc20.x86_64                          5/11 
  Verifying  : rubygem-json-1.7.7-101.fc20.x86_64                          6/11 
  Verifying  : rubygem-psych-2.0.0-16.fc20.x86_64                          7/11 
  Verifying  : rubypick-1.1.1-1.fc20.noarch                                8/11 
  Verifying  : ruby-2.0.0.353-16.fc20.x86_64                               9/11 
  Verifying  : libyaml-0.1.6-2.fc20.x86_64                                10/11 
  Verifying  : ruby-irb-2.0.0.353-16.fc20.noarch                          11/11 
 
Installed:
  ruby.x86_64 0:2.0.0.353-16.fc20                                               
 
Dependency Installed:
  libyaml.x86_64 0:0.1.6-2.fc20                                                 
  ruby-irb.noarch 0:2.0.0.353-16.fc20                                           
  ruby-libs.x86_64 0:2.0.0.353-16.fc20                                          
  rubygem-bigdecimal.x86_64 0:1.2.0-16.fc20                                     
  rubygem-io-console.x86_64 0:0.4.2-16.fc20                                     
  rubygem-json.x86_64 0:1.7.7-101.fc20                                          
  rubygem-psych.x86_64 0:2.0.0-16.fc20                                          
  rubygem-rdoc.noarch 0:4.0.1-2.fc20                                            
  rubygems.noarch 0:2.1.11-115.fc20                                             
  rubypick.noarch 0:1.1.1-1.fc20                                                
 
Complete!

After you install ruby, you need to install the MySQL and Ruby development libraries, like this:

yum -y install gcc mysql-devel ruby-devel rubygems
Loaded plugins: langpacks, refresh-packagekit
Package gcc-4.8.3-7.fc20.x86_64 already installed and latest version
Package rubygems-2.1.11-115.fc20.noarch already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-devel.x86_64 0:5.6.24-1.fc20 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) = 5.6.24-1.fc20 for package: mysql-community-devel-5.6.24-1.fc20.x86_64
---> Package ruby-devel.x86_64 0:2.0.0.353-16.fc20 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.6.23-1.fc20 will be updated
--> Processing Dependency: mysql-community-libs(x86-64) = 5.6.23-1.fc20 for package: mysql-community-client-5.6.23-1.fc20.x86_64
---> Package mysql-community-libs.x86_64 0:5.6.24-1.fc20 will be an update
--> Processing Dependency: mysql-community-common(x86-64) = 5.6.24-1.fc20 for package: mysql-community-libs-5.6.24-1.fc20.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.6.23-1.fc20 will be updated
--> Processing Dependency: mysql-community-client(x86-64) = 5.6.23-1.fc20 for package: mysql-community-server-5.6.23-1.fc20.x86_64
---> Package mysql-community-client.x86_64 0:5.6.24-1.fc20 will be an update
---> Package mysql-community-common.x86_64 0:5.6.23-1.fc20 will be updated
---> Package mysql-community-common.x86_64 0:5.6.24-1.fc20 will be an update
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.6.23-1.fc20 will be updated
---> Package mysql-community-server.x86_64 0:5.6.24-1.fc20 will be an update
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package                 Arch    Version               Repository          Size
================================================================================
Installing:
 mysql-community-devel   x86_64  5.6.24-1.fc20         mysql56-community  3.4 M
 ruby-devel              x86_64  2.0.0.353-16.fc20     updates            125 k
Updating for dependencies:
 mysql-community-client  x86_64  5.6.24-1.fc20         mysql56-community   19 M
 mysql-community-common  x86_64  5.6.24-1.fc20         mysql56-community  258 k
 mysql-community-libs    x86_64  5.6.24-1.fc20         mysql56-community  2.0 M
 mysql-community-server  x86_64  5.6.24-1.fc20         mysql56-community   55 M
 
Transaction Summary
================================================================================
Install  2 Packages
Upgrade             ( 4 Dependent packages)
 
Total download size: 80 M
Downloading packages:
No Presto metadata available for mysql56-community
(1/6): mysql-community-common-5.6.24-1.fc20.x86_64.rpm      | 258 kB  00:01     
(2/6): mysql-community-devel-5.6.24-1.fc20.x86_64.rpm       | 3.4 MB  00:01     
(3/6): mysql-community-libs-5.6.24-1.fc20.x86_64.rpm        | 2.0 MB  00:00     
(4/6): ruby-devel-2.0.0.353-16.fc20.x86_64.rpm              | 125 kB  00:00     
(5/6): mysql-community-client-5.6.24-1.fc20.x86_64.rpm      |  19 MB  00:09     
(6/6): mysql-community-server-5.6.24-1.fc20.x86_64.rpm      |  55 MB  00:21     
--------------------------------------------------------------------------------
Total                                              3.3 MB/s |  80 MB  00:24     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Updating   : mysql-community-common-5.6.24-1.fc20.x86_64                 1/10 
  Updating   : mysql-community-libs-5.6.24-1.fc20.x86_64                   2/10 
  Updating   : mysql-community-client-5.6.24-1.fc20.x86_64                 3/10 
  Updating   : mysql-community-server-5.6.24-1.fc20.x86_64                 4/10 
  Installing : mysql-community-devel-5.6.24-1.fc20.x86_64                  5/10 
  Installing : ruby-devel-2.0.0.353-16.fc20.x86_64                         6/10 
  Cleanup    : mysql-community-server-5.6.23-1.fc20.x86_64                 7/10 
  Cleanup    : mysql-community-client-5.6.23-1.fc20.x86_64                 8/10 
  Cleanup    : mysql-community-libs-5.6.23-1.fc20.x86_64                   9/10 
  Cleanup    : mysql-community-common-5.6.23-1.fc20.x86_64                10/10 
  Verifying  : mysql-community-client-5.6.24-1.fc20.x86_64                 1/10 
  Verifying  : mysql-community-devel-5.6.24-1.fc20.x86_64                  2/10 
  Verifying  : ruby-devel-2.0.0.353-16.fc20.x86_64                         3/10 
  Verifying  : mysql-community-libs-5.6.24-1.fc20.x86_64                   4/10 
  Verifying  : mysql-community-common-5.6.24-1.fc20.x86_64                 5/10 
  Verifying  : mysql-community-server-5.6.24-1.fc20.x86_64                 6/10 
  Verifying  : mysql-community-client-5.6.23-1.fc20.x86_64                 7/10 
  Verifying  : mysql-community-server-5.6.23-1.fc20.x86_64                 8/10 
  Verifying  : mysql-community-libs-5.6.23-1.fc20.x86_64                   9/10 
  Verifying  : mysql-community-common-5.6.23-1.fc20.x86_64                10/10 
 
Installed:
  mysql-community-devel.x86_64 0:5.6.24-1.fc20                                  
  ruby-devel.x86_64 0:2.0.0.353-16.fc20                                         
 
Dependency Updated:
  mysql-community-client.x86_64 0:5.6.24-1.fc20                                 
  mysql-community-common.x86_64 0:5.6.24-1.fc20                                 
  mysql-community-libs.x86_64 0:5.6.24-1.fc20                                   
  mysql-community-server.x86_64 0:5.6.24-1.fc20                                 
 
Complete!

After installing ruby, exit the root account to your management account and run the following command from the Linux shell:

ruby -v

It should show you:

ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]

Before you can run gem to install rails, you must install another the libxml2-devel library. Here’s the syntax to install the libxml2-devel library:

yum install libxml2-devel

You should see the following, which includes typing a y to continue:

Loaded plugins: langpacks, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package libxml2-devel.x86_64 0:2.9.1-3.fc20 will be installed
--> Processing Dependency: zlib-devel for package: libxml2-devel-2.9.1-3.fc20.x86_64
--> Processing Dependency: xz-devel for package: libxml2-devel-2.9.1-3.fc20.x86_64
--> Running transaction check
---> Package xz-devel.x86_64 0:5.1.2-12alpha.fc20 will be installed
---> Package zlib-devel.x86_64 0:1.2.8-3.fc20 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package             Arch         Version                   Repository     Size
================================================================================
Installing:
 libxml2-devel       x86_64       2.9.1-3.fc20              updates       1.0 M
Installing for dependencies:
 xz-devel            x86_64       5.1.2-12alpha.fc20        updates        45 k
 zlib-devel          x86_64       1.2.8-3.fc20              fedora         50 k
 
Transaction Summary
================================================================================
Install  1 Package (+2 Dependent packages)
 
Total download size: 1.1 M
Installed size: 9.1 M
Is this ok [y/d/N]: y
Downloading packages:
(1/3): xz-devel-5.1.2-12alpha.fc20.x86_64.rpm               |  45 kB  00:00     
(2/3): zlib-devel-1.2.8-3.fc20.x86_64.rpm                   |  50 kB  00:00     
(3/3): libxml2-devel-2.9.1-3.fc20.x86_64.rpm                | 1.0 MB  00:04     
--------------------------------------------------------------------------------
Total                                              264 kB/s | 1.1 MB  00:04     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : zlib-devel-1.2.8-3.fc20.x86_64                               1/3 
  Installing : xz-devel-5.1.2-12alpha.fc20.x86_64                           2/3 
  Installing : libxml2-devel-2.9.1-3.fc20.x86_64                            3/3 
  Verifying  : xz-devel-5.1.2-12alpha.fc20.x86_64                           1/3 
  Verifying  : libxml2-devel-2.9.1-3.fc20.x86_64                            2/3 
  Verifying  : zlib-devel-1.2.8-3.fc20.x86_64                               3/3 
 
Installed:
  libxml2-devel.x86_64 0:2.9.1-3.fc20                                           
 
Dependency Installed:
  xz-devel.x86_64 0:5.1.2-12alpha.fc20     zlib-devel.x86_64 0:1.2.8-3.fc20    
 
Complete!
yum install libxslt-devel

You should see the following and will need to reply with a y during install:

Loaded plugins: langpacks, refresh-packagekit
mysql-connectors-community                                  | 2.5 kB  00:00     
mysql-tools-community                                       | 2.5 kB  00:00     
mysql56-community                                           | 2.5 kB  00:00     
pgdg93                                                      | 3.6 kB  00:00     
updates/20/x86_64/metalink                                  |  14 kB  00:00     
updates                                                     | 4.9 kB  00:00     
updates/20/x86_64/primary_db                                |  13 MB  00:07     
updates/20/x86_64/pkgtags      FAILED                                           
http://mirror.utexas.edu/fedora/linux/updates/20/x86_64/repodata/fe40e35e0289ae1470dbe8030c09b8046924cbaa5e16ac61e9411ac57477820b-pkgtags.sqlite.gz: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
(1/2): updates/20/x86_64/updateinfo                         | 1.9 MB  00:02     
(2/2): updates/20/x86_64/pkgtags                            | 1.4 MB  00:00     
Resolving Dependencies
--> Running transaction check
---> Package libxslt-devel.x86_64 0:1.1.28-5.fc20 will be installed
--> Processing Dependency: libgcrypt-devel for package: libxslt-devel-1.1.28-5.fc20.x86_64
--> Running transaction check
---> Package libgcrypt-devel.x86_64 0:1.5.3-2.fc20 will be installed
--> Processing Dependency: libgpg-error-devel for package: libgcrypt-devel-1.5.3-2.fc20.x86_64
--> Running transaction check
---> Package libgpg-error-devel.x86_64 0:1.12-1.fc20 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package                  Arch         Version               Repository    Size
================================================================================
Installing:
 libxslt-devel            x86_64       1.1.28-5.fc20         fedora       309 k
Installing for dependencies:
 libgcrypt-devel          x86_64       1.5.3-2.fc20          fedora       127 k
 libgpg-error-devel       x86_64       1.12-1.fc20           fedora        16 k
 
Transaction Summary
================================================================================
Install  1 Package (+2 Dependent packages)
 
Total download size: 451 k
Installed size: 2.6 M
Is this ok [y/d/N]: y
Downloading packages:
(1/3): libgcrypt-devel-1.5.3-2.fc20.x86_64.rpm              | 127 kB  00:00     
(2/3): libgpg-error-devel-1.12-1.fc20.x86_64.rpm            |  16 kB  00:00     
(3/3): libxslt-devel-1.1.28-5.fc20.x86_64.rpm               | 309 kB  00:00     
--------------------------------------------------------------------------------
Total                                              454 kB/s | 451 kB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : libgpg-error-devel-1.12-1.fc20.x86_64                        1/3 
  Installing : libgcrypt-devel-1.5.3-2.fc20.x86_64                          2/3 
  Installing : libxslt-devel-1.1.28-5.fc20.x86_64                           3/3 
  Verifying  : libgcrypt-devel-1.5.3-2.fc20.x86_64                          1/3 
  Verifying  : libgpg-error-devel-1.12-1.fc20.x86_64                        2/3 
  Verifying  : libxslt-devel-1.1.28-5.fc20.x86_64                           3/3 
 
Installed:
  libxslt-devel.x86_64 0:1.1.28-5.fc20                                          
 
Dependency Installed:
  libgcrypt-devel.x86_64 0:1.5.3-2.fc20 libgpg-error-devel.x86_64 0:1.12-1.fc20
 
Complete!

One more to go. You can’t run the Ruby gem utility to create the nokogiri Ruby Gem on Fedora because of a library mismatch. If you attempt to create the Rails framework, like this:

gem install rails

It’ll raise the following error message on trying to dynamically link the nokogiri Ruby Gem. The error will be something like this, and unfortunately, the log files won’t be too useful:

Running patch with /usr/local/share/gems/gems/nokogiri-1.6.6.2/ports/patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch...
Running 'patch' for libxml2 2.9.2... ERROR, review '/usr/local/share/gems/gems/nokogiri-1.6.6.2/ext/nokogiri/tmp/x86_64-redhat-linux-gnu/ports/libxml2/2.9.2/patch.log' to see what happened.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

The error message isn’t very helpful but the fix is fortunately easy. You install the nokogiri Ruby Gem directly with the yum utility. The following instructs yum to proceed without waiting for you to type a y to install.

yum install -y rubygem-nokogiri
Loaded plugins: langpacks, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package rubygem-nokogiri.x86_64 0:1.6.6.2-1.fc20 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package                Arch         Version                Repository     Size
================================================================================
Installing:
 rubygem-nokogiri       x86_64       1.6.6.2-1.fc20         updates       534 k
 
Transaction Summary
================================================================================
Install  1 Package
 
Total download size: 534 k
Installed size: 834 k
Downloading packages:
rubygem-nokogiri-1.6.6.2-1.fc20.x86_64.rpm                  | 534 kB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : rubygem-nokogiri-1.6.6.2-1.fc20.x86_64                       1/1 
  Verifying  : rubygem-nokogiri-1.6.6.2-1.fc20.x86_64                       1/1 
 
Installed:
  rubygem-nokogiri.x86_64 0:1.6.6.2-1.fc20                                      
 
Complete!

Now you can use the Ruby gem utility to create the Rails framework like this:

gem install rails

This will take a couple minutes typically, so be patient. You see something like this, dependent on the release:

Fetching: loofah-2.0.1.gem (100%)
Successfully installed loofah-2.0.1
Fetching: rails-html-sanitizer-1.0.2.gem (100%)
Successfully installed rails-html-sanitizer-1.0.2
Fetching: rails-deprecated_sanitizer-1.0.3.gem (100%)
Successfully installed rails-deprecated_sanitizer-1.0.3
Fetching: rails-dom-testing-1.0.6.gem (100%)
Successfully installed rails-dom-testing-1.0.6
Fetching: builder-3.2.2.gem (100%)
Successfully installed builder-3.2.2
Fetching: erubis-2.7.0.gem (100%)
Successfully installed erubis-2.7.0
Fetching: actionview-4.2.1.gem (100%)
Successfully installed actionview-4.2.1
Fetching: actionpack-4.2.1.gem (100%)
Successfully installed actionpack-4.2.1
Fetching: activemodel-4.2.1.gem (100%)
Successfully installed activemodel-4.2.1
Fetching: arel-6.0.0.gem (100%)
Successfully installed arel-6.0.0
Fetching: activerecord-4.2.1.gem (100%)
Successfully installed activerecord-4.2.1
Fetching: globalid-0.3.5.gem (100%)
Successfully installed globalid-0.3.5
Fetching: activejob-4.2.1.gem (100%)
Successfully installed activejob-4.2.1
Fetching: mime-types-2.4.3.gem (100%)
Successfully installed mime-types-2.4.3
Fetching: mail-2.6.3.gem (100%)
Successfully installed mail-2.6.3
Fetching: actionmailer-4.2.1.gem (100%)
Successfully installed actionmailer-4.2.1
Fetching: rake-10.4.2.gem (100%)
Successfully installed rake-10.4.2
Fetching: thor-0.19.1.gem (100%)
Successfully installed thor-0.19.1
Fetching: railties-4.2.1.gem (100%)
Successfully installed railties-4.2.1
Fetching: bundler-1.9.2.gem (100%)
Successfully installed bundler-1.9.2
Fetching: hike-1.2.3.gem (100%)
Successfully installed hike-1.2.3
Fetching: multi_json-1.11.0.gem (100%)
Successfully installed multi_json-1.11.0
Fetching: tilt-1.4.1.gem (100%)
Successfully installed tilt-1.4.1
Fetching: sprockets-2.12.3.gem (100%)
Successfully installed sprockets-2.12.3
Fetching: sprockets-rails-2.2.4.gem (100%)
Successfully installed sprockets-rails-2.2.4
Fetching: rails-4.2.1.gem (100%)
Successfully installed rails-4.2.1
Parsing documentation for actionmailer-4.2.1
Installing ri documentation for actionmailer-4.2.1
Parsing documentation for actionpack-4.2.1
Installing ri documentation for actionpack-4.2.1
Parsing documentation for actionview-4.2.1
Installing ri documentation for actionview-4.2.1
Parsing documentation for activejob-4.2.1
Installing ri documentation for activejob-4.2.1
Parsing documentation for activemodel-4.2.1
Installing ri documentation for activemodel-4.2.1
Parsing documentation for activerecord-4.2.1
Installing ri documentation for activerecord-4.2.1
Parsing documentation for arel-6.0.0
Installing ri documentation for arel-6.0.0
Parsing documentation for builder-3.2.2
Installing ri documentation for builder-3.2.2
Parsing documentation for bundler-1.9.2
Installing ri documentation for bundler-1.9.2
Parsing documentation for erubis-2.7.0
Installing ri documentation for erubis-2.7.0
Parsing documentation for globalid-0.3.5
Installing ri documentation for globalid-0.3.5
Parsing documentation for hike-1.2.3
Installing ri documentation for hike-1.2.3
Parsing documentation for loofah-2.0.1
Installing ri documentation for loofah-2.0.1
Parsing documentation for mail-2.6.3
Installing ri documentation for mail-2.6.3
Parsing documentation for mime-types-2.4.3
Installing ri documentation for mime-types-2.4.3
Parsing documentation for multi_json-1.11.0
Installing ri documentation for multi_json-1.11.0
Parsing documentation for rails-4.2.1
Installing ri documentation for rails-4.2.1
Parsing documentation for rails-deprecated_sanitizer-1.0.3
Installing ri documentation for rails-deprecated_sanitizer-1.0.3
Parsing documentation for rails-dom-testing-1.0.6
Installing ri documentation for rails-dom-testing-1.0.6
Parsing documentation for rails-html-sanitizer-1.0.2
Installing ri documentation for rails-html-sanitizer-1.0.2
Parsing documentation for railties-4.2.1
Installing ri documentation for railties-4.2.1
Parsing documentation for rake-10.4.2
Installing ri documentation for rake-10.4.2
Parsing documentation for sprockets-2.12.3
Installing ri documentation for sprockets-2.12.3
Parsing documentation for sprockets-rails-2.2.4
Installing ri documentation for sprockets-rails-2.2.4
Parsing documentation for thor-0.19.1
Installing ri documentation for thor-0.19.1
Parsing documentation for tilt-1.4.1
Installing ri documentation for tilt-1.4.1
Done installing documentation for actionmailer, actionpack, actionview, activejob, activemodel, activerecord, arel, builder, bundler, erubis, globalid, hike, loofah, mail, mime-types, multi_json, rails, rails-deprecated_sanitizer, rails-dom-testing, rails-html-sanitizer, railties, rake, sprockets, sprockets-rails, thor, tilt after 475 seconds
26 gems installed

If you want to install Phusion Passenger, mod_passenger is already installed. You should note that support and testing for this stops at Fedora V17. You can verify installation with the following command:

yum list mod_passenger

It returns:

Loaded plugins: langpacks, refresh-packagekit
Available Packages
mod_passenger.x86_64                   4.0.53-3.fc20.2                   updates

You can also install the Ruby Gem for Passenger, like this:

gem install passenger

It should take less than 2 minutes and return something like this:

Fetching: passenger-5.0.6.gem (100%)
Building native extensions.  This could take a while...
Successfully installed passenger-5.0.6
Parsing documentation for passenger-5.0.6
Installing ri documentation for passenger-5.0.6
Done installing documentation for passenger after 9 seconds
1 gem installed

As always, I hope this was helpful. I’ll add a post with the remaining MySQL and Oracle connection details soon.

Written by maclochlainn

April 10th, 2015 at 2:28 am

MySQL bind-address

without comments

While I try to keep things simple, sometimes eliminating options and explanations comes back to haunt me. After posting how to open a Fedora firewall port for a LAMP stack, somebody got trapped by my instructions for installing MySQL on Fedora. They got stuck because they had the following setting in their /etc/my.cnf file:

bind-address=localhost.localdomain

I’d suggested using that bind-address value for a DHCP VMware Fedora installation in Step #7. I was trying to create an example for an isolated testing instance, which is why I set the bind-address to a localhost.localdomain value. They raised the following error when they tried to connect their base operating system’s version of MySQL Workstation to the Fedora VM:

Failed to Connect to MySQL at 192.168.2.168:3306 with user student

or, this dialog image:

MySQLBindAddr01

Before you do the next step, please ensure you’re using the right IP address. You can find that by running this command as an authorized sudoer:

ifconfig | grep inet.*netmask.*broadcast

In this case, the command returns:

        inet 192.168.2.168  netmask 255.255.255.0  broadcast 192.168.2.255

I’ve since added instructions to the older post to set the bind-address value in the my.cnf file as follows when they want to support external connections (naturally that means authorizing port 3306):

bind-address=0.0.0.0

After you reset the /etc/my.cnf file, you must stop and start, or restart the mysqld service. You can do that as the root user like this:

systemctl restart mysqld

Then, you can test a student user connection from MySQL Workbench like this:

MySQLBindAddr02

If the student user is authorized and the password is correct, you’ll see that the connection now works:

MySQLBindAddr03

As always, I hope this helps those working through similar issues.

Written by maclochlainn

March 29th, 2015 at 10:30 pm

Open Fedora Port 80

with 4 comments

After installing the LAMP stack on Fedora, you need to open port 80 in the Firewall to access the PHP programs on the Fedora instance from external servers. You can open a firewall port by launching the firewall-config application as the root user with the following syntax:

firewall-config

The firewall-config utility opens the following dialog:

FedoraFirewall1

Click on the Ports tab, and you’ll see the following:

FedoraFirewall2

Skip this step if you only want to set the runtime privilege to the port. Click on the Runtime tab and change it to Permanent if you want the port to be accessible when you reboot your OS.

FedoraFirewallPermanent

Click on Add button to add a port exception, and you’ll see the following:

FedoraFirewall3

Enter Port 80 for the Apache server unless you used a different value for the Apache server’s listener port. If you’re not sure open the /etc/httpd/conf/httpd.conf file and check for the following line (default value shown):

Listen 80

Click the OK button to set the port exception. Then, you can connect to the Linux machine with the IP address, a DNS name, or a name you resolve in your local hosts file, like:

http://192.168.2.1/query.php

You can find the IP address of your Fedora image by inspecting the /etc/hosts file or capture a DHCP assigned address with the following command as the root user (or with sudo as a valid sudoer user):

ifconfig -a

It should return the following image, which is based on the data stored in MySQL’s studentdb database, as qualified in yesterday’s blog post:

ExternalWebPage

I hope this helps those setting up a LAMP instance to work with the MySQL database.

Written by maclochlainn

March 29th, 2015 at 12:35 am

Fedora Install LAMP

with 11 comments

My students wanted an extra credit assignment, so I thought a LAMP configuration and test would be appropriate. The only problem was I hadn’t added it to their course VMware instance. So, here are the instructions to install Apache2, PHP, and MySQLi for a complete LAMP stack when MySQL is already installed.

The post builds on my Fedora Install of MySQL and MySQL Workbench on Fedora posts from last year. It also presumes that you’ve installed a studentdb database but you need to know how to do that let me know (but it hasn’t changed much from the example at the bottom of this old MySQL 5.1 blog post).

You install Apache2 with the following command as the root user, or with the sudo command as a sudoer-list user:

yum install httpd

The following displays the results of starting the yum utility to install httpd, and you need to reply with a y to complete the installation:

Loaded plugins: langpacks, refresh-packagekit
mysql-connectors-community                                  | 2.5 kB  00:00     
mysql-tools-community                                       | 2.5 kB  00:00     
mysql56-community                                           | 2.5 kB  00:00     
pgdg93                                                      | 3.6 kB  00:00     
updates/20/x86_64/metalink                                  |  16 kB  00:00     
updates                                                     | 4.9 kB  00:00     
updates/20/x86_64/primary_db                                |  13 MB  00:04     
(1/2): updates/20/x86_64/updateinfo                         | 1.9 MB  00:02     
(2/2): updates/20/x86_64/pkgtags                            | 1.4 MB  00:01     
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.10-2.fc20 will be installed
--> Processing Dependency: httpd-tools = 2.4.10-2.fc20 for package: httpd-2.4.10-2.fc20.x86_64
--> Processing Dependency: system-logos-httpd for package: httpd-2.4.10-2.fc20.x86_64
--> Running transaction check
---> Package fedora-logos-httpd.noarch 0:21.0.1-1.fc20 will be installed
---> Package httpd-tools.x86_64 0:2.4.10-2.fc20 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package                  Arch         Version              Repository     Size
================================================================================
Installing:
 httpd                    x86_64       2.4.10-2.fc20        updates       1.2 M
Installing for dependencies:
 fedora-logos-httpd       noarch       21.0.1-1.fc20        fedora         28 k
 httpd-tools              x86_64       2.4.10-2.fc20        updates        79 k
 
Transaction Summary
================================================================================
Install  1 Package (+2 Dependent packages)
 
Total download size: 1.3 M
Installed size: 4.0 M
Is this ok [y/d/N]: y
Downloading packages:
(1/3): fedora-logos-httpd-21.0.1-1.fc20.noarch.rpm          |  28 kB  00:00     
(2/3): httpd-2.4.10-2.fc20.x86_64.rpm                       | 1.2 MB  00:01     
(3/3): httpd-tools-2.4.10-2.fc20.x86_64.rpm                 |  79 kB  00:00     
--------------------------------------------------------------------------------
Total                                              815 kB/s | 1.3 MB  00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : httpd-tools-2.4.10-2.fc20.x86_64                             1/3 
  Installing : fedora-logos-httpd-21.0.1-1.fc20.noarch                      2/3 
  Installing : httpd-2.4.10-2.fc20.x86_64                                   3/3 
  Verifying  : httpd-2.4.10-2.fc20.x86_64                                   1/3 
  Verifying  : fedora-logos-httpd-21.0.1-1.fc20.noarch                      2/3 
  Verifying  : httpd-tools-2.4.10-2.fc20.x86_64                             3/3 
 
Installed:
  httpd.x86_64 0:2.4.10-2.fc20                                                  
 
Dependency Installed:
  fedora-logos-httpd.noarch 0:21.0.1-1.fc20  httpd-tools.x86_64 0:2.4.10-2.fc20 
 
Complete!

Next, you install php as the root user with the following command:

yum install php

The following displays when you install php, and you need to reply with a y to complete the installation:

Loaded plugins: langpacks, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package php.x86_64 0:5.5.22-1.fc20 will be installed
--> Processing Dependency: php-common(x86-64) = 5.5.22-1.fc20 for package: php-5.5.22-1.fc20.x86_64
--> Processing Dependency: php-cli(x86-64) = 5.5.22-1.fc20 for package: php-5.5.22-1.fc20.x86_64
--> Running transaction check
---> Package php-cli.x86_64 0:5.5.22-1.fc20 will be installed
---> Package php-common.x86_64 0:5.5.22-1.fc20 will be installed
--> Processing Dependency: php-pecl-jsonc(x86-64) for package: php-common-5.5.22-1.fc20.x86_64
--> Running transaction check
---> Package php-pecl-jsonc.x86_64 0:1.3.6-1.fc20 will be installed
--> Processing Dependency: /usr/bin/pecl for package: php-pecl-jsonc-1.3.6-1.fc20.x86_64
--> Processing Dependency: /usr/bin/pecl for package: php-pecl-jsonc-1.3.6-1.fc20.x86_64
--> Running transaction check
---> Package php-pear.noarch 1:1.9.5-6.fc20 will be installed
--> Processing Dependency: php-xml for package: 1:php-pear-1.9.5-6.fc20.noarch
--> Processing Dependency: php-posix for package: 1:php-pear-1.9.5-6.fc20.noarch
--> Running transaction check
---> Package php-process.x86_64 0:5.5.22-1.fc20 will be installed
---> Package php-xml.x86_64 0:5.5.22-1.fc20 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package               Arch          Version               Repository      Size
================================================================================
Installing:
 php                   x86_64        5.5.22-1.fc20         updates        2.6 M
Installing for dependencies:
 php-cli               x86_64        5.5.22-1.fc20         updates        3.9 M
 php-common            x86_64        5.5.22-1.fc20         updates        1.0 M
 php-pear              noarch        1:1.9.5-6.fc20        updates        343 k
 php-pecl-jsonc        x86_64        1.3.6-1.fc20          updates         34 k
 php-process           x86_64        5.5.22-1.fc20         updates         77 k
 php-xml               x86_64        5.5.22-1.fc20         updates        247 k
 
Transaction Summary
================================================================================
Install  1 Package (+6 Dependent packages)
 
Total download size: 8.2 M
Installed size: 32 M
Is this ok [y/d/N]: y
Downloading packages:
(1/7): php-5.5.22-1.fc20.x86_64.rpm                         | 2.6 MB  00:03     
(2/7): php-cli-5.5.22-1.fc20.x86_64.rpm                     | 3.9 MB  00:03     
(3/7): php-common-5.5.22-1.fc20.x86_64.rpm                  | 1.0 MB  00:00     
(4/7): php-pear-1.9.5-6.fc20.noarch.rpm                     | 343 kB  00:00     
(5/7): php-pecl-jsonc-1.3.6-1.fc20.x86_64.rpm               |  34 kB  00:00     
(6/7): php-process-5.5.22-1.fc20.x86_64.rpm                 |  77 kB  00:00     
(7/7): php-xml-5.5.22-1.fc20.x86_64.rpm                     | 247 kB  00:00     
--------------------------------------------------------------------------------
Total                                              1.1 MB/s | 8.2 MB  00:07     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : php-cli-5.5.22-1.fc20.x86_64                                 1/7 
  Installing : php-process-5.5.22-1.fc20.x86_64                             2/7 
  Installing : php-xml-5.5.22-1.fc20.x86_64                                 3/7 
  Installing : 1:php-pear-1.9.5-6.fc20.noarch                               4/7 
  Installing : php-common-5.5.22-1.fc20.x86_64                              5/7 
  Installing : php-pecl-jsonc-1.3.6-1.fc20.x86_64                           6/7 
  Installing : php-5.5.22-1.fc20.x86_64                                     7/7 
  Verifying  : php-5.5.22-1.fc20.x86_64                                     1/7 
  Verifying  : php-common-5.5.22-1.fc20.x86_64                              2/7 
  Verifying  : php-cli-5.5.22-1.fc20.x86_64                                 3/7 
  Verifying  : 1:php-pear-1.9.5-6.fc20.noarch                               4/7 
  Verifying  : php-process-5.5.22-1.fc20.x86_64                             5/7 
  Verifying  : php-xml-5.5.22-1.fc20.x86_64                                 6/7 
  Verifying  : php-pecl-jsonc-1.3.6-1.fc20.x86_64                           7/7 
 
Installed:
  php.x86_64 0:5.5.22-1.fc20                                                    
 
Dependency Installed:
  php-cli.x86_64 0:5.5.22-1.fc20        php-common.x86_64 0:5.5.22-1.fc20      
  php-pear.noarch 1:1.9.5-6.fc20        php-pecl-jsonc.x86_64 0:1.3.6-1.fc20   
  php-process.x86_64 0:5.5.22-1.fc20    php-xml.x86_64 0:5.5.22-1.fc20         
 
Complete!

After installing the software, you can set the Apache server to start automatically with the following command:

chkconfig httpd on

However, that command only starts the Apache server the next time you boot the server. You use the following command as the root user to start the Apache server:

apachectl start

You can verify the installation with the following command as the root user:

ps -ef | grep httpd | grep -v grep

It should return:

root      5433     1  0 17:03 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache    5434  5433  0 17:03 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache    5435  5433  0 17:03 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache    5436  5433  0 17:03 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache    5437  5433  0 17:03 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache    5438  5433  0 17:03 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache    5442  5433  0 17:03 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND

and, then verify the listening port with the following command as the root user:

netstat -tulpn | grep :80

It should return the following when both the Apache server is listening on port 80 and the Oracle multi-protocol server is listening on port 8080:

tcp6       0      0 :::80                   :::*                    LISTEN      5433/httpd          
tcp6       0      0 :::8080                 :::*                    LISTEN      1505/tnslsnr

After verifying the connection, you can test it by creating the traditional info.php program file in the /var/www/http directory. The file should contain the following:

1
2
3
<?php
  phpinfo();
?>

You can test it by opening the Firefox browser and entering the following URL from the Fedora Linux image:

http://localhost/info.php

It should display the typical diagnostic page. This verifies the configuration of the Apache and PHP servers. The next step verifies whether you have the mysqli library to connect to the MySQL database.

You create a mysqli_check.php script, like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<html>
<header>
<title>Static Query Object Sample</title>
<style type="text/css">
  /* HTML element styles. */
  table {background:white;border-style:solid;border-width:3px;border-color:black;border-collapse:collapse;}
  th {text-align:center;font-style:bold;background:lightgray;border:solid 1px gray;}
  td {border:solid 1px gray;}
 
  /* Class tag element styles. */
  .ID {min-width:50px;text-align:right;}
  .Label {min-width:200px;text-align:left;}
</style>
</header>
<body>
<?php
  if (!function_exists('mysqli_init') && !extension_loaded('mysqli')) {
    print 'mysqli not installed.'; }
  else {
    print 'mysqli installed.'; }
?>
</script>
</body>
</html>

You can test it with the following URL from the local browser:

http://localhost/mysqli_check.php

If it’s installed you can skip the next step, but if not you need to run yum in expert mode as follows (the check for php-mysql isn’t really necessary because it’s too old a version but good practice):

[root@localhost etc]# yum shell
Loaded plugins: langpacks, refresh-packagekit
> remove php-mysql
No Match for argument: php-mysql
> install php-mysqlnd
> run
--> Running transaction check
---> Package php-mysqlnd.x86_64 0:5.5.22-1.fc20 will be installed
--> Processing Dependency: php-pdo(x86-64) = 5.5.22-1.fc20 for package: php-mysqlnd-5.5.22-1.fc20.x86_64
--> Running transaction check
---> Package php-pdo.x86_64 0:5.5.22-1.fc20 will be installed
--> Finished Dependency Resolution
 
================================================================================
 Package             Arch           Version               Repository       Size
================================================================================
Installing:
 php-mysqlnd         x86_64         5.5.22-1.fc20         updates         293 k
Installing for dependencies:
 php-pdo             x86_64         5.5.22-1.fc20         updates         141 k
 
Transaction Summary
================================================================================
Install  1 Package (+1 Dependent package)
 
Total download size: 433 k
Installed size: 1.4 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): php-mysqlnd-5.5.22-1.fc20.x86_64.rpm                 | 293 kB  00:00     
(2/2): php-pdo-5.5.22-1.fc20.x86_64.rpm                     | 141 kB  00:00     
--------------------------------------------------------------------------------
Total                                              427 kB/s | 433 kB  00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : php-pdo-5.5.22-1.fc20.x86_64                                 1/2 
  Installing : php-mysqlnd-5.5.22-1.fc20.x86_64                             2/2 
  Verifying  : php-pdo-5.5.22-1.fc20.x86_64                                 1/2 
  Verifying  : php-mysqlnd-5.5.22-1.fc20.x86_64                             2/2 
 
Installed:
  php-mysqlnd.x86_64 0:5.5.22-1.fc20                                            
 
Dependency Installed:
  php-pdo.x86_64 0:5.5.22-1.fc20                                                
 
Finished Transaction
> quit

You should note that this also installed PDO. One caveat, before you rerun the mysqli_check.php script from a browser, you need to restart the Apache server. You can do that as the root user with the following syntax:

apachectl restart

You can retest it with the following URL from the local browser:

http://localhost/mysqli_check.php

At this point you should have everything installed to test your connection the MySQL database. As mentioned, this example extends my instructions for installing MySQL on the Fedora instance.

The following query.php file tests your ability to connect to the MySQL database with the mysqli driver, and it uses the studentdb and video store example from my Oracle Database 11g and MySQL 5.6 Developer Handbook:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<html>
<header>
<title>Static Query Object Sample</title>
<style type="text/css">
  /* HTML element styles. */
  table {background:white;border-style:solid;border-width:3px;border-color:black;border-collapse:collapse;}
  th {text-align:center;font-style:bold;background:lightgray;border:solid 1px gray;}
  td {border:solid 1px gray;}
 
  /* Class tag element styles. */
  .ID {min-width:50px;text-align:right;}
  .Label {min-width:200px;text-align:left;}
</style>
</header>
<body>
<?php
  // Assign credentials to connection.
  $mysqli = new mysqli("localhost", "student", "student", "studentdb");
 
  // Check for connection error and print message.
  if ($mysqli->connect_errno) {
    print $mysqli->connect_error."<br />";
    print "Connection not established ...<br />";
  }
  else {
 
    // Declare a static query.
    $query = "SELECT au.system_user_id, au.system_user_name FROM system_user au" ;
 
    // Loop through a result set until completed.  
    do {
 
      // Attempt query and exit with failure before processing.
      if (!$stmt = $mysqli->query($query)) {
 
        // Print failure to resolve query message.
        print $mysqli->error."<br />";
        print "Failed to resolve query ...<br />";
      }     
      else {
 
        // Print the opening HTML table tag.
        print '<table><tr><th class="ID">ID</th><th class="Label">User Role Name</th></tr>';
 
        // Fetch a row for processing.
        while( $row = $stmt->fetch_row() ) {
 
          // Print the opening HTML row tag.
          print "<tr>";
 
          // Loop through the row's columns.
          for ($i = 0;$i < $mysqli->field_count;$i++) {
            // Handle column one differently.
            if ($i == 0)
              print '<td class="ID">'.$row[$i]."</td>";
            else
              print '<td class="Label">'.$row[$i]."</td>";
          }
          // Print the closing HTML row tag.
          print "</tr>"; 
        }
      }
    } while( $mysqli->next_result());
 
  // Print the closing HTML table tag.
  print "</table>"; 
 
  // Release connection resource.
  $mysqli->close(); }
?>
</script>
</body>
</html>

This should display the following in the browser:

FedoraConfigMySQLPHP

You can see how to open port 80 for the Apache server in this blog post. If you want to work with blob data types, you’ll also need to use yum to install the php-gd library. You can read my LAMP php-gd library blog post to learn how to install the libraries. As always, I hope a step-by-step approach without assumptions helps those learning MySQL.

Written by maclochlainn

March 28th, 2015 at 7:41 pm

Add Color to VIM?

without comments

In Fedora 20, documents have no color coding when you edit them with vi or vim. That’s because Fedora installs vim-minimal by default. You can check what’s running with the following command at a shell prompt in the terminal:

rpm -qa | grep vim

It should print the following to console:

vim-minimal-7.4.179-1.fc20.x86_64

You can download and install vim with the enhanced version by using the following syntax:

sudo yum install vim-enhanced
Loaded plugins: langpacks, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package vim-enhanced.x86_64 2:7.4.417-1.fc20 will be installed
--> Processing Dependency: vim-common = 2:7.4.417-1.fc20 for package: 2:vim-enhanced-7.4.417-1.fc20.x86_64
--> Processing Dependency: libgpm.so.2()(64bit) for package: 2:vim-enhanced-7.4.417-1.fc20.x86_64
--> Running transaction check
---> Package gpm-libs.x86_64 0:1.20.7-3.fc20 will be installed
---> Package vim-common.x86_64 2:7.4.417-1.fc20 will be installed
--> Processing Dependency: vim-filesystem for package: 2:vim-common-7.4.417-1.fc20.x86_64
--> Running transaction check
---> Package vim-filesystem.x86_64 2:7.4.417-1.fc20 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package              Arch         Version                  Repository     Size
================================================================================
Installing:
 vim-enhanced         x86_64       2:7.4.417-1.fc20         updates       1.0 M
Installing for dependencies:
 gpm-libs             x86_64       1.20.7-3.fc20            fedora         32 k
 vim-common           x86_64       2:7.4.417-1.fc20         updates       5.9 M
 vim-filesystem       x86_64       2:7.4.417-1.fc20         updates        11 k
 
Transaction Summary
================================================================================
Install  1 Package (+3 Dependent packages)
 
Total download size: 7.0 M
Installed size: 23 M
Is this ok [y/d/N]: y
Downloading packages:
(1/4): gpm-libs-1.20.7-3.fc20.x86_64.rpm                    |  32 kB  00:00     
(2/4): vim-enhanced-7.4.417-1.fc20.x86_64.rpm               | 1.0 MB  00:03     
(3/4): vim-filesystem-7.4.417-1.fc20.x86_64.rpm             |  11 kB  00:03     
(4/4): vim-common-7.4.417-1.fc20.x86_64.rpm                 | 5.9 MB  00:05     
--------------------------------------------------------------------------------
Total                                              1.3 MB/s | 7.0 MB  00:05     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 2:vim-filesystem-7.4.417-1.fc20.x86_64                       1/4 
  Installing : 2:vim-common-7.4.417-1.fc20.x86_64                           2/4 
  Installing : gpm-libs-1.20.7-3.fc20.x86_64                                3/4 
  Installing : 2:vim-enhanced-7.4.417-1.fc20.x86_64                         4/4 
  Verifying  : gpm-libs-1.20.7-3.fc20.x86_64                                1/4 
  Verifying  : 2:vim-common-7.4.417-1.fc20.x86_64                           2/4 
  Verifying  : 2:vim-enhanced-7.4.417-1.fc20.x86_64                         3/4 
  Verifying  : 2:vim-filesystem-7.4.417-1.fc20.x86_64                       4/4 
 
Installed:
  vim-enhanced.x86_64 2:7.4.417-1.fc20                                          
 
Dependency Installed:
  gpm-libs.x86_64 0:1.20.7-3.fc20          vim-common.x86_64 2:7.4.417-1.fc20  
  vim-filesystem.x86_64 2:7.4.417-1.fc20  
 
Complete!

You can now type vim to edit files in color but vi will still be in black and white.

Written by maclochlainn

September 13th, 2014 at 2:06 am

Posted in Fedora,Linux,vim

Wrapping SQL*Plus

without comments

One annoying thing from installing Oracle Database 11g on Fedora, was that the up arrows for command history didn’t work. I decided to fix that today after seeing Lutz Hartmann’s article on rlwrap. Unfortunately, the epel (Extra Packages for Enterprise Linux) package he recommended doesn’t run on Fedora 20. You can read my tale of woe, or skip to the .bashrc function that fixed it when I installed only rlwrap.

Attempting it on yum, gave me these errors:

# yum install http://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
Loaded plugins: langpacks, refresh-packagekit
epel-release-6-8.noarch.rpm                                 |  14 kB  00:00     
Examining /var/tmp/yum-root-5CLTPa/epel-release-6-8.noarch.rpm: epel-release-6-8.noarch
Marking /var/tmp/yum-root-5CLTPa/epel-release-6-8.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:6-8 will be installed
--> Processing Conflict: epel-release-6-8.noarch conflicts fedora-release
No package matched to upgrade: epel-release
--> Finished Dependency Resolution
Error: epel-release conflicts with fedora-release-20-3.noarch
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles –nodigest

Poking around for an epel fix wasn’t successful, so I chose to install only the rlwrap package. Here’s that command and log file:

[root@localhost ~]# yum install rlwrap 
Loaded plugins: langpacks, protectbase, refresh-packagekit
0 packages excluded due to repository protections
Resolving Dependencies
--> Running transaction check
---> Package rlwrap.x86_64 0:0.41-1.fc20 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package         Arch            Version                 Repository        Size
================================================================================
Installing:
 rlwrap          x86_64          0.41-1.fc20             updates           95 k
 
Transaction Summary
================================================================================
Install  1 Package
 
Total download size: 95 k
Installed size: 204 k
Is this ok [y/d/N]: y
Downloading packages:
rlwrap-0.41-1.fc20.x86_64.rpm                               |  95 kB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : rlwrap-0.41-1.fc20.x86_64                                    1/1 
  Verifying  : rlwrap-0.41-1.fc20.x86_64                                    1/1 
 
Installed:
  rlwrap.x86_64 0:0.41-1.fc20                                                   
Complete!

The next step was getting it to work. A sqlplus function wrapper inside the .bashrc file seemed the easiest. Here’s the code to the .bashrc file:

# .bashrc
 
# Source global definitions
if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi
 
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
 
# User specific aliases and functions
. /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
 
# Wrap sqlplus with rlwrap to edit prior lines.
sqlplus()
{
  if [ "$RLWRAP" = "0" ]; then
    sqlplus "$@"
  else
    rlwrap sqlplus "$@"
  fi
}
 
# Set vi as a command line editor.
set -o vi

As always, I hope this helps some folks.

Written by maclochlainn

August 20th, 2014 at 6:58 pm

Fedora VMWare Upgrade

with 2 comments

When a new update of VMWare comes out, and it is time to upgrade VMWare Tools. Here’s an update on the instructions for upgrading VMWare Tools 6.0.1 through 6.0.4:

  1. Navigate to the VMWare Menu, choose Virtual Machine and in the drop down menu Install VMWare Tools. This will mount a virtual CD in the Oracle Unbreakable Linux virtual machine and it launches the following dialog box:
VMware962

  1. Open a terminal session by right clicking anywhere in the desktop, and then choose Open in Terminal from the context menu. You can then run the VMWare Toolkit by following these instructions as the root user:

The instructions for VMWare 6.0.0 through 6.0.2 are:

cd /media/VMware\ Tools
cp VMwareTools-9.6.2-1688356.tar.gz /tmp
cd /tmp
gunzip VMwareTools-9.6.2-1688356.tar.gz
tar -xvf VMwareTools-9.6.2-1688356.tar
cd vmware-tools-distrib
sudo ./vmware-install.pl

VMWare changed where the VMWare Tools CD are mounted. You can discover it by clicking on the VMware Tools in the left pane (this assumes you log on to Fedora as the student user, and the student user is a sudo-enabled user)

VMWare6.0.4

The instructions for VMWare Tools 6.0.4 forward are listed below. Only the first command changes. You should also note that the VMWare Tools library is the same:

cd /run/media/student/VMware\ Tools
cp VMwareTools-9.6.2-1688356.tar.gz /tmp
cd /tmp
gunzip VMwareTools-9.6.2-1688356.tar.gz
tar -xvf VMwareTools-9.6.2-1688356.tar
cd vmware-tools-distrib
sudo ./vmware-install.pl

The last step requires that you reply to a set of prompts. If you’d like to accept the default at one time, you can use the following command:

sudo ./vmware-install.pl --default

Lastly, you’ll get these instructions form the Perl script that installs the VMWare tools:

The configuration of VMware Tools 9.6.2 build-1688356 for Linux for this 
running kernel completed successfully.
 
You must restart your X session before any mouse or graphics changes take 
effect.
 
You can now run VMware Tools by invoking "/usr/bin/vmware-toolbox-cmd" from the
command line.
 
To enable advanced X features (e.g., guest resolution fit, drag and drop, and 
file and text copy/paste), you will need to do one (or more) of the following:
1. Manually start /usr/bin/vmware-user
2. Log out and log back into your desktop session; and,
3. Restart your X session.
 
Enjoy,
 
--the VMware team

Written by maclochlainn

July 3rd, 2014 at 2:00 am

Posted in Fedora,Linux,VMWare

Tagged with , ,

A/UX, NeXTSTEP, & OS X

with 5 comments

One thing that gets tedious in the IT community and Oracle community is the penchant for Windows only solutions. While Microsoft does an excellent job in certain domains, I remain a loyal Apple customer. By the way, you can install Oracle Client software on Mac OS X and run SQL Developer against any Oracle Database server. You can even run MySQL Workbench and MySQL server natively on the Mac OS X platform, which creates a robust development platform and gives you more testing options with the MySQL monitor (the client software).

Notwithstanding, some Windows users appear to malign Apple and the Mac OS X on compatibility, but they don’t understand that it’s a derivative of the Research Unix, through BSD (Berkeley Software Distribution). This Unix lineage chart illustrates it well:

I’m probably loyal to Apple because in the early 1990’s I worked on Mac OS 6, Mac OS 7, A/UX, NeXTSTEP, and AIX/6000 (Version 3) while working at APL (American President Lines) in Oakland, California. Back then, my desktop was a pricey Macintosh Quadra 950 and today I work on a pricey Mac Pro desktop. The Mac Pro lets me use VMware virtualize development environments for Oracle Linux, Red Hat Enterprise Linux, Fedora, and as you might guess Windows 7/8. My question to those dyed in the wool Microsoft users is simple, why would you choose a single user OS like Windows over a multi-user OS like Mac OS X?

Written by maclochlainn

April 18th, 2014 at 4:28 pm

Mac Mini to the rescue

with 7 comments

In teaching, I had a problem because my students have different base operating systems, like Windows 7, Windows 8, Linux, and Mac OS X. I needed a teaching and lecture platform that would let me teach it all (not to mention support their environments). That meant it had to virtualize any of the following with a portable device:MacMiniConsole

  • Windows 7 or 8 hosting natively an Oracle Database 11g XE, 11g, or 12c and MySQL Database 5.6
  • Windows 7 or 8 hosting a Fedora or Oracle Unbreakable Linux VM (3 or 4 GB) with Oracle Database 11g XE, 11g, or 12c and MySQL Database 5.6
  • Mac OS X hosting a Fedora or Oracle Unbreakable Linux VM (3 or 4 GB) with Oracle Database 11g XE, 11g, or 12c and MySQL Database 5.6
  • Ubuntu hosting a Fedora or Oracle Unbreakable Linux VM (3 or 4 GB) with Oracle Database 11g XE, 11g, or 12c and MySQL Database 5.6

I never considered a manufacturer other than Apple for a laptop since they adopted the Intel chip. Too many of the others sell non-hyperthreaded laptop machines that they market as i5 or i7 64-bit OS machines when they’re not. Some of those vendors disable the hyperthreading facility while others provide motherboards that can’t support hyperthreading. The ones I dislike the most provide a BIOS setting that gives the impression you can enable hyperthreading when you can’t. All Apple devices, MacBook, MacBook Pro, Mac Mini, and Mac Pro do fully support a 64-bit OS and their virtualization.

A MacBook Pro came to mind but the disk space requirements were 1 TB, and that’s too pricey. I went with the Mac Mini because with 16 GB of memory and a 1 TB drive it was only $1,200. Add a wireless keyboard and mighty mouse, and an HDMI and mini-DVI connections, and I had my solution. Naturally, my desktop is a one generation old Mac Pro with 64 GB of memory and 12 TB of disk space, which supports all the virtual machines used for testing. Note to Apple marketing staff: The prior version of the Mac Pro let you pay reasonable (3rd party) prices for the additional memory and disk drives.

The Mac Mini means I can travel anywhere and plug into the console and demo tools and techniques from a myriad set of platforms without the hassle of moving on and off to frequently VM images. It’s a great solution with only one downside, HDMI to DVI sometimes creates purple toned screens. It’s unfortunate because some venues have monitors that don’t support HDMI).

Written by maclochlainn

February 6th, 2014 at 12:17 pm

Open a port on Fedora

with one comment

Since MySQL Workbench 6.0 isn’t available for Fedora, Version 20, I’m having my students install it on their local Windows and Mac OS X operating systems. You can configure the /etc/sysconfig/iptables file to enable port 3306 after installing MySQL on Fedora.

You can open a port by using the firewall-config utility (easy way) or by adding the following line to the /etc/sysconfig/iptables file (Fedora’s instructions on editing iptables [hard way]). The file won’t exist initially, but you can create it by running the following command as the root superuser or sudoer:

shell> service iptables save

You you can run the following commands as the root superuser, which saves the line in the iptables file:

shell> iptables -A INPUT -m conntrack --ctstate NEW -m tcp -p tcp --dport 3306 -j ACCEPT
shell> iptables-save

After making the change to the /etc/iptables file you can change the firewall by running the following command as the root superuser:

shell> service iptables restart

Just make sure you don’t inadvertently start both iptables and ip6tables as services. You can check that only one is running by using the following commands:

shell> service iptables status
shell> service ip6tables status

MySQL Workbench Configuration

MySQL Workbench Home Page

  1. The first thing you need to do is click on the + symbol in the circle to the right of the MySQL Connections text label. It launches the Setup New Connection dialog.

Setup New Connection

  1. The second thing you need to do is enter a Connection Name, Hostname, Port, and Username. Then, click the Test Connection button.

Connect to MySQL Server

  1. The Test Connection button launches the Connect to MySQL Server dialog. Enter the password for the student user (or whatever user you’re interested in), and then click the OK button.

Connection Parameter Acknowledgment

  1. When the credentials in the Connect to MySQL Server dialog work, you see the following confirmation dialog message. Click the OK button to continue and you’ll see a new VMWare Fedora Instance connection icon.

MySQL Workbench Home Page

  1. Click the VMWare Fedora Instance connection to start a new connection.

Connect to MySQL Server

  1. The VMWare Fedora Instance button launches the Connect to MySQL Server dialog. Like you did when configuring the connection, enter the password for the student user (or whatever user you’re interested in), and then click the OK button. It launches an interactive panel that lets you run, edit, or save the SQL script file.

MySQL Workbench

  1. Type the following two lines in the Query1 panel (at least if you have a studentdb database:
    USE studentdb;
    SELECT DATABASE();

Written by maclochlainn

January 18th, 2014 at 11:51 pm