このチュートリアルでは、LAMPをManjaro 20にインストールする方法を説明します。知らなかった方のために、 LAMP Linux、Apache、MySQL / MariaDB、PHPまたはPerl、またはPythonの略です。すべてのコンポーネントは無料のオープンソースソフトウェアであり、この組み合わせは動的なWebページの構築に適しています。 LAMPスタックは、世界で最も人気のあるサーバー構成の1つです。
この記事は、少なくともLinuxの基本的な知識があり、シェルの使用方法を知っていること、そして最も重要なこととして、サイトを独自のVPSでホストしていることを前提としています。インストールは非常に簡単で、ルートアカウントで実行されていますが、そうでない場合は、'sudo
を追加する必要があります。 ルート権限を取得するコマンドに‘。 Manjaro 20(ニビア)にLAMPスタックを段階的にインストールする方法を紹介します。
前提条件
- 次のオペレーティングシステムのいずれかを実行しているサーバーまたはデスクトップ:ManjaroまたはArchLinux。
- 潜在的な問題を防ぐために、OSの新規インストールを使用することをお勧めします。
- サーバーへのSSHアクセス(またはデスクトップを使用している場合はターミナルを開く)
non-root sudo user
またはroot user
へのアクセス 。non-root sudo user
として行動することをお勧めします ただし、ルートとして機能するときに注意しないと、システムに害を及ぼす可能性があるためです。
Manjaro20NibiaにLAMPをインストールする
ステップ1.以下のチュートリアルを実行する前に、システムが最新であることを確認してください。
sudo pacman -Syu
ステップ2.Apacheをインストールします。
次のコマンドを使用してApacheWebサーバーをインストールしましょう:
sudo pacman -S apache
インストールが完了したら、/etc/httpd/conf/httpd.conf
にあるApache構成ファイルを開きます。 、次の行を検索してコメントします:
#LoadModule unique_id_module modules / mod_unique_id.so
これで、次のコマンドを使用してApacheサーバーを有効にして起動できます。
sudo systemctl enable httpd sudo systemctl restart httpd
ステップ3.MySQLをインストールします。
次のコマンドを実行して、MySQLサーバーをManjaroにインストールします。
sudo pacman -S mysql
完了したら、次のコマンドを使用してMySQLデータディレクトリを初期化することから始めます。
sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
次に、次のコマンドを使用して有効にし、開始します。
sudo systemctl enable mysqld sudo systemctl restart mysqld
デフォルトでは、MySQLは強化されていません。mysql_secure_installation
を使用してMySQLを保護できます。 脚本。ルートパスワードを設定し、匿名ユーザーを削除し、リモートルートログインを禁止し、テストデータベースと安全なMySQLへのアクセスを削除する各手順を注意深く読んでください。
$ 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をインストールします。
ManjaroにPHPおよびPHPApacheモジュールをインストールするには、pacman
を使用するだけです。 コマンド:
sudo pacman -S php php-apache
インストール後、PHPを構成する必要があります。ファイルを編集します:/etc/httpd/conf/httpd.conf:
sudo nano /etc/httpd/conf/httpd.conf
次の行を見つけてコメントします:
#LoadModule mpm_event_module modules/mod_mpm_event.so
また、コメントを外すか、次の行を追加します:
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
次に、構成ファイルの下部に次の行を追加します。
LoadModule php7_module modules/libphp7.so AddHandler php7-script php Include conf/extra/php7_module.conf
ファイルを保存して終了します。Apacheサーバーを再起動して、すべての構成が正しくロードされていることを確認します。
sudo systemctl restart httpd
PHPのインストールをテストするには、/srv/http/phpinfo.php
にファイルを作成します。 次のPHPコードを記述します。
<?php phpinfo(); ?>
次に、localhost/phptest.php
にアクセスして、このファイルをブラウザで開きます。 最新のPHPバージョンのApacheサーバーがManjaroLinuxにインストールされていることを確認してください。
おめでとうございます!LAMPサーバーが正常にインストールされました。Manjaro20システムにLAMP(Apache、MariaDB、PHP)をインストールするためにこのチュートリアルを使用していただきありがとうございます。追加のヘルプや役立つ情報については、お勧めします。 Apache、MariaDB、およびPHPの公式Webサイトを確認してください。