view · edit · sidebar · attach · print · history

20160701-setup-davaz-com

<< 20160702-setup-davaz-com | Index | 20160319-fix-and-setup-ruby186-apps-with-mod_ruby-compiled-against-ruby193 >>


Summary

  • Setup davaz.com in local machine
    • Compile Ruby 1.8.6 + Oniguruma patch, openssl-1.0 patch and syck.patch
    • Install Apache2, PostgreSQL, MySQL and ImageMagick
    • Compile mod_ruby
    • Build rubygem (1.4.1) from source (setup.rb) for ruby 1.8.6 (above Ruby 1.9.3 includes rubygem)
    • Install gems with script

Commits / Patches / Pull Requests, Scripts

Index


Setup davaz.com

Requirements

;; apache options in /etc/conf.d/apache2
APACHE2_OPTS="$APACHE2_OPTS -D RUBY"
;; mysql on production
$ mysql --version
mysql Ver 14.14 Distrib 5.1.66, for pc-linux-gnu (x86_64) using readline 5.1

Build ruby 1.8.6 + Oniguruma patches + Additional patches

All patches are here:
http://dev.ywesee.com/Ruby186/Patches

Reference:
http://dev.ywesee.com/uploads/att/gen_ruby_186_niklaus.txt

Compile error with gcc-5.3.0

I've got with gcc-5.3.0 . It seems that this version is too new for ruby 1.8.6.

gc.c: In function ‘obj_free’:
gc.c:380:17: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
 #define RANY(o) ((RVALUE*)(o))
                 ^
gc.c:1288:29: note: in expansion of macro ‘RANY’
      struct rb_io_t *fptr = RANY(obj)->as.file.fptr;
                             ^
In file included from parse.y:3362:0:
lex.c:125:26: warning: ‘hash’ is static but used in inline function ‘rb_reserved_word’ which is not static
       register int key = hash (str, len);
                          ^
lex.c:76:25: warning: ‘wordlist’ is static but declared in inline function ‘rb_reserved_word’ which is not static
   static struct kwtable wordlist[] =
                         ^
process.c: In function ‘proc_exec_v’:
process.c:998:5: warning: implicit declaration of function ‘rb_thread_cancel_timer’ [-Wimplicit-function-declaration]
     rb_thread_cancel_timer();
     ^
libruby186-static.a(parse.o): In function `ruby_yylex':
parse.c:(.text+0xd411): undefined reference to `rb_reserved_word'
collect2: error: ld returned 1 exit status
make: *** [Makefile:101: miniruby] Error 1

This is full compile log (includes oniguruma and other patches):
http://dev.ywesee.com/uploads/att/ruby186-compile-error-with-gcc-5.3.0.log.txt

After gcc-4.9.3 compiled, I could compile ruby 1.8.6 with it.

% gcc-config -l    
 [1] avr-4.9.3 *

 [2] x86_64-pc-linux-gnu-4.9.3 *
 [3] x86_64-pc-linux-gnu-5.3.0
 [4] x86_64-pc-linux-gnu-5.4.0
% ./bin/ruby186 --version
ruby 1.8.6 (2010-01-11 patchlevel 388) [x86_64-linux]

Note to compile ruby

Download ruby source from cache (CDN)

Let's use https://cache.ruby-lang.org/pub/ruby/ instead of https://ftp.ruby-lang.org/pub/ruby/ .

Oniguruma patches

Oniguruma patches is written for ruby-1.8.6-p369. But it does not exist in ruby-lang.org.
Its are available with ruby-1.8.6-p388, too.

Reference:
http://dev.ywesee.com/Main/Oniguruma

Install scripts

Rubygems for davatz.com (186)

On fastpower, current davatz.com depends following rubygems:
All ruby gems are installed via gem command. Because it is ruby 1.8.6, we can't bundle install.

And as note, all rubygems (for 1.8.6) are in /usr/local/bin/ruby186 .
This is not normal install location.

;; Rubygems in /usr/local/bin/ruby186/lib/ruby/gems/1.8/gems
character-encodings-0.3.0                                                       
color-1.4.1                                                                     
dbd-pg-0.3.9                                                                    
dbi-0.4.5                                                                       
deprecated-2.0.1                                                                
deprecated-3.0.1                                                                
fastthread-1.0.7                                                                
hpricot-0.8.6                                                                   
htmlgrid-1.0.0                                                                  
htmlgrid-1.0.3                                                                  
htmlgrid-1.0.6                                                                  
json-1.8.0                                                                      
mysql-2.8.1                                                                     
needle-1.3.0                                                                    
odba-1.1.0                                                                      
pdf-writer-1.1.8                                                                
pg-0.15.1                                                                       
pg-0.8.0                                                                        
rclconf-1.0.0                                                                   
rmagick-2.13.2                                                                  
rmail-1.0.0                                                                     
ruby-json-1.1.2                                                                 
ruby-ole-1.2.11.6                                                               
ruby-password-0.15.5                                                            
ruby-termios-0.9.6                                                              
sbsm-1.2.3                                                                      
smtp_tls-1.0.3                                                                  
spreadsheet-0.8.5                                                               
tmail-1.2.7.1                                                                   
transaction-simple-1.4.0.2                                                      
ydim-1.0.0                                                                      
yus-1.0.1
$ /usr/local/bin/ruby186/bin/gem --version
1.4.1

Rubygem 1.4.1:
https://github.com/rubygems/rubygems/archive/v1.4.1.tar.gz

$ cd rubygems-1.4.1
$ /path/to/ruby186 setup.rb

Some rubygems (with native extension) are not installed without error.
If I removed `-werror` from CFLAGS and CPPFLAGS, then it is installed expectedly.

gcc -I. -I/pat/to/lib/ruby/1.8/x86_64-linux -I/path/to/lib/ruby/1.8/x86_64-linux -I. -DHAVE_ASSERT_H -DHAVE_LIMITS_H -DHAVE_LOCALE_H -DHAVE_STDBOOL_H -DHAVE_STDDEF_H -DHAVE_STDINT_H -DHAVE_STDIO_H -DHAVE_STDLIB_H -DHAVE_STRING_H -DHAVE_SYS_TYPES_H -DHAVE_WCHAR_H   -fPIC -fPIC -std=c99 -finline-functions -Wall -Wextra -Wwrite-strings -Waggregate-return -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wundef -Wpointer-arith -Wcast-align -Werror -Winline  -c rb_utf_tr.c
rb_utf_tr.c: In function ‘tr_trans_do’:
rb_utf_tr.c:107:14: error: variable ‘modified’ set but not used [-Werror=unused-but-set-variable]
         bool modified = false;
              ^
cc1: all warnings being treated as errors
make: *** [Makefile:146: rb_utf_tr.o] Error 1
% ./gem186 install character-encodings --version 0.3.0 --no-ri --no-rdoc -- --with-cflags=-w
Building native extensions.  This could take a while...
Successfully installed character-encodings-0.3.0
1 gem installed

This is install script for gems:

mod_ruby and Apache2

In production, The version of apache2 is currently 2.2.31

$ /usr/sbin/apache2 -V
Server version: Apache/2.2.31 (Unix)
Server built:   May 17 2016 16:12:38
Server's Module Magic Number: 20051115:40
Server loaded:  APR 1.4.5, APR-Util 1.3.12
Compiled using: APR 1.4.5, APR-Util 1.3.12
Architecture:   64-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT="/usr"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="/var/run/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="/var/run/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="/etc/apache2/mime.types"
 -D SERVER_CONFIG_FILE="/etc/apache2/httpd.conf"

If I installed with >= 2.4.20, then compiling of mod_ruby fails.

In file included from /path/to/include/ruby-1.9.1/ruby.h:32:0,
                 from mod_ruby.h:33,
                 from apachelib.c:35:
apachelib.c: In function ‘rb_init_apache’:
apachelib.c:374:58: error: ‘OPT_INCNOEXEC’ undeclared (first use in this function)
     rb_define_const(rb_mApache, "OPT_INCNOEXEC", INT2NUM(OPT_INCNOEXEC));
                                                          ^
/path/to/include/ruby-1.9.1/ruby/ruby.h:225:45: note: in definition of macro ‘INT2FIX’
 #define INT2FIX(i) ((VALUE)(((SIGNED_VALUE)(i))<<1 | FIXNUM_FLAG))
                                             ^
apachelib.c:374:50: note: in expansion of macro ‘INT2NUM’
     rb_define_const(rb_mApache, "OPT_INCNOEXEC", INT2NUM(OPT_INCNOEXEC));
                                                  ^
apachelib.c:374:58: note: each undeclared identifier is reported only once for each function it appears in
     rb_define_const(rb_mApache, "OPT_INCNOEXEC", INT2NUM(OPT_INCNOEXEC));
                                                          ^
/path/to/include/ruby-1.9.1/ruby/ruby.h:225:45: note: in definition of macro ‘INT2FIX’
 #define INT2FIX(i) ((VALUE)(((SIGNED_VALUE)(i))<<1 | FIXNUM_FLAG))
                                             ^
apachelib.c:374:50: note: in expansion of macro ‘INT2NUM’
     rb_define_const(rb_mApache, "OPT_INCNOEXEC", INT2NUM(OPT_INCNOEXEC));
                                                  ^
apachelib.c: In function ‘ap_chdir_file’:
apachelib.c:149:2: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
  chdir(file);
  ^
apachelib.c:154:2: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
  chdir(buf);
  ^
make: *** [Makefile:115: apachelib.o] Error 1
cp: cannot stat 'mod_ruby.so': No such file or directory

I could compile mod_ruby with apache 2.2.31 agaist:

  • ruby186
  • ruby193

This is install script:
http://dev.ywesee.com/uploads/att/gen-mod_ruby-with-ruby-186oniguruma-patch.sh.txt

But, when I've compiled mod_ruby with ruby186, I've gotten following error at boot.

% sudo service apache2 start                 
 * apache2 has detected an error in your setup:
apache2: Syntax error on line 149 of /etc/apache2/httpd.conf: Syntax error on line 2 of /etc/apache2/modules.d/99_mod_ruby.conf: Cannot load /usr/lib64/apache2/modules/mod_ruby186.so into server: /usr/lib64/apache2/modules/mod_ruby186.so: undefined symbol: rb_block_lambda
 * ERROR: apache2 failed to start
% ldd /usr/lib/apache2/modules/mod_ruby186.so 
        linux-vdso.so.1 (0x00007fffa6b8d000)
        libruby186.so.1.8 => /path/to/lib/libruby186.so.1.8 (0x00007ff7f5675000)
        librt.so.1 => /lib64/librt.so.1 (0x00007ff7f544e000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007ff7f524a000)
        libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007ff7f5013000)
        libm.so.6 => /lib64/libm.so.6 (0x00007ff7f4d16000)
        libc.so.6 => /lib64/libc.so.6 (0x00007ff7f497d000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ff7f4761000)
        /lib64/ld-linux-x86-64.so.2 (0x000055d2a5c39000)

Next: Fix installation of mod_ruby, Setup Database (MySQL, PostgreSQL)

view · edit · sidebar · attach · print · history
Page last modified on July 02, 2016, at 11:52 AM