レンプについて

LEMPスタックは、Webサーバーを稼働させるためのオープンソースソフトウェアのグループです。 頭字語は、Linux、nginx(Engine xと発音)、MySQL、およびPHPの略です。 サーバーはすでにArchLinuxを実行しているので、Linux部分が処理されます。 残りをインストールする方法は次のとおりです。

設定

このチュートリアルの手順では、ユーザーがroot権限を持っている必要があります。 これを設定する方法は、手順3と4の初期サーバー設定チュートリアルで確認できます。

ステップ1-パックマン

archパッケージマネージャーであるpacmanにはローリングパッケージリリースがあるため、他の手順に進む前にArchとそのリポジトリを更新する必要があります。

sudo pacman -Syu

ステップ2—MySQLをインストールする

すべてが新しく最新の状態になったら、MySQLから始めてサーバーソフトウェアのインストールを開始できます。

sudo pacman -S mysql

MySQLがインストールされたら、mysqlとセキュアインストールプロセスの両方を開始します。 インストール中にMySQLルートパスワードを設定することもできます。

sudo systemctl start mysqld && mysql_secure_installation

MySQLルートパスワードの入力を最初に求められたら、まだ設定されていないため、先に進んでEnterキーを押すことができます。 インストールは次のようになります。

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorization.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...



All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

MySQLを再起動してフォローアップします。

sudo systemctl restart mysqld

ステップ3—nginxをインストールします

MySQLがすべてセットアップされたら、VPSへのnginxのインストールに進むことができます。

sudo pacman -S nginx

nginxはそれ自体では起動しません。 nginxを実行するには、次のように入力します。

sudo systemctl start nginx

ブラウザをIPアドレスに誘導することで、nginxがWebサーバーをインストールしたことを確認できます。

次のコマンドを実行して、VPSのIPアドレスを明らかにすることができます。

curl -s icanhazip.com

ステップ4—PHP-FPMをインストールします

phpアプリケーションを処理するには、php-fpmをインストールする必要があります。

sudo pacman -S php-fpm

インストールしたら、起動します。

sudo systemctl start php-fpm

最後に、php-fpmを使用してphpを実行するようにnginxに指示する必要があります。 これを行うには、最初にnginx構成ファイルを開きます。

sudo nano /etc/nginx/nginx.conf 

phpアプリケーションを扱うロケーションブロックを見つけて、セクションのテキストを次のように置き換えます。

location ~ \.php$ {
      fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
      fastcgi_index  index.php;
      root   /srv/http;
      include        fastcgi.conf;
 }

nginxを保存、終了、再起動します。

sudo systemctl restart nginx

ステップ5-PHP情報ページを作成する

新しいphp構成のすべての詳細をすばやく確認できます。

これを設定するには、最初に新しいファイルを作成します。

sudo nano /srv/http/info.php

次の行を追加します。

<?php
phpinfo();
?>

次に、保存して終了します。

nginxを再起動します

sudo systemctl restart nginx

http://youripaddress/info.phpにアクセスすると、nginxとphp-fpmの構成の詳細を確認できます。

これで、LEMPスタックが仮想プライベートサーバーでセットアップおよび構成されました。

ステップ6—起動時に開始するようにデーモンを構成する

サーバーの再起動後にすべてのLEMPプログラムが自動的に開始されるようにするには、次のようにします。

sudo systemctl enable nginx mysqld php-fpm

これで、LEMPがインストールされます。

EtelSverdlov著