Linux Install

Android

Linux Tools

Linux AV

Linux Memo

WINDOWS

PROGRAM

動画 Memo

音楽 Memo

モバイルアプリ Memo

FILE FORMAT

PROTOCOL

DEVICE

BookMark

その他


centos7.0   

  1. OSのインストールイメージダウンロード
    http://ftp.jaist.ac.jp/pub/Linux/CentOS/7/isos/x86_64/CentOS-7.0-1406-x86_64-Minimal.iso

VMWare で minimal install

  1. 新規仮想マシンの作成
    • 後でOSを位ストール
  2. Linux / CentOS 64 ビット
  3. 仮想ディスクを単一ファイルとして格納
  4. ハードウェアをカスタマイズ
    • 新規 CD/DVD(IDE) - ISOイメージファイルを使用する
    • ネットワークアダプタ - ブリッジ
  5. 仮想マシンの再生
  6. Install CentOS 7
    1. 言語を選択:日本語
    2. network のチェックボックスをONに設定:「完了」
    3. インストール先:そのまま「完了」
    4. パーティション設定をそのまま左上の「完了」
    5. インストールの開始
  7. root のパスワード:脆弱なままだと「完了」を2回

ネットワーク初期設定

ip a

IP が取れていない場合は

nmtui 

で、auto connect にチェックをいれ、OK

DHCPが使えない場合

IP192.168.80.100/24
Gateway192.168.80.2
DNS192.168.80.2

基本コマンド変更点

  • ifconfig
    ip a
  • netstat
    ss 

初期更新

yum -y update
yum -y install emacs nmap lrzsz yum-utils zip unzip wget ntp bind-utils telnet curl bash-completion net-tools samba-client samba-winbind cifs-utils
cat > ~/.emacs
(setq make-backup-files nil)
(setq auto-save-default nil)

package-cleanup --oldkernels --count=1
cat >> /etc/cron.hourly/ntpdate
/usr/sbin/ntpdate ntp.nict.jp
chmod +x /etc/cron.hourly/ntpdate
/etc/cron.hourly/ntpdate
timedatectl set-timezone Asia/Tokyo
localectl set-keymap jp
localectl set-locale LANG=ja_JP.utf8

/etc/ssh/sshd_config

Protocol 2
PasswordAuthentication no
PermitRootLogin no
RSAAuthentication yes
PubkeyAuthentication yes
RhostsRSAAuthentication no
service sshd restart

ssh でログイン

hostname

hostnamectl set-hostname server1.example.com

aws の場合

/etc/cloud/cloud.cfg

 # - update_hostname

selinux/firewall 無効化したい場合

systemctl disable firewalld

/etc/selinux/config

SELINUX=disabled
reboot

apache

yum -y install httpd mod_ssl
systemctl enable httpd
iptables -I INPUT 5 -p tcp -m tcp --dport 80 -j ACCEPT
iptables -I INPUT 5 -p tcp -m tcp --dport 443 -j ACCEPT
firewall-cmd --add-service=http --zone=public --permanent
firewall-cmd --add-service=https --zone=public --permanent
service httpd restart

その他のポートを開けたい場合

firewalld

reverse-proxy などをする場合

/usr/sbin/setsebool -P httpd_can_network_connect 1

ntpd

/etc/ntp.conf

server 0.centos.pool.ntp.org iburst
service ntpd start
ntpq -p
systemctl enable ntpd.service

mariadb

yum -y install mariadb mariadb-server
systemctl enable mariadb.service
systemctl start mariadb.service

/etc/my.cnf

[[mysqld]]
character-set-server=utf8
[mysql]
character-set-server=utf8

php

yum -y install php php-pear
pear upgrade PEAR

ImageMagick

yum -y install ImageMagick ImageMagick-perl ImageMagick-devel ipa-pgothic-fonts

httpd 再起動

systemctl start httpd 

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.rpm
rpm -ivh jdk-8u66-linux-x64.rpm 
旧 wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u66-b17/jdk-8u66-linux-x64.rpm

最新を探す

http://www.oracle.com/technetwork/java/javase/downloads/index.html

上記状態で保存したテンプレートイメージをコピーして再度VMWare で起動した場合、最初に「移動」か「コピー」かを問われる。

同時に2台起動する可能性がある場合は「コピー」を選択する。


epel

yum -y install epel-release

/etc/yum.repos.d/epel.repo

enabled = 0

nkf

yum -y --enablerepo=epel install nkf

jq

yum -y --enablerepo=epel install jq

postgres + postgis

yum -y --enablerepo=epel install postgis postgresql-server
postgresql-setup initdb
systemctl enable postgresql.service
systemctl start postgresql.service

最新を入れたい場合

rpm -Uvh https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum -y install epel-release centos-release-scl
yum -y install --enablerepo=epel postgresql12-server postgresql12-devel postgresql21-contrib gdal postgis30_12.x86_64 postgis30_12-client.x86_64 postgis30_12-devel.x96_64
/usr/pgsql-12/bin/postgresql-12-setup initdb

/var/lib/pgsql/*/data/pg_hba.conf

local   all             all                                     trust
service postgresql-11 restart
psql -U postgres -c "alter role postgres with password '【パスワード】';"

/var/lib/pgsql/*/data/pg_hba.conf

local   all             all                                     password
host    all             all                                     password
systemctl enable postgresql-11
service postgresql-11 restart

git

 yum -y install git --enablerepo=epel

※結構古いので新しいのを入れたい場合はソースからいれる

NTFS マウント

yum -y --enablerepo=epel install dkms fuse-ntfs-3g

/etc/fstab

/dev/sdb2 /mnt/usbhdd ntfs-3g defaults 0 0

ディスクを追加したい

fdisk /dev/sdb
n
p
w

format

mkfs -t xfs /dev/sdb1

mount

blkid /dev/sdb1

/etc/fstab

UUID=7ae7276e-45a4-4780-b096-4e3b4cxxxxxx /mnt/ssd                    xfs     defaults        0 0

samba

yum install samba

sshfs

yum install sshfs --enablerepo=epel
sshfs 192.168.0.1:/mnt/usbhdd /mnt/usbhdd

devtools

yum -y groupinstall 開発ツール

nodejs

git clone https://github.com/creationix/nvm.git ~/.nvm
source ~/.nvm/nvm.sh
nvm install 0

.bashrc

source ~/.nvm/nvm.sh

redis

 yum -y install redis --enablerepo=epel
service redis start
redis-cli
> set 'test' 10
OK
> get 'test'
"10"
> exit

ruby

cd /usr/local/src
wget https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.2.tar.gz
tar xzfp ruby-2.2.2.tar.gz
cd ruby*
./configure --disable-install-doc
make
make install

convmvfs

EUCの HDD を UTF でマウントしたい場合などに使用

cd /usr/src
wget https://github.com/libfuse/libfuse/releases/download/fuse-2.9.7/fuse-2.9.7.tar.gz
tar xzfp fuse-*
cd fuse-*
./configure --prefix=/usr
make 
make install
ldconfig
cd /usr/src
wget "http://osdn.jp/frs/g_redir.php?m=kent&f=%2Ffuse-convmvfs%2Ffuse-convmvfs%2F0.2.6%2Ffuse-convmvfs-0.2.6.tar.gz" -O fuse-convmvfs-0.2.6.tar.gz
tar xzfp fuse-conv*
cd fuse-conv*
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib64/pkgconfig/
make 
make install