LoginSignup
0
0

More than 5 years have passed since last update.

さくらVPSでMojoliciousを使うの巻 試練編

Posted at

地獄の門へようこそ。

筆者はこれを朝方取り組んだのですが、まぁ泣きそうになりながら10時を迎えましたʕ̡̢̡ʘ̅͟͜͡ʘ̲̅ʔ̢̡̢

1. cpanm を使ってみる

[hoge@hog1234xx ~]$ cpan --sudo Mojolicious

これでインストール出来るはずが、問題多発。
以下、ログです。

1-1. インスコ編

[hoge@hog1234xx ~]$ cpan --sudo Mojolicious
Unknown option: -
Unknown option: s
Unknown option: u
Unknown option: d
Unknown option: o
Sorry, we have to rerun the configuration dialog for CPAN.pm due to
some missing parameters...

CPAN is the world-wide archive of perl resources. It consists of about
300 sites that all replicate the same contents around the globe. Many
countries have at least one CPAN site already. The resources found on
CPAN are easily accessible with the CPAN.pm module. If you want to use
CPAN.pm, lots of things have to be configured. Fortunately, most of
them can be determined automatically. If you prefer the automatic
configuration, answer 'yes' below.

If you prefer to enter a dialog instead, you can answer 'no' to this
question and I'll let you configure in small steps one thing after the
other. (Note: you can revisit this dialog anytime later by typing 'o
conf init' at the cpan prompt.)
Would you like me to configure as much as possible automatically? [yes] no ← これが地獄の始まりだったかもしれない

(|| ×m×)オ、オェ・・

The following questions are intended to help you with the
configuration. The CPAN module needs a directory of its own to cache
important index files and maybe keep a temporary mirror of CPAN files.
This may be a site-wide or a personal directory.

I see you already have a  directory
    /home/hoge/.cpan
Shall we use it as the general CPAN build and cache directory?

 <cpan_home>
CPAN build and cache directory? [/home/hoge/.cpan]

Unless you are accessing the CPAN on your filesystem via a file: URL,
CPAN.pm needs to keep the source files it downloads somewhere. Please
supply a directory where the downloaded files are to be kept.

 <keep_source_where>
Download target directory? [/home/hoge/.cpan/sources]

 <build_dir>
Directory where the build process takes place? [/home/hoge/.cpan/build]

Normally CPAN.pm keeps config variables in memory and changes need to
be saved in a separate 'o conf commit' command to make them permanent
between sessions. If you set the 'auto_commit' option to true, changes
to a config variable are always automatically committed to disk.

 <index_expire>
Let the index expire after how many days? [1]

By default, each time the CPAN module is started, cache scanning is
performed to keep the cache size in sync. To prevent this, answer
'never'.

延々と…それはそれは延々と….ʕ̡̢̡ʘ̅͟͜͡ʘ̲̅ʔ̢̡̢

CPAN needs access to at least one CPAN mirror.

As you did not allow me to connect to the internet you need to supply
a valid CPAN URL now.

Please enter the URL of your CPAN mirror
CPAN needs access to at least one CPAN mirror.

As you did not allow me to connect to the internet you need to supply
a valid CPAN URL now.

Please enter the URL of your CPAN mirror
CPAN needs access to at least one CPAN mirror.

As you did not allow me to connect to the internet you need to supply
a valid CPAN URL now.

Please enter the URL of your CPAN mirror
CPAN needs access to at least one CPAN mirror.

As you did not allow me to connect to the internet you need to supply
a valid CPAN URL now.

Please enter the URL of your CPAN mirror
CPAN needs access to at least one CPAN mirror.

As you did not allow me to connect to the internet you need to supply
a valid CPAN URL now.

Please enter the URL of your CPAN mirror
CPAN needs access to at least one CPAN mirror.

As you did not allow me to connect to the internet you need to supply
a valid CPAN URL now.

Please enter the URL of your CPAN mirror
CPAN needs access to at least one CPAN mirror.

As you did not allow me to connect to the internet you need to supply
a valid CPAN URL now.

Please enter the URL of your CPAN mirror
CPAN needs access to at least one CPAN mirror.

As you did not allow me to connect to the internet you need to supply
a valid CPAN URL now.

Please enter the URL of your CPAN mirror
CPAN needs access to at least one CPAN mirror.

As you did not allow me to connect to the internet you need to supply
a valid CPAN URL now.

Please enter the URL of your CPAN mirror
CPAN needs access to at least one CPAN mirror.

As you did not allow me to connect to the internet you need to supply
a valid CPAN URL now.

Please enter the URL of your CPAN mirror  ftp://ftp.kddilabs.jp/CPAN/
Configuration does not allow connecting to the internet.
Current set of CPAN URLs:
  ftp://ftp.kddilabs.jp/CPAN/
Enter another URL or RETURN to quit: [] ftp://ftp.ring.gr.jp/pub/lang/perl/CPAN/
Enter another URL or RETURN to quit: [] http://ftp.nara.wide.ad.jp/pub/CPAN/
Enter another URL or RETURN to quit: [] ftp://ftp.nara.wide.ad.jp/pub/CPAN/
Enter another URL or RETURN to quit: []
New urllist
  ftp://ftp.kddilabs.jp/CPAN/
  ftp://ftp.ring.gr.jp/pub/lang/perl/CPAN/
  http://ftp.nara.wide.ad.jp/pub/CPAN/
  ftp://ftp.nara.wide.ad.jp/pub/CPAN/

Please remember to call 'o conf commit' to make the config permanent!

あ、終わったかもしれないʕ̡̢̡ʘ̅͟͜͡ʘ̲̅ʔ̢̡̢ でも続きます。

Fetching with LWP:
  ftp://ftp.kddilabs.jp/CPAN/authors/id/S/SR/SRI/CHECKSUMS
Checksum for /home/hoge/.cpan/sources/authors/id/S/SR/SRI/Mojolicious-3.93.tar.gz ok
CPAN: Archive::Tar loaded ok (v1.58)
Mojolicious-3.93/
Mojolicious-3.93/.perltidyrc
Mojolicious-3.93/Changes
Mojolicious-3.93/CONTRIBUTING.md
Mojolicious-3.93/examples/
Mojolicious-3.93/lib/
Mojolicious-3.93/LICENSE
Mojolicious-3.93/Makefile.PL
Mojolicious-3.93/MANIFEST
Mojolicious-3.93/MANIFEST.SKIP

長い….

Mojolicious-3.93/examples/microhttpd.pl
Mojolicious-3.93/examples/websocket.pl
CPAN: File::Temp loaded ok (v0.22)

次はなんだ….

  CPAN.pm: Going to build S/SR/SRI/Mojolicious-3.93.tar.gz

Checking if your kit is complete...
Looks good
Writing Makefile for Mojolicious
Could not read '/home/hoge/.cpan/build/Mojolicious-3.93-ITLhST/META.yml'. Falling back to other methods to determine prerequisites
cp lib/Mojo/Template.pm blib/lib/Mojo/Template.pm
cp lib/Mojo/JSON.pm blib/lib/Mojo/JSON.pm
cp lib/Mojolicious/Command/routes.pm blib/lib/Mojolicious/Command/routes.pm
cp lib/Mojo/ByteStream.pm blib/lib/Mojo/ByteStream.pm
cp lib/Mojo/Log.pm blib/lib/Mojo/Log.pm
cp lib/Mojolicious/public/mojo/prettify/prettify.css blib/lib/Mojolicious/public/mojo/prettify/prettify.css
cp lib/Mojolicious/Plugin/JSONConfig.pm blib/lib/Mojolicious/Plugin/JSONConfig.pm
          ・
          ・
          ・
Manifying blib/man3/Mojo::Parameters.3pm
  SRI/Mojolicious-3.93.tar.gz
  make -- OK

お、makeが終わった。

Warning (usually harmless): 'YAML' not installed, will not store persistent state

ん? warningでた。不穏。。。
続きます。

Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/*/*.t
t/mojo/app.t ............................... ok 
t/mojo/asset.t ............................. ok 
t/mojo/base.t .............................. ok  
t/mojo/bytestream.t ........................ ok 
t/mojo/headers.t ........................... ok  
t/mojo/home.t .............................. ok 
     ・
     ・
     ・
t/mojolicious/websocket_lite_app.t ......... ok  
t/pod.t .................................... skipped: set TEST_POD to enable this test (developer only!)
t/pod_coverage.t ........................... skipped: set TEST_POD to enable this test (developer only!)
All tests successful.
Files=83, Tests=9537, 49 wallclock secs ( 2.41 usr  0.43 sys + 33.90 cusr  3.09 csys = 39.83 CPU)
Result: PASS
  SRI/Mojolicious-3.93.tar.gz
  make test -- OK
Warning (usually harmless): 'YAML' not installed, will not store persistent state

お、make testも終わった!良い感じ良い感じ!

Running make install
Prepending /home/hoge/.cpan/build/Mojolicious-3.93-ITLhST/blib/arch /home/hoge/.cpan/build/Mojolicious-3.93-ITLhST/blib/lib to PERL5LIB for 'install'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ERROR: Can't create '/usr/local/bin'
Do not have write permissions on '/usr/local/bin'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 at -e line 1
make: *** [pure_site_install] エラー 13
  SRI/Mojolicious-3.93.tar.gz
  make install  -- NOT OK
----
  You may have to su to root to install the package
  (Or you may want to run something like
    o conf make_install_make_command 'sudo make'
  to raise your permissions.Warning (usually harmless): 'YAML' not installed, will not store persistent state

(|| ×m×)オ、オェ・・

まぁエラーコードくらい見てやるか。

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ERROR: Can't create '/usr/local/bin'
Do not have write permissions on '/usr/local/bin'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

ともあれ。/usr/local/binへのアクセス権限がないというわけですな。 sudoしたのに。
権限変えるか。でもwrite権限は与えてはいけないと。 chmodですね。
書き込み権限はダメだけど、ディレクトリへのファイルのインスコはしたいと。

(|| ×m×)オ、オェ・・ 私にはこのエラーコードの意味がイマイチ分からない・・・

1-2. chmod編

〜省略〜
(全然うまく行かなすぎて地獄過ぎて(´;ω;`))

1-3. sudo編

[hoge@hog1234xx ~]$ su
パスワード:
[root@hog1234xx hoge]# ls
[root@hog1234xx hoge]# pwd
/home/hoge
[root@hog1234xx hoge]# cpan mojolicious

CPAN is the world-wide archive of perl resources. It consists of about
300 sites that all replicate the same contents around the globe. Many
countries have at least one CPAN site already. The resources found on
CPAN are easily accessible with the CPAN.pm module. If you want to use
CPAN.pm, lots of things have to be configured. Fortunately, most of
them can be determined automatically. If you prefer the automatic
configuration, answer 'yes' below.

If you prefer to enter a dialog instead, you can answer 'no' to this
question and I'll let you configure in small steps one thing after the
other. (Note: you can revisit this dialog anytime later by typing 'o
conf init' at the cpan prompt.)
Would you like me to configure as much as possible automatically? [yes] yes  ←今度はちゃんとyes

すると全部自動でやってくれたε=\_○ノ イヤッホーゥ!
・・・でもそもそも既に何回も登録しているわけで・・・
なんで何回も何回もやらなくちゃいけんのだ・・・
そんな時こんなメッセージが

If you don't understand this question, just press ENTER.

そうかそうか、ではその様に

Typical frequently used settings:

    PREFIX=~/perl    # non-root users (please see manual for more hints)
     ・
     ・
     ・

うんうんうまくいってる気がする!指示通りだもん!!
+(0゚・∀・) + ワクテカ +

     ・
     ・
     ・

Warning: Cannot install mojolicious, don't know what it is.
Try the command

    i /mojolicious/

to find objects with matching identifiers.
 (|| ×m×)オ、オェ・・(|| ×m×)オ、オェ・・(|| ×m×)オ、オェ・・(|| ×m×)オ、オェ・・
[root@hog1234xx hoge]# exit
exit

そりゃ一旦さよならしたくなるよね

1-4. 諦めるʕ̡̢̡ʘ̅͟͜͡ʘ̲̅ʔ̢̡̢

もう無理。ていうか、そもそもcpanmをインスコしたかったのに、全然違う方に行っていた。

2. perlbrewのインストール

2-1. ブログ記事なんてもう信じない

[hoge@hog1234xx ~]$ curl -L http://xrl.us/perlbrew | perl - install
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 94486  100 94486    0     0  20670      0  0:00:04  0:00:04 --:--:--  195k

install [options] perl-<version>
install [options] <version>
    Build and install the given version of perl.

    Version numbers usually look like "5.x.xx", or "perl-5.xx.x-RCx" for
    release candidates.

    The specified perl is downloaded from the offical CPAN website or
    from the mirror site configured before.

    To configure mirror site, invoke `mirror` command.

install [options] perl-stable
install [options] stable
    A convenient way to install the most recent stable version of Perl,
    of those that are available.

install [options] perl-blead
install [options] blead
    A special way to install the blead version of perl, which is
    downloaded from this specific URL regardless of mirror settings:

        http://perl5.git.perl.org/perl.git/snapshot/blead.tar.gz

install [options] /path/to/perl/git/checkout/dir
    Build and install from the given git checkout dir.

install [options] /path/to/perl-5.14.0.tar.gz
    Build and install from the given archive file.

install [options] http://example.com/mirror/perl-5.12.3.tar.gz
    Build and install from the given URL. Supported URL schemes are
    "http://", "https://", "ftp://" and "file://".

Options for "install" command:

    -f --force     Force installation
    -j $n          Parallel building and testing. ex. C<perlbrew install -j 5 perl-5.14.2>
    -n --notest    Skip testing

       --switch    Automatically switch to this Perl once successfully
                   installed, as if with `perlbrew switch <version>`

       --as        Install the given version of perl by a name.
                   ex. C<perlbrew install perl-5.6.2 --as legacy-perl>

    -D,-U,-A       Switches passed to perl Configure script.
                   ex. C<perlbrew install perl-5.10.1 -D usemymalloc -U uselargefiles>

    --sitecustomize $filename
                   Specify a file to be installed as sitecustomize.pl

By default, all installations are configured after their name like this:

    sh Configure -de -Dprefix=$PERLBREW_ROOT/perls/<name>

しかし、★★問題解決★★
perlbrewのインストール先の設定ができていればよかったようです。

2-2. インストール先の設定

[hoge@hog1234xx ~]$ export PERLBREW_ROOT=$HOME/.perlbrew
[hoge@hog1234xx ~]$ curl -L http://xrl.us/perlbrewinstall --insecure | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
102  1022  102  1022    0     0    331      0  0:00:03  0:00:03 --:--:--  998k

## Download the latest perlbrew

## Installing perlbrew
perlbrew is installed: ~/.perlbrew/bin/perlbrew

perlbrew root (~/.perlbrew) is initialized.

Append the following piece of code to the end of your ~/.bash_profile and start a
new shell, perlbrew should be up and fully functional from there:

    source ~/.perlbrew/etc/bashrc

Simply run `perlbrew` for usage details.

Happy brewing!

## Installing patchperl

## Done.

2-3. Perlbrew 初期設定

[hoge@hog1234xx ~]$ ~/.perlbrew/bin/perlbrew init

perlbrew root (~/.perlbrew) is initialized.

Append the following piece of code to the end of your ~/.bash_profile and start a
new shell, perlbrew should be up and fully functional from there:

    source ~/.perlbrew/etc/bashrc

Simply run `perlbrew` for usage details.

Happy brewing!


[hoge@hog1234xx ~]$ echo 'source ~/.perlbrew/etc/bashrc' >> ~/.bashrc
[hoge@hog1234xx ~]$ source ~/.bashrc

3. Perlのインストール

[hoge@hog1234xx ~]$ perlbrew install -v perl-5.14.2 -D ccflags=-fPIC

これ30分以上かかるかも。
Perlのインストール確認

[hoge@hog1234xx ~]$ perlbrew list
----
  perl-5.14.2
----

え?5.10とかどこいった?
てかアスタリスクついてるバージョンがない。
え?どーなってんの?

[hoge@hog1234xx ~]$ perl -v

This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi

Copyright 1987-2009, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

おやおや?
詳細をみよう。

[hoge@hog1234xx ~]$ perl -V
[hoge@hog1234xx ~]$ perl -V
Summary of my perl5 (revision 5 version 10 subversion 1) configuration:

  Platform:
    osname=linux, osvers=2.6.32-220.el6.x86_64, archname=x86_64-linux-thread-multi
    uname='linux c6b10.bsys.dev.centos.org 2.6.32-220.el6.x86_64 #1 smp tue dec 6 19:48:22 gmt 2011 x86_64 x86_64 x86_64 gnulinux '
    config_args='-des -Doptimize=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -DDEBUGGING=-g -Dversion=5.10.1 -Dmyhostname=localhost -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dprefix=/usr -Dvendorprefix=/usr -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl5 -Dsitearch=/usr/local/lib64/perl5 -Dprivlib=/usr/share/perl5 -Darchlib=/usr/lib64/perl5 -Dvendorlib=/usr/share/perl5/vendor_perl -Dvendorarch=/usr/lib64/perl5/vendor_perl -Dinc_version_list=5.10.0 -Darchname=x86_64-linux-thread-multi -Dlibpth=/usr/local/lib64 /lib64 /usr/lib64 -Duseshrplib -Dusethreads -Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio -Dinstallusrbinperl=n -Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less -isr -Dd_gethostent_r_proto -Ud_endhostent_r_proto -Ud_sethostent_r_proto -Ud_endprotoent_r_proto -Ud_setprotoent_r_proto -Ud_endservent_r_proto -Ud_setservent_r_proto -Dscriptdir=/usr/bin -Dusesitecustomize'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.4.7 20120313 (Red Hat 4.4.7-3)', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -fstack-protector'
    libpth=/usr/local/lib64 /lib64 /usr/lib64
    libs=-lresolv -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.12'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/usr/lib64/perl5/CORE'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'


Characteristics of this binary (from libperl):
  Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV
                        PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP USE_64_BIT_ALL
                        USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES
                        USE_PERLIO USE_REENTRANT_API USE_SITECUSTOMIZE
  Built under linux
  Compiled at Mar 26 2013 19:53:38
  %ENV:
    PERLBREW_BASHRC_VERSION="0.62"
    PERLBREW_HOME="/home/hoge/.perlbrew"
    PERLBREW_ROOT="/home/hoge/.perlbrew"
  @INC:
    /usr/local/lib64/perl5
    /usr/local/share/perl5
    /usr/lib64/perl5/vendor_perl
    /usr/share/perl5/vendor_perl
    /usr/lib64/perl5
    /usr/share/perl5
    .
 ほう。とにかくバージョンは5.10だね。
[hoge@hog1234xx ~]$ perlbrew switch perl-5.14.2
[hoge@hog1234xx ~]$ perl -v

This is perl 5, version 14, subversion 2 (v5.14.2) built for x86_64-linux

Copyright 1987-2011, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

よし◎。

ここまでが試練でした。
あとは、割とサクサクと行きましたが、
DBD::mysqlのインストールについては考えたくもありません(|| ×m×)オ、オェ・・

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0