続いてSSHログインして、ガシガシと入れていきます。
標準リポジトリからのyumだと古いものしか入らないので、普通に入れてしまうと以下のようになってしまいます。
Linux OS: CentOS 7.6.1810
Webサーバ: Apache 2.4.6
データベース: MariaDB 5.5.60
PHP: PHP 5.4.16
WordPress: WordPress 4.9.8
ここでは、remiリポジトリなどの拡張リポジトリからyumで入れる方法をとって、最新ではないですが少しでも新しいものを入れてみます。
1. SSHログインして、epelリポジトリ、remiリポジトリ、iusリポジトリをインストール
$ ssh ji0vwl-aws (configで設定済みの前提) $ sudo -i # timedatectl set-timezone Asia/Tokyo # yum -y update # yum -y install epel-release # yum -y install "http://rpms.famillecollet.com/enterprise/remi-release-7.rpm" # yum -y install "https://centos7.iuscommunity.org/ius-release.rpm" # yum -y install mailcap git wget net-tools bind-utils
2. Apache2.4.35、mod_sslをインストール、設定
# systemctl stop httpd # yum remove httpd # yum remove httpd-tools # yum --disablerepo=base,extras,updates --enablerepo=ius -y install httpd # yum -y install openldap-devel expat-devel # yum --disablerepo=base,extras,updates --enablerepo=ius -y install mod_ssl # mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.old
# vi /var/www/html/index.html ----------------------- <h1>ji0vwl.net</h1> ----------------------- :wq
# chown -R apache:apache /var/www/html # chmod -R 755 /var/www/html # setenforce 0 # vi /etc/selinux/config ----------------------- ... SELINUX=permissive ... ----------------------- :wq
HTTPバーチャルホストの設定
# vi /etc/httpd/conf.d/vhost-http.conf
-----------------------
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName ji0vwl.net
<Directory "/var/www/html/">
Options FollowSymlinks Includes
AllowOverride All
AddType text/html .html
Require all granted
</Directory>
# HTTP -> HTTPS リライトするときはコメントアウト解除
#RewriteEngine on
#RewriteCond %{SERVER_NAME} =ji0vwl.net
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
-----------------------
:wq
# systemctl start httpd.service # systemctl enable httpd.service
3. Let’s EncryptでSSL証明書を取得、HTTPS設定
Let’s Encryptのインストール
# yum -y install certbot python-certbot-apache # certbot ...
HTTPSバーチャルホストの設定
# vi /etc/httpd/conf.d/vhost-https.conf
-----------------------
<IfModule mod_ssl.c>
<VirtualHost *:443>
DocumentRoot /var/www/html
ServerName ji0vwl.net
<Directory "/var/www/html/">
Options FollowSymlinks Includes
AllowOverride All
AddType text/html .html
Require all granted
</Directory>
# Let's Encrypt 証明書
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/ji0vwl.net/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/ji0vwl.net/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/ji0vwl.net/chain.pem
</VirtualHost>
</IfModule>
-----------------------
:wq
4. PHP7.3.00をインストール
# yum -y --enablerepo=epel install libmcrypt # yum -y remove php-* # yum -y install --enablerepo=remi,remi-php73 php php-devel php-mbstring php-pdo php-gd php-xml php-mysql php-opcache php-pecl-apcu # yum -y install php73-php-fpm # systemctl start php73-php-fpm # systemctl enable php73-php-fpm
5. mariaDB 10.3.11をインストール、設定
# curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash # yum -y install MariaDB-server MariaDB-client # systemctl start mariadb # systemctl enable mariadb
# mysql -u root
> update mysql.user set password=password('rootパスワード入力') where # user = 'root';
> flush privileges;
> exit;
WordPress用DB,User,Password作成
# mysql -u root -p > CREATE DATABASE wordpress_db DEFAULT CHARACTER SET UTF8 DEFAULT COLLATE UTF8_GENERAL_CI; > CREATE USER 'wordpress_ur'@'localhost' IDENTIFIED BY 'wp用パスワード入力'; > GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_ur'@'localhost'; > exit;
6. WordPress4.9.8 インストール、設定
# cd /var/www/ # wget https://ja.wordpress.org/wordpress-4.9.8-ja.tar.gz # tar zxvf wordpress-4.9.8-ja.tar.gz # mv html/ html_old # mv wordpress html # chown -R apache:apache html # chmod -R 755 html # cd html
# cp wp-config-sample.php wp-config.php
# vi wp-config.php
-----------------------
...
/** WordPress のためのデータベース名 */
define('DB_NAME', 'wordpress_db');
/** MySQL データベースのユーザー名 */
define('DB_USER', 'wordpress_ur');
/** MySQL データベースのパスワード */
define('DB_PASSWORD', 'wp用パスワード');
/** MySQL のホスト名 */
define('DB_HOST', 'localhost');
/** データベースのテーブルを作成する際のデータベースの文字セット */
define('DB_CHARSET', 'utf8');
/** データベースの照合順序 (ほとんどの場合変更する必要はありません) */
define('DB_COLLATE', '');
/* HTTPS化するにはこれを追記する必要がある*/
$_SERVER['HTTPS'] = 'on';
...
-----------------------
:wq
# systemctl restart httpd.service
7. メモリ不足を解消するためにスワップファイルを作成
# dd if=/dev/zero of=/swapfile bs=1M count=2048 # mkswap /swapfile # swapon /swapfile # chmod 600 /swapfile
# vi /etc/fstab ----------------------- ... /swapfile swap swap defaults 0 0 ... ----------------------- :wq
うまく動かなくて、何度も消したり入れたりしたので上記の通りで完璧に動かないかもしれませんが、最終的には以下の環境が入り、このBlogサーバーが稼働を開始しました。
Linux OS: CentOS 7.6.1810
Webサーバ: Apache 2.4.6 → 2.4.35
データベース: MariaDB 5.5.60 → 10.3.11
PHP: PHP 5.4.16 → 7.3.00
WordPress: WordPress 4.9.8 → 5.0.2(自動更新)