m6uのエンジニアっぽい日記

PHP利用開発やFuelPHP利用開発、PostgreSQL利用開発、Androidアプリ開発、CentOS7サーバー構築など、テクニカルでエンジニアっぽい内容の日記

CentOS 7.3&PHP 7.1.4にFuelPHP 1.8をインストールしてみるテスト

古いサーバーからの引っ越しを前提に、技術習得中

VMware上のゲストOSとしてCentOS 7.3を立ち上げ、Server Worldさんの「PHP 7.1 インストール
CentOS 7 : PHP 7.1 インストール : Server World」に従ってPHP 7.1.4をインストールし、webコンテンツをいじる新規ユーザーwebuserをapacheグループ所属にした上で作業中。
CentOS - CentOS7以降での、FuelPHPのインストール先はどこが良いか(102191)|teratail」で教えてもらった情報を参考に、FuelPHPのPHP7対応版であるv1.8をインストールしてみたときの記録。
「/var/www」の下に、fuelディレクトリを作って、そこにインストールしてみたときのログ。

composer create-projectコマンドを使ってさくっと展開

[webuser@localhost fuel]$ composer create-project fuel/fuel --prefer-dist .
Installing fuel/fuel (1.8.0.1)
- Installing fuel/fuel (1.8.0.1): Loading from cache
Created project in .
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 13 installs, 0 updates, 0 removals
- Installing composer/installers (v1.4.0): Loading from cache
- Installing fuelphp/upload (2.0.6): Loading from cache
- Installing michelf/php-markdown (1.4.0): Loading from cache
- Installing psr/log (1.0.2): Loading from cache
- Installing monolog/monolog (1.18.2): Loading from cache
- Installing phpseclib/phpseclib (2.0.0): Loading from cache
- Installing fuel/core (1.8.0.4): Loading from cache
- Installing fuel/auth (1.8.0.4): Loading from cache
- Installing fuel/email (1.8.0.4): Loading from cache
- Installing fuel/oil (1.8.0.4): Loading from cache
- Installing fuel/orm (1.8.0.1): Loading from cache
- Installing fuel/parser (1.8.0.4): Loading from cache
- Installing fuel/docs (1.8.0.4): Loading from cache
fuel/fuel suggests installing dwoo/dwoo (Allow Dwoo templating with the Parser package)
fuel/fuel suggests installing mustache/mustache (Allow Mustache templating with the Parser package)
fuel/fuel suggests installing smarty/smarty (Allow Smarty templating with the Parser package)
fuel/fuel suggests installing twig/twig (Allow Twig templating with the Parser package)
fuel/fuel suggests installing pyrocms/lex (Allow Lex templating with the Parser package)
fuel/fuel suggests installing mthaml/mthaml (Allow Haml templating with Twig supports with the Parser package)
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server)
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server via PHP Driver)
monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome)
monolog/monolog suggests installing raven/raven (Allow sending log messages to a Sentry server)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
phpseclib/phpseclib suggests installing ext-libsodium (SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.)
phpseclib/phpseclib suggests installing ext-mcrypt (Install the Mcrypt extension in order to speed up a few other cryptographic operations.)
phpseclib/phpseclib suggests installing ext-gmp (Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.)
phpseclib/phpseclib suggests installing pear-pear/PHP_Compat (Install PHP_Compat to get phpseclib working on PHP < 5.0.0.)
Writing lock file
Generating autoload files
[webuser@localhost fuel]$

って、いつの間にかv1.8.0.1が出てたんですね! しかも、「fuelphp/upload (2.0.6)」とかv2側のパッケージも追加されていたりして。

public/index.phpの改変

諸々のディレクトリ指定をこんな風に書き換えて、welcome!が表示されて一安心。

define('DOCROOT', '/var/www/html/');
define('APPPATH', '/var/www/fuel/fuel/app/');
define('PKGPATH', '/var/www/fuel/fuel/packages/');
define('COREPATH', '/var/www/fuel/fuel/core/');

CentOS7でSSH必須にしたあとに、個別ユーザーを絞ってパスワード認証を復活させる方法

背景

CentOS7サーバーを立てていて、古いシステムを移植しているのですが、FTP接続するのにSCP/SFTPでなくFTPを使わざるを得ない状況になり、急遽やり方を調べてみました。
なお、この記事については、teratailでの質問:「CentOS - CentOS7&Vsftpdで非SSHユーザーをFTPできるようにしたい(96994)」を再構成したものです。

SSH側とvsftpd側の両方で穴を開ける

なお、前提として、追加したユーザー名「foobarbaz」をグループ「web」に所属させています。

SSH(6.6.1p1-35.el7_3)側

定義ファイル「/etc/ssh/sshd_config」を点検して、ファイル末尾に「Match User foobarbaz」行を追加して、「PasswordAuthentication yes」を加えました。  こんな感じです↓

Match User foobarbaz
  PasswordAuthentication yes

vsftpd(3.0.2-21.el7)側

ユーザー定義用ファイルを置くディレクトリ「userconf」を「/etc/vsftpd」の下に作り:
「# mkdir /etc/vsftpd/userconf」
vsftpdの定義ファイル「/etc/vsftpd/vsftpd.conf」に下記の行を追加し
「user_config_dir=/etc/vsftpd/userconf」
そのディレクトリにfoobarbazというユーザー名そのもののファイル名で定義を
「local_root=/var/www/html/path/to/target/directory」
みたいにしました。
しかし、これだけでは足りず、ファイルを書き込んだり削除できるようにするのと、ルートディレクトリ書き込み権限問題の対策も入れて、最終的にはこうなりました:

write_enable=YES
allow_writeable_chroot=YES
local_root=/var/www/html/path/to/target/directory

rootディレクトリに書き込めるようにしたものの、そもそもlocal_rootの定義で実ルートディレクトリを操作できるようにしているわけでなく、web公開ディレクトリの奥底深くを指定しているので、rootディレクトリを書き込みできる状態になっていても問題ないのです。

それぞれサービスをリスタート

二つのサービスの定義ファイルをいじったわけなので、それぞれ再起動させます。
「# systemctl restart sshd
「# systemctl restart vsftpd」