1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Mojoliciousインストール メモ

Posted at

Perl WEBアプリケーションフレームワークMojoliciousインストールのメモです。
windows上でvagrantにてcentos7を立ててそこにインストールします。

Mojoliciousテスト環境構築

設定

  • HostOS: windows10

  • vagrant

  • virtualbox

  • GuestOS: CentOS7

  • perlbrew

  • cpanm

  • Perl 5.20.3

  • mojolicious

備考

  • Windowsではvagrantでcentos7を入れる場合、C:\Users[username].vagrant.d\boxes\centos-VAGRANTSLASH-7\XXXX\virtualbox
    Vagrantfile
  config.vm.synced_folder ".", "/home/vagrant/sync", type: "rsync"

をコメントアウトする必要があるかもしれない。

  • mojoliciousはperl5.20以上だと、同梱ライブラリで動作するとのことなので
    5.20.3を選択している。

以下、手順

windows上で以下を実行

mkdir mojotest && cd mojotest
vagrant init centos/7

次のようにファイルを編集、作成する。(Vagrantfile, provison.sh)
Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
  config.vm.box = "centos/7"
  config.vm.network "private_network", ip: "192.168.33.20"
  config.vm.synced_folder ".", "/home/vagrant/sync" ,disabled: true
  config.vm.provision "shell", :path => "provision.sh", privileged: false
end

provision.sh

#!/usr/bin/env bash

PERL_INSTALL_VERSION='perl-5.20.3'
echo "**exec user:"
whoami
################################################
echo "**yum install"

sudo yum -y install perl vim gcc  git
sudo yum install -y -q ntp
sudo systemctl start  ntpd
sudo systemctl enable ntpd
sudo timedatectl set-timezone Asia/Tokyo

# centos7
sudo sed -i -e 's/^PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
sudo systemctl restart sshd
sudo sed -i -e 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config

sudo systemctl disable firewalld
sudo systemctl stop firewalld
sudo systemctl disable NetworkManager
sudo systemctl stop NetworkManager
sudo systemctl enable network
sudo systemctl start network
################################################
echo "**perlbrew"
cd ~
export PERLBREW_ROOT=$HOME/.perlbrew
#if [[ ! -d $HOME/.perlbrew ]]; then
  curl -L http://xrl.us/perlbrewinstall --insecure | bash
  ~/.perlbrew/bin/perlbrew init
  echo 'source ~/.perlbrew/etc/bashrc' >> ~/.bashrc
  source ~/.bashrc
#fi
perlbrew install -v $PERL_INSTALL_VERSION -D ccflags=-fPIC
perlbrew list
perlbrew switch $PERL_INSTALL_VERSION
perlbrew   install-cpanm    
cpanm Mojolicious
mojo version

echo "**End"
  • 次を実行して待つ
vagrant up
  • テストアプリ
  • できたらゲストOSのcentos7にSSHログインして以下を実行。
cd ~
mkdir ~/mojo_welcome; cd ~/mojo_welcome
mojo generate lite_app
morbo myapp.pl
1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?