keymapの変更
最初はJPになってしまってるけど、USキーボード使ってるのでUSに変える。
$ localectl list-keymaps // 使用できるキーマップ一覧
$ localectl set-keymap us // キーマップをUSに変更
$ localectl status // 確認
SELinuxの無効化
一時的に無効化。
$ setenforce 0
ずっと無効にしたい場合は、/etc/selinux/config
を編集する。
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing <-ここをdisableにする
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
enforcingになってるのをdisableにしてrebootすればOK。
hostnameの変更
sudo vi /etc/hostname
ここに書いた内容がそのままhost名になる。
sshの設定
sshがインストールされてるか確認。されてなかったらインストールする。
$ yum list installed | grep ssh
$ yum -y install openssh-server
で、設定ファイルを編集する
$ vi /etc/ssh/sshd_config
- Port : 適当なポート番号にする
- Protocol : 今回は2にする
- RSAAuthentication : yes(デフォルト)
- PubkeyAuthentication : yes(デフォルト)
- AuthorizedKeysFile : .ssh/authorized_keys(デフォルト)
- PasswordAuthentication : no
設定ファイルを編集したら、ssh用のポートを解放する。
$ vi /usr/lib/firewalld/services/ssh.xml
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>SSH</short>
<description>Secure Shell (SSH) is a protocol for logging into and executing commands on remote machines. It provides secure encrypted communications. If you plan on accessing your machine remotely via SSH over a firewalled interface, enable this option. You need the openssh-server package installed for this option to be useful.</description>
<port protocol="tcp" port="22"/>
</service>
このport="22"
の部分を先ほど編集したポート番号に合わせる。
編集したらファイアーウォールを再起動。
$ systemctl reload firewalld.service
で次に、~/.ssh/authorized_keys
に公開鍵をコピペしてパーミッションを変更する。
$ sudo chmod 600 ~/.ssh/authorized_keys
$ sudo chmod 700 ~/.ssh
一通り設定し終わったら、sshdを起動。
$ systemctl start sshd.service
$ systemctl status sshd.service
で稼働状況を確認する。
teamspeak3サーバーの設置
ひとまず必要なもののインストール。
$ yum -y install wget
$ yum -y install bzip2
$ yum -y install ld-linux.so.2
次にTS3起動用のユーザを作る。rootやsudo権限のあるユーザで実行しないこと。
$ useradd teamspeak
$ passwd teamspeak
$ su - teamspeak
んで、公式のダウンロードページから環境にあったやつをダウンロードして展開、起動する。
$ wget http://dl.4players.de/ts/releases/3.0.12.4/teamspeak3-server_linux_x86-3.0.12.4.tar.bz2
$ tar -jxvf teamspeak3-server_linux_x86-3.0.12.4.tar.bz2
$ cd teamspeak3-server_linux_x86
$ ./ts3server_startscript.sh start
初回起動時にだけ下記のような出力がされるので、大事に控えておく。めちゃくちゃ大事なので無くさないように。
------------------------------------------------------------------
I M P O R T A N T
------------------------------------------------------------------
Server Query Admin Account created
loginname= "foooo", password= "hogehoge"
------------------------------------------------------------------
------------------------------------------------------------------
I M P O R T A N T
------------------------------------------------------------------
ServerAdmin privilege key created, please use it to gain
serveradmin rights for your virtualserver. please
also check the doc/privilegekey_guide.txt for details.
token=hogehogehogehogehogehogehogehogehogehoge
------------------------------------------------------------------
TS3用のポート開放する。
$ firewall-cmd --add-port=9987/udp --zone=public --permanent
$ firewall-cmd --add-port=10011/udp --zone=public --permanent
$ firewall-cmd --add-port=30033/udp --zone=public --permanent
これでクライアントからログインできるはずなので、先ほどのloginnameとpasswordでログインする。
初回接続時にtokenを聞かれるので、上記のtokenを入力する。
ログインできたら、サーバのルートを右クリックして、Edit Virtual Serverからパスワードをかける。
MySQL 5.7
$ yum localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
$ sudo yum localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
$ sudo yum -y install mysql-community-server
$ systemctl enable mysqld.service
$ systemctl start mysqld.service
$ systemctl status mysqld.service
これでインストール&起動される。初回起動時に/var/log/mysqld.log
にrootの初期パスワードが出力されるので、メモっておく。
$ mysql_secure_installation
セキュリティ関連の初期設定をする。rootパスワードの変更とかとか。
5.7のパスワードポリシー
MEDIUM ポリシーは、パスワードが最低 1 つの数値文字を含み、1 つの小文字および大文字を含み、1 つの特殊文字 (英数字以外) を含む必要があるという条件を追加します。
Apache2
$ sudo yum -y install httpd
$ systemctl enable httpd
$ systemctl start httpd
$ systemctl status httpd
これでインストール完了。80ポートがLISTENになってることを確認する。
ss -nat
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 :::80 :::*
次にファイアーウォールの80番ポートを開放する。
$ firewall-cmd --list-all
interfaces: eth0
sources:
services: dhcpv6-client ssh
ports: 9987/udp 30033/udp 10011/udp
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
デフォルトだとこんな感じでservices
がdhcpv6-client
とssh
なので、http
とhttps
を追加する。
$ sudo firewall-cmd --add-service=http --zone=public --permanent
$ sudo firewall-cmd --add-service=https --zone=public --permanent
$ systemctl restart firewalld.service
Vim
$ sudo yum -y install vim-enhanced
pluginはvim−plugで管理する。
https://github.com/renoinn/dev_server_settings/blob/master/.vimrc
Gogs
gitをインストールする。最新版使いたいけど、ソースからコンパイルは面倒なのでパッケージで我慢。
$ sudo yum -y install git
git用のユーザを作成。
$ sudo adduser git
$ sudo passwd git
Gogsをダウンロードして解凍。今回はバイナリを使う。https://gogs.io/docs/installation/install_from_binary
$ wget https://cdn.gogs.io/gogs_v0.9.13_linux_amd64.zip
$ unzip gogs_v0.9.13_linux_amd64.zip
$ cd gogs
MySQLのユーザとDBを作る。
$ mysql -u root -p < scripts/mysql.sql
$ mysql -u root -p
mysql> CREATE USER 'gogs'@'localhost' IDENTIFIED BY "{password}";
mysql> grant all privileges on gogs.* to 'gogs'@'localhost';
mysql> flush privileges;
公式だとnginxを使ってリバースプロキシしてるけど、Apacheを使う。まずはGogsのapp.ini
を作る。
$ mkdir -p custom/conf
$ vim custom/conf/app.ini
まずはこんな感じで書いておく
[server]
PROTOCOL = http
DOMAIN = server.domain.com
ROOT_URL = http://server.domain.com/git/
HTTP_ADDR = 127.0.0.1
HTTP_PORT = 3000
次にApache用のconfを作る。
$ sudo vim /etc/httpd/conf.d/gogs.conf
内容はこんな感じ。Gogsの方とポートとかパスとかを合わせる。
ServerName server.domain.com
ProxyPass /git http://127.0.0.1:3000
ProxyPassReverse /git http://127.0.0.1:3000
<Location /git>
Order allow,deny
Allow from all
</Location>
で、Apacheを再起動しつつGogsを起動する。
$ systemctl restart httpd
$ ./gogs web
ブラウザでhttp://server.domain.com/git/
にアクセスすると初期設定画面にリダイレクトされるので、DBの項目とかを埋めていく。
何事もなければこれで動くはず。
次にgogsをsystemd経由でgitユーザで実行するようにする。
$ sudo cp scripts/systemd/gogs.service /usr/lib/systemd/system
$ cd
$ sudo cp -r ~/gogs /home/git/gogs
$ sudo chown -R git:git /home/git/gogs
$ su - git
$ mkdir gogs-repositories
こんん感じ。で、元のユーザに戻ってsystemctlでGogsを起動する。
$ exit
$ systemctl start gogs.service
$ systemctl status gogs.service
PHP
yum install epel-release
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum install --enablerepo=remi,remi-php70 php php-devel php-mbstring php-pdo php-gd
PHPでMeCab
sudo rpm -ivh http://packages.groonga.org/centos/groonga-release-1.1.0-1.noarch.rpm
sudo yum makecache
sudo yum install mecab mecab-ipadic
mecab --version
sudo yum install php70-php-pear
sudo php70-pear channel-discover pecl.opendogs.org
sudo php70-pear remote-list -c opendogs
sudo yum install php70-php-devel
sudo yum install gcc
sudo yum install mecab-devel
which mecab-config
sudo php70-pear install opendogs/mecab-beta
これでMeCabの本体とphp−mecabが入る。
Installing '/opt/remi/php70/root/usr/lib64/php/modules/mecab.so'
install ok: channel://pecl.opendogs.org/mecab-0.6.0
configuration option "php_ini" is not set to php.ini location
You should add "extension=mecab.so" to php.ini
こんな感じのメッセージが出てくるので、
sudo cp /opt/remi/php70/root/usr/lib64/php/modules/mecab.so /usr/lib64/php/modules/
sudo chmod 755 /usr/lib64/php/modules/mecab.so
として、/etc/php.d/mecab.ini
にextension=mecab.so
と書いて保存する。
systemctl restart httpd
apacheを再起動して完了。