[[Linuxめも]]

#contents

*日本語化 [#pf4ec3f0]

 # localectl set-locale LANG=ja_JP.UTF-8
 # source /etc/locale.conf 

*SELinuxを無効化 [#i87d33e8]

 # vi /etc/sysconfig/selinux

 #SELINUX=enforcing
 SELINUX=disabled

サーバを再起動

*vsftpdのインストール [#rf599119]

 # yum install vsftpd
 # vi /etc/vsftpd/vsftpd.conf

 anonymous_enable=NO
 ascii_upload_enable=YES
 ascii_download_enable=YES
 chroot_local_user=YES
 chroot_list_enable=YES
 chroot_list_file=/etc/vsftpd/chroot_list
 ls_recurse_enable=YES
 use_localtime=YES

 # touch /etc/vsftpd/chroot_list
 # chmod 600 /etc/vsftpd/chroot_list
 # /etc/rc.d/init.d/vsftpd start

起動

 # systemctl start vsftpd.service

自動起動設定

 # chkconfig vsftpd on
 # systemctl enable vsftpd.service

設定確認

 # chkconfig --list vsftpd
 # systemctl is-enabled vsftpd.service

*PostgreSQLのインストール [#mee6e453]

 # yum install postgresql-server

自動起動設定

 # chkconfig postgresql on
 # systemctl is-enabled postgresql.service

データベースの初期化

 # su postgres
 $ initdb --encoding=UTF8 --no-locale -D /var/lib/pgsql/data
 # postgresql-setup initdb

起動

 # /etc/rc.d/init.d/postgresql start
 # systemctl start postgresql.service

無ければ

 # service postgresql start

*MySQLのインストール [#d69464f3]

 # yum install mysql mysql-devel mysql-server
 # /etc/rc.d/init.d/mysqld start

自動起動設定

 # chkconfig mysqld on

コンソール経由で文字化けする場合

設定ファイルに2行を追加してMySQLを再起動

 # vi/etc/my.cnf

 [mysqld]
 default-character-set=utf8
 skip-character-set-client-handshake

**MariaDBのインストール [#vc9b31ee]

CentOS7からはMySQLと互換性があるMariaDBが標準になっているようです。

 # yum install mariadb mariadb-server

起動

 # systemctl start mariadb.service

停止

 # systemctl stop mariadb.service

自動起動を有効にする

 # systemctl enable mariadb.service

確認

 # systemctl is-enabled mariadb.service

最新版を入れたい場合

 # curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
 # yum install MariaDB-server

curlでエラーが出た場合は curl を update

 curl: (35) Peer reports incompatible or unsupported protocol version.
 # yum curl update

*Apacheのインストール [#i3eca5e0]

 # yum install httpd

自動起動設定

 # chkconfig httpd on
 # systemctl enable httpd.service

起動
確認

 # /etc/rc.d/init.d/httpd start
 # systemctl is-enabled httpd.service

無ければ
起動

 # systemctl start httpd.service

CentOS7の場合、configtestとgracefulはserviceを使用します。

 # service httpd configtest

 # vi /etc/httpd/conf/httpd.conf

 ServerName localhost:80
 UseCanonicalName On
 
 <IfModule mod_userdir.c>
     UserDir public_html
 </IfModule>
 
 <Directory /home/*/public_html>
     AllowOverride All
     Options FollowSymlinks ExecCGI
     <Limit GET POST OPTIONS>
         Order allow,deny
         Allow from all
     </Limit>
     <LimitExcept GET POST OPTIONS>
         Order deny,allow
         Deny from all
     </LimitExcept>
 </Directory>

*つながらない場合 [#t9b7d63f]

firewalldとやらがじゃまをしているらしいので停止

 # systemctl stop firewalld

再起動後も自動起動しないようにするためには

 # systemctl disable firewalld

*エラーになる場合 [#m3a87981]

 # yum list
 読み込んだプラグイン:fastestmirror
 base                                                                                                                 | 3.6 kB  00:00:00
 
 
  One of the configured repositories failed (不明),
  and yum doesn't have enough cached data to continue. At this point the only
  safe thing yum can do is fail. There are a few ways to work "fix" this:
 
      1. Contact the upstream for the repository and get them to fix the problem.
 
      2. Reconfigure the baseurl/etc. for the repository, to point to a working
         upstream. This is most often useful if you are using a newer
         distribution release than is supported by the repository (and the
         packages for the previous distribution release still work).
 
      3. Disable the repository, so yum won't use it by default. Yum will then
         just ignore the repository until you permanently enable it again or use
         --enablerepo for temporary usage:
 
             yum-config-manager --disable <repoid>
 
      4. Configure the failing repository to be skipped, if it is unavailable.
         Note that yum will try to contact the repo. when it runs most commands,
         so will have to try and fail each time (and thus. yum will be be much
         slower). If it is a very temporary problem though, this is often a nice
         compromise:
 
             yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
 
 Cannot retrieve metalink for repository: epel/x86_64. Please verify its path and try again

デバッグでログを取ってみる
 # URLGRABBER_DEBUG=1 yum check-update 2> /tmp/debug.log

SSLが問題っぽい
 * NSS error -12190 (SSL_ERROR_PROTOCOL_VERSION_ALERT)

NSSをupdate
 # yum --disablerepo=epel update nss

curlのバージョンが古いことが問題っぽい

 # yum --disablerepo=epel update curl

*PHPのインストール [#lc043ef2]

 # yum install php php-cli php-common php-mbstring php-pdo php-pgsql php-mysql php-gd php-pear php-xml php-intl

**PHP7のインストール [#o26c9768]

 # yum install epel-release
 # rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
 # yum install --enablerepo=remi,remi-php71 php php-cli php-common php-mbstring php-pdo php-pgsql php-mysql php-gd php-pear php-xml php-intl

7.2系の場合
 # yum install --enablerepo=remi-php72 php php-cli php-common php-mbstring php-pdo php-pgsql php-mysql php-gd php-pear php-xml php-intl

**PHP7のバージョンアップ [#z0033b7f]

yumでインストールしたPHPのバージョンが 7.0.30 であったので、7.1以降にバージョンアップしてみました。

 # yum --enablerepo=remi-php71 install php
 # php -v
 PHP 7.1.20 (cli) (built: Jul 19 2018 10:10:15) ( NTS )
 Copyright (c) 1997-2018 The PHP Group
 Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

PHP7.3にバージョンアップしてみました。

 # rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
 # yum install --enablerepo=remi-php73 php
 # php -v
 PHP 7.3.12 (cli) (built: Nov 19 2019 10:24:51) ( NTS )
 Copyright (c) 1997-2018 The PHP Group
 Zend Engine v3.3.12, Copyright (c) 1998-2018 Zend Technologies
     with Zend OPcache v7.3.12, Copyright (c) 1999-2018, by Zend Technologies


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS