このチュートリアルでは、Manjaro 20にLEMPをインストールする方法を説明します。知らなかった方のために、 LEMP Linux、Nginx(Engine Xと発音)、MySQL / MariaDB、およびPHPまたはPerlまたはPythonの略です。すべてのコンポーネントは無料のオープンソースソフトウェアであり、この組み合わせは動的なWebページの構築に適しています。 LEMPスタックは、世界で最も人気のあるサーバー構成の1つです。
この記事は、少なくともLinuxの基本的な知識があり、シェルの使用方法を知っていること、そして最も重要なこととして、サイトを独自のVPSでホストしていることを前提としています。インストールは非常に簡単で、ルートアカウントで実行されていますが、そうでない場合は、'sudo
を追加する必要があります。 ルート権限を取得するコマンドに‘。 Manjaro 20(ニビア)にLAMPスタックを段階的にインストールする方法を紹介します。
Manjaro20NibiaにLEMPをインストールする
ステップ1.以下のチュートリアルを実行する前に、システムが最新であることを確認してください。
sudo pacman -Syu
ステップ2.Nginxをインストールします。
以下のコマンドを実行して、ManjaroLinuxにNginxをインストールします。
sudo pacman -S nginx
Nginxをインストールしたら、起動して、システムの起動時に起動できるようにします:
sudo systemctl start nginx sudo systemctl enable nginx
Nginxの設定を確認するには、ブラウザを開いてサーバーのホスト名またはIPアドレスを参照すると、次のようなNginxのデフォルトのテストページが表示されます。
http://your-ip-address
ステップ3.MariaDBをインストールします。
次のコマンドを実行して、MariaDBサーバーをManjaroにインストールします。
sudo pacman -S mariadb
次に、MariaDBデータディレクトリを初期化し、以下に示すようにシステムテーブルを作成します。
sudo mysql_install_db –user=mysql basedir=/usr –datadir=/var/lib/mysql
次に、次のコマンドを使用して有効にし、開始します。
sudo systemctl start mariadb sudo systemctl enable mariadb
デフォルトでは、MariaDBは強化されていません。mysql_secure_installation
を使用してMySQLを保護できます。 脚本。ルートパスワードを設定し、匿名ユーザーを削除し、リモートルートログインを禁止し、テストデータベースと安全なMariaDBへのアクセスを削除する各手順を注意深く読んでください。
$ sudo mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and haven't set the root password yet, you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password or using the unix_socket ensures that nobody can log into the MariaDB root user without the proper authorisation. You already have your root account protected, so you can safely answer 'n'. Switch to unix_socket authentication [Y/n] Y Enabled successfully! Reloading privilege tables.. ... Success! You already have your root account protected, so you can safely answer 'n'. Change the root password? [Y/n] n ... skipping. By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB 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, MariaDB 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 MariaDB installation should now be secure. Thanks for using MariaDB!
ステップ4.PHPをインストールします。
次のコマンドを実行してPHPをインストールします:
sudo pacman -S php php-fpm
インストールが完了したら、php-fpm
を起動して有効にします。 以下のコマンドで起動を開始します:
sudo systemctl start php-fpm sudo systemctl enable php-fpm
Nginx構成ファイルにいくつかの変更を加える必要があります:
sudo nano /etc/nginx/nginx.conf
次の行を追加します:
location ~ \.php$ { fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; root /usr/share/nginx/html; include fastcgi.conf; }
ファイルを保存し、NginxとPHP-FPMの両方を再起動して、変更を有効にします:
sudo systemctl restart nginx sudo systemctl restart php-fpm
PHPのインストールをテストするには、info.php
を作成します /usr/share/nginx/html/
内のファイル パス:
sudo nano /usr/share/nginx/html/info.php
次の行を追加してファイルを保存します:
<?php phpinfo(); ?>
手順5.ファイアウォールを構成します。
Manjaro Linux Webサーバーへの外部接続を許可するには、Webポート80と443を開く必要があります。ただし、最初にufw
をインストールしましょう。 ファイアウォール:
sudo pacman -S ufw sudo ufw allow 80/tcp sudo ufw allow 443/tcp sudo ufw enable
おめでとうございます!LEMPサーバーが正常にインストールされました。Manjaro20システムにLEMP(Nginx、MariaDB、PHP)をインストールするためにこのチュートリアルを使用していただきありがとうございます。追加のヘルプや役立つ情報については、お勧めしますNginx、MariaDB、およびPHPの公式Webサイトを確認してください。