Fedora 22にLAMP(Linux、Apache、MySQL、PHP)をインストールする方法

前書き

LAMPスタックは、Webサーバーを稼働させるために使用されるオープンソースソフトウェアのグループです。 頭字語は、Linux、Apache、MySQL、およびPHPを表します。 サーバーはすでにFedoraを実行しているため、Linuxの部分は処理されます。 残りのインストール方法は次のとおりです。

前提条件

このチュートリアルを開始する前に、実行中のFedora 22ドロップレットがあり、SSH経由でログインする必要があります。

セットアップ

LAMPプログラムのインストールを開始する前に、まず、バージョン22のFedoraのデフォルトパッケージマネージャーとしてdnf update dnfがyumに置き換えられたすべての更新をダウンロードしてインストールする必要があります。

sudo dnf update

[[step-one—install-apache]] ==ステップ1-Apacheをインストールします

Apacheは、世界のWebサーバーの50%以上を実行する無料のオープンソースソフトウェアです。

Apacheをインストールするには、ターミナルを開き、次のコマンドを入力します。

sudo dnf install httpd

インストールが完了すると、VPSでApacheを実行できます。

sudo systemctl start httpd.service

それでおしまい。 Apacheがインストールされているかどうかを確認するには、ブラウザにサーバーのIPアドレスを指定します(例: http://12.34.56.789)。 デフォルトのFedoraページが表示されます
Fedora Default

[[ドロップレットのIPアドレスを見つける方法]] ===ドロップレットのIPアドレスを見つける方法

次のコマンドを実行して、サーバーのIPアドレスを表示できます。

ifconfig eth0 | grep inet | awk '{ print $2 }'

[[step-two—install-mysql]] ==ステップ2—MySQLをインストールします

MySQL/MariaDB is a powerful database management system used for organizing and retrieving data on a virtual server

MySQLをインストールするには、ターミナルを開き、次のコマンドを入力します。

sudo dnf install mysql mysql-server
sudo systemctl start mariadb.service

インストールが完了したら、ルートMySQLパスワードを設定できます。

sudo /usr/bin/mysql_secure_installation

プロンプトが表示され、現在のルートパスワードが求められます。

MySQLをインストールしたばかりなので、おそらくMySQLがないので、Enterキーを押して空白のままにします。

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

次に、rootパスワードを設定するかどうかを尋ねるプロンプトが表示されます。 先に進み、Yを選択して指示に従います。

FedoraはMySQLの設定プロセスを自動化し、一連のyesまたはnoの質問をします。

すべてのオプションで「はい」と言うのが最も簡単です。 最後に、MySQLは新しい変更をリロードして実装します。

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!

[[step-three—install-php]] ==ステップ3—PHPをインストールする

PHPは、動的なWebページを構築するために広く使用されているオープンソースのWebスクリプト言語です。

仮想プライベートサーバーにPHPをインストールするには、ターミナルを開き、次のコマンドを入力します。

sudo dnf install php php-mysql

PHPプロンプトにyesと答えると、PHPは自動的にインストールされます。

PHPモジュール

PHPには、サーバーに追加できるさまざまな便利なライブラリとモジュールもあります。 次のように入力して、使用可能なライブラリを確認できます。

dnf search php-

端末は、可能なモジュールのリストを表示します。 最初は次のようになります。

php-fpdf-doc.noarch : Documentation for php-fpdf
php-libvirt-doc.noarch : Document of php-libvirt
php-pear-Auth-radius.noarch : RADIUS support for php-pear-Auth
php-pear-Auth-samba.noarch : Samba support for php-pear-Auth
ice-php-devel.i686 : PHP tools for developping Ice applications
ice-php-devel.x86_64 : PHP tools for developping Ice applications
perl-PHP-Serialization.noarch : Converts between PHP's serialize() output and
                              : the equivalent Perl structure
php-IDNA_Convert.noarch : Provides conversion of internationalized strings to
                        : UTF8
php-Kohana.noarch : The Swift PHP Framework
php-LightweightPicasaAPI.noarch : A lightweight API for Picasa in PHP
php-PHPMailer.noarch : PHP email transport class with a lot of features
php-Smarty.noarch : Template/Presentation Framework for PHP
php-ZendFramework.noarch : Leading open-source PHP framework
php-ZendFramework-Auth-Adapter-Ldap.noarch : Zend Framework LDAP
                                           : Authentication Adapter
php-ZendFramework-Cache-Backend-Apc.noarch : Zend Framework APC cache backend

各モジュールの機能の詳細を確認するには、ターミナルに次のコマンドを入力し、モジュールの名前を知りたいライブラリに置き換えます。

dnf info name of the module

モジュールのインストールを決定したら、次を入力します。

sudo dnf install name of the module

各モジュールの名前をスペースで区切ることにより、複数のライブラリを一度にインストールできます。

おめでとうございます。 これで、ドロップにLAMPスタックができました!

また、サーバーの起動時にプロセスが自動的に実行されるように設定する必要があります(Apacheが起動すると、phpが自動的に実行されます)。

sudo chkconfig httpd on
sudo chkconfig mariadb on

[[step-four—results-see-php-on-your-server]] ==ステップ4—結果:サーバー上のPHPを参照してください

LAMPは仮想サーバーにインストールされていますが、簡単なphp情報ページを作成することで、オンラインでコンポーネントを確認できます。

これを設定するには、まずnanoテキストエディターをインストールし、新しいファイルを作成します。

sudo dnf install nano
sudo nano /var/www/html/info.php

次の行を追加します。

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

すべての変更が仮想サーバーで有効になるように、Apacheを再起動します。

sudo systemctl restart httpd.service

最後に、php情報ページにアクセスします(サンプルのIPアドレスを正しいアドレスに置き換えてください):http://12.34.56.789/info.php

これは次のようになります。

PHP Info

Related