メインコンテンツへスキップ
見出し画像
Photo bym0l

WordPress5.7 をCentOS Stream release 8に入れてみた

    こんにちは。PMPの旅人です。

    今回は2021年4月4日現在最新のWordPress5.7の構築をメモを共有します。
    VertualBox上に作成したCentOS Stream release 8(以下CentOS st8)サーバーにWordPress5.7を構築した手順メモを共有します。

    OSインストール

    VertualBoxにCentOS st8を構築してください。
    詳細な手順はここでは触れません。
    特に断りにない限りroot権限で実施しています。

    dnf check-update
    dnf upgrade
    dnf groupinstall "Development Tools"

    MySQLインストールと設定

    dnf install mysql-server.x86_64

    MySQLバージョン確認と自動起動設定

    mysql --version
    systemctl start mysqld.service
    systemctl enable mysqld.service

    MySQL初期設定を行います。

    mysql_secure_installation
    secure enough. Would you like to setup VALIDATE PASSWORD component?
    Press y|Y for Yes, any other key for No: y

    STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
    Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2

    パスワード強度はSTRONGとしました。検証用で外部に公開しないのであればLOWやMEDIUMでも問題ないと思います。パスワードの設定を行ってください。

    Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
    Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
    Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
    Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
    Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

    WordPress用DB設定

    DB作成

    mysql -u root -p
    CREATE DATABASE 【DB名】 DEFAULT CHARACTER SET utf8;

    WordPress用ユーザ作成、pass設定

    create user '【ユーザ名】'@'localhost' identified by '【パスワード】';
    grant all privileges on 【DB名】.* to '【ユーザ名】'@'localhost';

    Apacheインストールと設定

    dnf install httpd.x86_64
    dnf install httpd mod_ssl
    dnf install php php-xmlrpc php-gd php-pdo php-mysqlnd php-pecl-mysql php-pecl-zip php-pecl-apc
    systemctl restart httpd.service

    /etc/httpd/conf/httpd.confを編集

    <Directory "/var/www/html">内

    Options Indexes FollowSymLinks
     ↓下記に変更
    Options All -Indexes +SymLinksIfOwnerMatch -FollowSymLinks

    AllowOverride None
     ↓下記に変更
    AllowOverride AuthConfig FileInfo Indexes Limit Options=MultiViews,Ind

    編集多ファイルを保存してサービス再起動

    systemctl start httpd.service
    systemctl status httpd.service
    systemctl enable httpd.service

    Firewall設定

    firewall-cmd --add-service=http --zone=public --permanent
    firewall-cmd --add-service=https --zone=public --permanent
    firewall-cmd --reload

    80、443ポートを開放

    PHPインストール

    yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
    yum install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
    
    dnf install dnf-utils
    dnf module install php:remi-7.4

    /etc/httpd/conf/httpd.confを編集

    ファイル内に以下を追記する

    AddType application/x-httpd-php .php
    systemctl restart httpd.serviceへ

    変更を有効化するためサービス再起動する

    WordPressのインストール

    cd /var/www/
    wget https://ja.wordpress.org/latest-ja.tar.gz
    tar xzvf latest-ja.tar.gz 
    mv html/ html.back
    mv wordpress/ html
    cd html
    cp -a wp-config-sample.php wp-config.php
    vi wp-config.php
    define('DB_NAME', 'database_name_here');  WordPress用DB設定で設定した【DB名】
    define('DB_USER', 'username_here'); 同【ユーザ名】
    define('DB_PASSWORD', 'password_here'); 同【ユーザパスワード】

    に書き換える。

    https://api.wordpress.org/secret-key/1.1/salt/

    にアクセスした結果をコピーし同様に書き換え保存する。

    chown -R apache:apache /var/www/html

    ブラウザでサーバのIPにアクセスすれば初期画面が表示されます。

    WordPress構築の参考になれば幸いです。











     
     

    旅渡

     
     
    氷河期世代。大学卒業時唯一の内定がブラック企業。その後派遣社員として就職するもパワハラに耐えながら学び続ける日々→派遣元大手IT企業グループ社員に登用。まだまだ成長するために日々挑戦中。 PMP,MA,技術士補(情報工学部門),元装蹄師

    あなたへのおすすめ