WordPress を FTP を使わず Curl でダウンロード、解凍して使う。

WordPress の公式サイト から tar.gz のダウンロードリンクを探して、アドレスをコピーする。
(もしくは http://ja.wordpress.org/latest-ja.tar.gz のアドレスをコピーして最新版を使う)

f:id:hirose-test:20181227220942j:plain

コピーしたURLと wgetコマンドで tar ファイルをダウンロードする。(curl だとなぜかうまく解凍できなかった)
wget がインストールされていない場合 yum install wgetで先にwgetをインストールしてください)

[root@localhost ~]# cd /var/www/html/  ←htmlディレクトリに移動
[root@localhost html]# ls
index.html  phpinfo.php

[root@localhost html]# wget http://ja.wordpress.org/latest-ja.tar.gz  
[root@localhost html]# ls
index.html  phpinfo.php   latest-ja.tar.gz ←ダウンロードされてる

[root@localhost html]# tar xzvf  latest-ja.tar.gz  ← x(解凍) z(gzip形式ファイルを) v(詳細情報の表示) f(アーカイブファイルを指定)
 (~中略~)
wordpress/wp-includes/class.wp-dependencies.php
wordpress/wp-signup.php
wordpress/wp-links-opml.php
[root@localhost html]# ls
index.html  phpinfo.php  wordpress  latest-ja.tar.gz
        解凍された ↑

異なったバージョンの WordPressを複数設置したい場合は、最初に解凍したディレクトリ名を mv で変更してからもう一方を解凍する。

[root@localhost html]# ls
index.html  phpinfo.php  wordpress  wordpress-4.7.1-ja.tar.gz  wordpress-5.0.2-ja.tar.gz
[root@localhost html]# mv ./wordpress ./wordpress-5.0.2
[root@localhost html]# ll
合計 19172
-rw-r--r--. 1 root root      141  7月 31 23:27 index.html
-rw-r--r--. 1 root root       24  8月  1 00:18 phpinfo.php
-rw-r--r--. 1 root root  8488132 12月 27 22:16 wordpress-4.7.1-ja.tar.gz
drwxr-xr-x. 5 1006 1006     4096 12月 20 19:04 wordpress-5.0.2
-rw-r--r--. 1 root root 11125446 12月 27 22:05 wordpress-5.0.2-ja.tar.gz
[root@localhost html]# tar xzvf wordpress-4.7.1-ja.tar.gz

解凍後のもう一方もややこしいので名前変更しておいた方がよい。

 (~中略~)
wordpress/xmlrpc.php
wordpress/wp-activate.php
wordpress/wp-trackback.php
[root@localhost html]# ls
index.html   wordpress                wordpress-5.0.2
phpinfo.php  wordpress-4.7.1-ja.tar.gz  wordpress-5.0.2-ja.tar.gz

[root@localhost html]# mv wordpress wordpress-4.7.1
[root@localhost html]# ls
index.html   wordpress-4.7.1            wordpress-5.0.2
phpinfo.php  wordpress-4.7.1-ja.tar.gz  wordpress-5.0.2-ja.tar.gz

また、解凍後のディレクトリはそのままだと所有者がヘンなので apache に変更しておきましょう。
変更しないと後述のように「ファイル wp-config.php に書き込めませんでした」というエラーが出ます。 (/etc/httpd/conf/httpd.conf の User/Group に書いてあるものに合わせる)

[root@localhost html]# ll
合計 19176
-rw-r--r--. 1 root   root           141  7月 31 23:27 index.html
-rw-r--r--. 1 root   root            24  8月  1 00:18 phpinfo.php
drwxr-xr-x. 5 nobody nfsnobody     4096 12月  7  2016 wordpress-4.7.1
-rw-r--r--. 1 root   root       8488132 12月 27 22:16 wordpress-4.7.1-ja.tar.gz
drwxr-xr-x. 5   1006      1006     4096 12月 20 19:04 wordpress-5.0.2
-rw-r--r--. 1 root   root      11125446 12月 27 22:05 wordpress-5.0.2-ja.tar.gz

[root@localhost html]# chown -R apache:apache wordpress-4.7  (-R オプション:ディレクトリの中も全部、を忘れずに)
[root@localhost html]# chown -R apache:apache wordpress-5.0.2

[root@localhost html]# ll
合計 19176
-rw-r--r--. 1 root   root        141  7月 31 23:27 index.html
-rw-r--r--. 1 root   root         24  8月  1 00:18 phpinfo.php
drwxr-xr-x. 5 apache apache     4096 12月  7  2016 wordpress-4.7.1
-rw-r--r--. 1 root   root    8488132 12月 27 22:16 wordpress-4.7.1-ja.tar.gz
drwxr-xr-x. 5 apache apache     4096 12月 20 19:04 wordpress-5.0.2
-rw-r--r--. 1 root   root   11125446 12月 27 22:05 wordpress-5.0.2-ja.tar.gz

f:id:hirose-test:20181227223303j:plain

前述でディレクトリの所有者を適切に変更したにも関わらず、まだ「ファイル wp-config.php に書き込めませんでした」のエラーが出る場合、SELinux が邪魔をしている場合があります。 f:id:hirose-test:20181227230029j:plain

右下にちっちゃく出る。すごく気づきにくい。 f:id:hirose-test:20181227230040j:plain

f:id:hirose-test:20181227230049j:plain

SELinux を停止してから再度試してください。

/* -----codeの行番号----- */