LoginSignup
8
10

More than 5 years have passed since last update.

WordPress用のFTPサーバをCentOSで構築

Last updated at Posted at 2016-03-26

[目的]
WordPressのテーマやプラグインをインストール・アップデートをする際に、FTPサーバが必要なため、CentOSのサーバにFTPサーバを構築する。

WordPressのインストールが完了 しても、のテーマやプラグインのインストール・アップデートをする際に、FTPサーバが必要になるため、CentOSのサーバに vsftpd でFTPサーバを構築する。

vsftpdのインストール

vsftpdのインストール
sudo yum install vsftpd
[sudo] password for user1: 
読み込んだプラグイン:fastestmirror, remove-with-leaves, show-leaves
base                                                     | 3.6 kB     00:00     
epel/x86_64/metalink                                     | 3.3 kB     00:00     
epel                                                     | 4.3 kB     00:00     
extras                                                   | 3.4 kB     00:00     
groonga                                                  | 2.5 kB     00:00     
mysql-connectors-community                               | 2.5 kB     00:00     
mysql-tools-community                                    | 2.5 kB     00:00     
mysql56-community                                        | 2.5 kB     00:00     
updates                                                  | 3.4 kB     00:00     
(1/3): epel/x86_64/updateinfo                              | 523 kB   00:00     
(2/3): epel/x86_64/primary_db                              | 3.9 MB   00:00     
(3/3): updates/7/x86_64/primary_db                         | 3.2 MB   00:00     
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.riken.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ vsftpd.x86_64 0:3.0.2-10.el7 を インストール
--> 依存性解決を終了しました。

依存性を解決しました

================================================================================
 Package          アーキテクチャー バージョン              リポジトリー    容量
================================================================================
インストール中:
 vsftpd           x86_64           3.0.2-10.el7            base           167 k

トランザクションの要約
================================================================================
インストール  1 パッケージ

総ダウンロード容量: 167 k
インストール容量: 347 k
Is this ok [y/d/N]: y
Downloading packages:
vsftpd-3.0.2-10.el7.x86_64.rpm                             | 167 kB   00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  インストール中          : vsftpd-3.0.2-10.el7.x86_64                      1/1 
  検証中                  : vsftpd-3.0.2-10.el7.x86_64                      1/1 

インストール:
  vsftpd.x86_64 0:3.0.2-10.el7                                                  

完了しました!
New leaves:
  vsftpd.x86_64

vsftpdの設定

vsftpd設定ファイル修正

設定ファイルの修正
sudo vim /etc/vsftpd/vsftpd.conf
匿名利用禁止にするためNOに変更
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
ホームディレクトリを/var/www/public_htmlに設定し、wwwより上層には行けないよう設定するために追記
local_root=public_html
タイムスタンプを日本時間に設定するために追記
use_localtime=YES 

上層アクセスユーザーリスト作成

上層アクセスユーザーリストを作成し、自分のアカウントのみ追記する
sudo vim /etc/vsftpd/chroot_list
user1

vsftpd起動

vsftpd起動

systemctl start vsftpd

自動起動設定

自動起動ON
chkconfig vsftpd on
自動起動設定確認
systemctl is-enabled vsftpd
enabled

SSL/TSLの設定

設定ファイルの修正

certsディレクトリへ移動
cd /etc/pki/tls/certs/
サーバ証明書の作成
sudo openssl req -x509 -nodes -newkey rsa:1024 -keyout /etc/pki/tls/certs/vsftpd.pem -out /etc/pki/tls/certs/vsftpd.pem
[sudo] password for user1: 
Generating a 1024 bit RSA private key
.++++++
.............++++++
writing new private key to '/etc/pki/tls/certs/vsftpd.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
サーバの所在国を入力
Country Name (2 letter code) [XX]:JP
都道府県を入力
State or Province Name (full name) []:Tokyo 
市区町村を入力
Locality Name (eg, city) [Default City]: 
組織名を入力 
Organization Name (eg, company) [Default Company Ltd]:
部署名を入力
Organizational Unit Name (eg, section) []:
ホスト名を入力
Common Name (eg, your name or your server's hostname) []:
メールアドレスを入力
Email Address []:

設定ファイルのパーミッション変更

sudo chmod 600 vsftpd.pem

vsftpdファイルの設定追加

vsftpdの設定ファイルに追加
sudo vim /etc/vsftpd/vsftpd.conf
サーバ証明書を指定 
rsa_cert_file=/etc/pki/tls/certs/vsftpd.pem
SSL有効化
ssl_enable=YES
通信のSSL使用を強制しない
force_local_data_ssl=NO
ユーザー認証のSSL使用を強制しない
force_local_logins_ssl=NO

再起動して設定反映

systemctl restart vsftpd

WordPressのアップデートが Error: There was an error connecting to the server, Please verify the settings are correct. となり、エラーになる場合は、wp-config.php に以下の設定を追加。

define( 'FS_METHOD', 'direct' );
8
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
10