Help us understand the problem. What is going on with this article?

centos kuro memo

More than 1 year has passed since last update.

wget https://github.com/kurokurosawa/centos7_setup_shell/archive/master.zip
unzip master.zip

IDとPW

CentOS
root userID:root
root userPW:root

normal userID:user
normal userPW:user

MySQL
root userID:root
root userPW:root

PostgreSQL
root userID:postgres
root userPW:postgres
su -
yum -y upgrade
yum -y update
yum -y update kernel
yum -y install kernel-devel kernel-headers gcc gcc-c++

初期設定

ルートユーザーに切り替える

rm -f setup_basic.sh; touch setup_basic.sh; chmod u+x setup_basic.sh; vi setup_basic.sh
#!/bin/bash

if [ "$UID" -eq 0 ];then
    echo -e "\033[0;32m【RPMパッケージのアップグレード】\033[0;39m"
    yum upgrade -y

    echo -e "\033[0;32m【RPMパッケージのアップデート】\033[0;39m"
    yum update -y

    echo -e "\033[0;32m【GuestAdditionsインストール用ライブラリ】\033[0;39m"
    yum install -y gcc kernel-devel kernel-headers

    echo -e "\033[0;32m【共通で必要なライブラリのインストール】\033[0;39m"
    yum groupinstall -y "Development Tools"
    yum install -y wget
    yum install -y curl-devel expat-devel gdbm-devel gettext-devel libffi-devel libyaml-devel ncurses-devel openssl-devel perl-ExtUtils-MakeMaker readline-devel zlib-devel

    echo -e "\033[0;32m【RPMコンフィグファイル(/etc/sudoers)の設定】\033[0;39m"
    cp -fp /etc/sudoers /etc/sudoers.`date "+%Y%m%d_%H%M%S"`_org
    sed -i 's/Defaults.*requiretty/#Default\trequiretty/g' /etc/sudoers
    sed -i 's/^#\s%wheel\s*ALL=(ALL)\s*ALL$/%wheel\tALL=(ALL)\tALL/g' /etc/sudoers
    sed -i 's/^#\s%wheel\s*ALL=(ALL)\s*NOPASSWD: ALL$/vagrant\tALL=(ALL)\tNOPASSWD: ALL/g' /etc/sudoers

    echo -e "\033[0;32m【SELinux無効設定】\033[0;39m"
    sed -i "s/\(^SELINUX=\).*/\1disabled/" /etc/selinux/config

    echo -e "\033[0;32m【RPMfirewall無効設定】\033[0;39m"
    firewall-cmd --permanent --zone=public --add-service=ssh
    firewall-cmd --permanent --zone=public --add-service=http
    firewall-cmd --permanent --zone=public --add-service=https
    firewall-cmd --permanent --zone=public --add-service=mysql
    firewall-cmd --permanent --zone=public --add-port=8080/tcp
    systemctl stop firewalld
    systemctl disable firewalld

    echo -e "\033[0;32m【locale keymapの設定】\033[0;39m"
    localectl set-locale LANG=ja_JP.utf8
    localectl set-keymap jp106
    localectl status

    echo -e "\033[0;32m【timezoneの設定】\033[0;39m"
    timedatectl set-timezone Asia/Tokyo
    timedatectl status

    echo -e "\033[0;31m【不要サービス停止】\033[0;39m"
    systemctl stop postfix.service
    systemctl stop auditd
    systemctl stop rpcbind.service
    systemctl stop nfs-lock.service
    systemctl stop auditd.service

    systemctl disable postfix.service
    systemctl disable auditd
    systemctl disable rpcbind.service
    systemctl disable nfs-lock.service
    systemctl disable auditd.service Agent

    echo "【Oracle JDK設定】";
    yum install -y wget

    mkdir /opt/java
    cd /opt/java

    wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz
    tar xzvf jdk-*.gz

    mv ./jdk*/* ./
    rm -rf ./jdk1.8.0_92/
    rm -rf ./jdk-8u92-linux-x64.tar.gz

    echo 'JAVA_HOME=/opt/java' >> /etc/profile
    echo 'export JAVA_HOME' >> /etc/profile
    echo 'PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile
    echo 'export PATH' >> /etc/profile
    echo 'CATALINA_HOME=/opt/tomcat' >> /etc/profile
    echo 'export CATALINA_HOME' >> /etc/profile
    . /etc/profile

    echo "$JAVA_HOME"
    echo $JAVA_HOME

    yum -y install libXScrnSaver


    echo -e "\033[0;31m【Finish】\033[0;39m"
else
  echo "non-root user!"
fi

rpm –ivh jdk-8u45-linux-x64.rpm

Git

ルートユーザーに切り替える

su -
rm -f setup_git.sh; touch setup_git.sh; chmod u+x setup_git.sh; vi setup_git.sh
#!/bin/bash

func_Install (){
  if [ "$UID" -eq 0 ];then
    echo -e "\033[0;32m【root!】\033[0;39m"

    # 定数設定
    URL_GIT="https://www.kernel.org/pub/software/scm/git/git-2.9.0.tar.gz"

    echo -e "\033[0;32m【アンストール git】\033[0;39m"
    yum -y remove git

    echo -e "\033[0;32m【確認 git アンストール】\033[0;39m"
    git --version

    echo -e "\033[0;32m【ファイル取得 git-2.X.X.tar.gz】\033[0;39m"
    cd ~/
    yum -y install gcc curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-ExtUtils-MakeMaker
    wget $URL_GIT
    tar zxvf git-*.tar.gz
    rm -rf git-*.tar.gz

    echo -e "\033[0;32m【コンパイル】\033[0;39m"
    cd git-*
    make prefix=/usr/local all
    make prefix=/usr/local install

    echo -e "\033[0;32m【シンボリックリンク】\033[0;39m"
    sudo ln -s /usr/local/bin/git /usr/bin/git

    echo -e "\033[0;32m【不要ファイル削除】\033[0;39m"
    rm -rf git-*

    echo -e "\033[0;32m【確認 git インストール】\033[0;39m"
    git --version
  else
    echo "non-root user!"
  fi
}

#2重確認 インストール済みか確認
if !(git --version) then
  echo -e "\033[0;32m【gitインストールされていません インストールする必要があります】\033[0;39m"
  func_Install
else
  echo -e "\033[0;32m【gitインストールされています】\033[0;39m"
    if (git --version | grep "git version 1") then
    echo -e "\033[0;32m【1.7.1なので古いです インストールする必要があります】\033[0;39m"
      func_Install
    else
    echo -e "\033[0;32m【新しいgitインストールされています】\033[0;39m"
    fi
fi

Git初期設定

cd
ls -la ~/.ssh/
ssh-keygen -t rsa
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa

#!/bin/bash
git config --global user.name "First-name Family-name"
git config --global user.email "username@example.com"
git config --global core.editor 'vim -c "set fenc=utf-8"'
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
# git config --global push.default simple
git config --global core.precomposeunicode true
git config --global core.quotepath false


# 確認
git config --list

Apache

ルートユーザーに切り替える

su -
rm -f setup_apache.sh; touch setup_apache.sh; chmod u+x setup_apache.sh; vi setup_apache.sh
#!/bin/bash

if [ "$UID" -eq 0 ];then
  echo -e "\033[0;32m【install httpd】\033[0;39m"
  yum -y install httpd

  echo -e "\033[0;32m【start enable httpd】\033[0;39m"
  systemctl start httpd
  systemctl enable httpd

  echo -e "\033[0;32m【back up httpd.conf】\033[0;39m"
  cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.orig
else
  echo "non-root user!"
fi
# ユーザー直下のhtmlをドキュメントディレクトリにシンボリックリンクさせる

# "/home/vagrant/"を755にする。
chmod 755 $HOME
ls -l /home/

# "/home/vagrant/html"をvagrantユーザー権限で作成する。
mkdir $HOME/html
ls -l $HOME/

# 所有者をvagrantユーザーに設定する
sudo chown $USER:$USER $HOME/html

# "/var/www/html"にシンボリックリンクを設定する
sudo rm -rf /var/www/html
sudo ln -fs $HOME/html /var/www/html

# PHP動作確認用ファイル設置
echo -e "<?php\n\tphpinfo();\n?>" > /var/www/html/info.php


# 【確認】
ls -la /var/www | grep html
ls -la /home/ | grep vagrant

Ruby

通常ユーザーで作業する

rm -f setup_ruby.sh; touch setup_ruby.sh; chmod u+x setup_ruby.sh; vi setup_ruby.sh
#!/bin/bash

if [ "$UID" -eq 0 ];then
  echo -e "\033[0;32m【non-normal user!】\033[0;39m"
else
  sudo yum install -y git gcc openssl-devel readline-devel zlib-devel sqlite-devel gcc-c++ libicu-devel cmake

  # clone rbenv source code and add it do PATH
  echo -e "\033[0;32m【cloning rbenv source code】\033[0;39m"
  git clone https://github.com/rbenv/rbenv.git ~/.rbenv

  # initialize rbenv
  echo -e "\033[0;32m【initialize rbenv】\033[0;39m"
  echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
  echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

  # clone rbenv's plugin to compile and install ruby
  echo -e "\033[0;32m【installing ruby-build】\033[0;39m"
  git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
  echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
  source ~/.bash_profile

  # install ruby
  echo -e "\033[0;32m【installing ruby】\033[0;39m"
  rbenv install 2.4.0
  rbenv install 2.3.0
  rbenv global 2.4.0

  # prints out ruby version
  echo -e "\033[0;32m【the following version(s) of ruby were installed:】\033[0;39m"
  ruby -v
  echo '\n'

  echo -e "\033[0;32m【install bundler and rails】\033[0;39m"
  gem install bundler
  rbenv rehash
  gem install rails
  rbenv rehash

  echo -e "\033[0;32m【the following version of rails were installed:】\033[0;39m"
  rails -v
  echo '\n'
fi

Rails 動作確認

rails new scaffold_sample
cd scaffold_sample
sed -i -e "s/# gem 'therubyracer'/gem 'therubyracer'/" Gemfile
bundle
rails generate scaffold user name:string age:integer
rake db:migrate
rails s

http://localhost:3000/users

Python

通常ユーザーで作業する

rm -f setup_python.sh; touch setup_python.sh; chmod u+x setup_python.sh; vi setup_python.sh
#!/bin/bash

if [ "$UID" -eq 0 ];then
  echo "non-normal user!"
else
  echo -e "\033[0;31m【.pyenv】\033[0;39m"
  git clone https://github.com/yyuu/pyenv.git ~/.pyenv
  echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
  echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
  echo 'eval "$(pyenv init -)"' >> ~/.bashrc
  source ~/.bashrc

  # 最新版を確認。anaconda3-2.5.0 (2系はanaconda-2.5.0)
  # minicondaがいい人はminicondaを入れてください。
  echo -e "\033[0;31m【install anaconda】\033[0;39m"
  pyenv install -l | grep ana

  pyenv install anaconda3-2.5.0
  pyenv rehash

  # anacondaをメインのpythonに設定。
  echo -e "\033[0;31m【global anaconda】\033[0;39m"
  pyenv global anaconda3-2.5.0

  # activateがpyenvとanacondaでバッティングするので、pathに明示しておく。
  echo -e "\033[0;31m【export PATH anaconda】\033[0;39m"
  echo 'export PATH="$PYENV_ROOT/versions/anaconda3-2.5.0/bin/:$PATH"' >> ~/.bashrc
  source ~/.bashrc

  #念のためconda自体をアップデートしておく。
  echo -e "\033[0;31m【conda update】\033[0;39m"
  conda update -y conda

  echo -e "\033[0;31m【requests chainer】\033[0;39m"
  conda install -y beautifulsoup4
  conda install -y requests
  conda install -y -c conda-forge selenium=3.4.3
  conda install -y pandas

  pip install --upgrade chainer
  pip install --upgrade keras==2.0.5
  pip install --upgrade tensorflow==1.2.1
  pip install https://ci.tensorflow.org/view/Nightly/job/nightly-python35-linux-cpu/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow-1.3.0rc2-cp35-cp35m-linux_x86_64.whl
  pip install --upgrade scikit-learn==0.18.1
  pip install --upgrade opencv-python

  # PhantomJS
  echo -e "\033[0;31m【PhantomJS】\033[0;39m"
  sudo yum install -y wget fontconfig-devel
  sudo yum install -y epel-release
  sudo rpm -ivh http://repo.okay.com.mx/centos/6/x86_64/release/okay-release-1-1.noarch.rpm
  sudo yum search all phantomjs
  sudo yum install -y phantomjs.x86_64

  source ~/.bashrc
fi

PHP

rm -f setup_php.sh; touch setup_php.sh; chmod u+x setup_php.sh; vi setup_php.sh
#!/bin/bash

if [ "$UID" -eq 0 ];then

yum -y install epel-release.noarch
cp -p /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.org
sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/epel.repo

rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
cp -p /etc/yum.repos.d/remi.repo /etc/yum.repos.d/remi.repo.org
sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/remi.repo

yum -y install httpd
systemctl start httpd.service
systemctl enable httpd.service

yum -y remove mariadb-libs
yum -y remove mysql*

yum -y install http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
yum -y install mysql-community-server

systemctl start mysqld.service
systemctl enable mysqld.service

cat /var/log/mysqld.log | grep 'password is generated'

mysql_secure_installation




else
  echo "non-root user!"
fi

http://qiita.com/nissuk/items/2b1aee7f81f351c7ab05

Node.js

rm -f setup_nodejs.sh; touch setup_nodejs.sh; chmod u+x setup_nodejs.sh; vi setup_nodejs.sh
#!/bin/bash

if [ "$UID" -eq 0 ];then
  # インストール epel
  echo -e "\033[0;31m【インストール epel】\033[0;39m"
  yum install -y epel-release

  # インストール nodejs npm
  echo -e "\033[0;31m【インストール nodejs npm】\033[0;39m"
  yum install -y nodejs npm
else
  echo "non-root user!"
fi

DB

MySQL

https://github.com/lochuynh-mediba/DL_PJ_1/tree/9c123ad4413c4182237258f59d8f021497b897f5/ansible/playbooks/roles/mysql57-server/files

rm -f setup_mysql.sh; touch setup_mysql.sh; chmod u+x setup_mysql.sh; vi setup_mysql.sh
#!/bin/bash

if [ "$UID" -eq 0 ];then
  echo -e "\033[0;31m【remove mariadb】\033[0;39m"
  yum -y remove mariadb-libs

  echo -e "\033[0;31m【install mysql】\033[0;39m"
  yum -y localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
  yum -y install mysql-community-server

  echo -e "\033[0;31m【start enable mysqld.service】\033[0;39m"
  systemctl start mysqld.service
  systemctl enable mysqld.service
else
  echo "non-root user!"
fi

[手動]

cat /var/log/mysqld.log | grep password

mysql -u root -p
---------------
SET GLOBAL validate_password_length=6;
SET GLOBAL validate_password_policy=LOW;
ALTER USER root@localhost IDENTIFIED BY 'vagrant';
exit
---------------

PostgreSQL

rm -f setup_postgresql.sh; touch setup_postgresql.sh; chmod u+x setup_postgresql.sh; vi setup_postgresql.sh
#!/bin/bash

if [ "$UID" -eq 0 ];then
  echo -e "\033[0;31m【install postgresql】\033[0;39m"
  yum -y install postgresql-server
  postgresql-setup initdb

  echo -e "\033[0;31m【start enable postgresql】\033[0;39m"
  systemctl start postgresql
  systemctl enable postgresql
else
  echo "non-root user!"
fi

[手動]

sudo passwd postgres

su - postgres
---------------
psql -c "ALTER USER postgres WITH PASSWORD 'vagrant'"
exit
---------------

#!/bin/sh
cat <<EOF > /etc/supervisord.d/postgresql.conf
[program:postgresql]
command=/usr/bin/postgres -D /var/lib/pgsql/data
user=postgres
autorestart=true
EOF

cat <<EOF > /var/lib/pgsql/data/pg_hba.conf
local   all         all                               trust
host    all         all         127.0.0.1/32          trust
host    all         all         192.168.0.0/24        trust
host    all         all         ::1/128               trust
EOF


cat <<EOF > /var/lib/pgsql/data/postgresql.conf
listen_addresses = '*'
EOF

Mongodb

#!/bin/bash

if [ "$UID" -eq 0 ];then
  echo -e "\033[0;31m【インストール mongodb】\033[0;39m"
  echo '[mongodb]' >> /etc/yum.repos.d/mongodb.repo
  echo 'name=MongoDB repo' >> /etc/yum.repos.d/mongodb.repo
  echo 'baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/' >> /etc/yum.repos.d/mongodb.repo
  echo 'gpgcheck=0' >> /etc/yum.repos.d/mongodb.repo
  echo 'enabled=1' >> /etc/yum.repos.d/mongodb.repo

  echo -e "\033[0;31m【install -y mongodb】\033[0;39m"
  yum install -y mongodb-org

  echo -e "\033[0;31m【mongoスタート】\033[0;39m"
  service mongod start
  service mongod enable
else
  echo "non-root user!"
fi

spark

echo -e "\033[0;32m【scala】\033[0;39m"
wget http://downloads.typesafe.com/scala/2.11.7/scala-2.11.7.tgz
tar zxfv scala-2.11.7.tgz
mv scala-2.11.7 /usr/

echo -e "\033[0;32m【spark】\033[0;39m"
wget http://ftp.riken.jp/net/apache/spark/spark-1.5.2/spark-1.5.2-bin-hadoop2.6.tgz
tar zxfv spark-1.5.2
mv spark-1.5.2 /usr/

echo 'export SCALA_HOME=/usr/scala-2.11.7' >> ~/.bash_profile
echo 'export SPARK_HOME=/usr/spark-1.5.2' >> ~/.bash_profile
echo 'export PATH=$SCALA_HOME/bin:$PATH' >> ~/.bash_profile

spark(コンソール)の起動

cd $SPARK_HOME
bin/spark-shell

Jenkins

#!/usr/bin/env bash

sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

sudo yum install jenkins -y

Cloud9

# rootで実行
sudo sed -i "s/\(^SELINUX=\).*/\1disabled/" /etc/selinux/config
sudo getenforce

sudo yum install -y httpd

sudo yum install -y glibc-static
sudo yum install -y epel-release
sudo yum install -y nodejs
sudo yum install -y npm --enablerepo=epel

python -V
node -v

sudo systemctl start httpd
sudo systemctl enable httpd

sudo systemctl stop firewalld
sudo systemctl disable firewalld

# 通常ユーザーで実行
cd ~/
git clone https://github.com/c9/core.git cloud9
cd cloud9
./scripts/install-sdk.sh

# サーバー起動
node server.js -l 0.0.0.0 -p 8080 -a :

python -V
> Python 2.7.5

node -v
> v0.10.42

firewall-cmd --permanent --zone=public --add-service=ssh
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --permanent --zone=public --add-service=mysql
firewall-cmd --permanent --zone=public --add-port=8080/tcp
firewall-cmd --reload

http://qiita.com/okamu_/items/1c8e5fde742ca165fa12#cloud9

Heroku

sudo wget -qO- https://toolbelt.heroku.com/install.sh | sh
echo 'PATH="/usr/local/heroku/bin:$PATH"' >> .bash_profile 
source .bash_profile 
chmod 0600 /home/vagrant/.netrc
heroku version
heroku login

Enter your Heroku credentials.
Email: メールアドレス
Password (typing will be hidden): パスワード

AWS CLI

rpm -iUvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm

# or
wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
rpm -Uvh epel-release-7-5.noarch.rpm

yum -y update

yum -y install python-pip

pip install awscli

[root ]# aws
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help
  aws: error: too few arguments
[root ~]# 
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした