GNU/Linux >> Linux の 問題 >  >> Fedora

PHP5FastCGIとMySQLを使用したLighttpdをFedora21にインストールします

Lighttpdは、高性能環境向けに設計および最適化されたオープンソースのウェブサーバーです。他のWebサーバーと比較してメモリフットプリントが小さく、cpu-loadの効果的な管理、および高度な機能セット(FastCGI、SCGI、Auth、Output-Compression、URL-Rewritingなど)を備えたlighttpdは、サーバーを克服するための完璧なソリューションです。負荷の問題。

ここでは、Fedora21へのphp5とMySQLを使用したlighttpdのインストールについて説明します。

Lighttpdのインストール:

まず、Lighttpdをインストールし、ターミナルを開いてrootユーザーに切り替えます。

$ su

ターミナルで次のコマンドを入力し、Enterキーを押します。

# yum install lighttpd

次のコマンドを使用してlighttpdを起動します。

# systemctl start lighttpd.service

lighttpdを自動起動して、システムの起動時に起動します。

# systemctl enable lighttpd.service

Iptables:

Webサーバーへの外部接続を許可するには、ファイアウォールを構成する必要があります。 FirewallDデーモンは、Fedora 21で、着信および発信リクエストをフィルタリングするためのネットフィルターとしてデフォルトで有効になっています。ここでは、静的ファイアウォールを使用して、独自の静的ファイアウォールルールのセットを設定できるようにします。
先に進む前に、 iptablesサービス。

# yum install iptables-services

既存のFirewallDサービスをマスクします。

# systemctl mask firewalld.service

iptablesを有効にして、システムの起動時に自動起動します。

# systemctl enable iptables.service
# systemctl enable ip6tables.service

FirewallDサービスを停止し、iptablesを開始します。

# systemctl stop firewalld.service
# systemctl start iptables.service
# systemctl start ip6tables.service

iptablesでhttpdポートを許可します。

# iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT

iptablesを保存します。

# service iptables save

Lighttpdのテスト:

すべてが正しくインストールされていることを確認するために、Lighttpdをテストして正しく機能していることを確認します。任意のWebブラウザを開き、Webアドレスに次のように入力します。

http:// localhost /

または

http://your.ip.addr.ess

「Poweredbylighttpd」というWebページが表示されます。lighttpdのデフォルトのドキュメントルートはFedoraでは/var/ www/lighttpdです。設定ファイルは/etc/lighttpd/lighttpd.confで、追加の設定は/etc/lighttpd/conf.d/ディレクトリに保存されます。

MariaDBのインストール:

次はMySQLサーバーのインストールです。MySQLはFedoraパッケージで利用できます。次のコマンドを発行してインストールしてください。

# yum install mariadb mariadb-server php-mysql

MySQLサーバーを起動します。

# systemctl start mariadb.service

起動のたびにMariaDBを起動するには、ターミナルで次のように入力し、Enterキーを押します。

# systemctl enable mariadb.service

次は、mysql_secure_installationコマンドを使用してMySQLを安全にすることです。

このプログラムを使用すると、次の方法でMySQLインストールのセキュリティを向上させることができます。

  • rootアカウントのパスワードを設定できます。
  • ローカルホストの外部からアクセスできるルートアカウントを削除できます。
  • 匿名ユーザーアカウントを削除できます。
  • テストデータベース(デフォルトでは、匿名ユーザーも含めてすべてのユーザーがアクセスできます)と、test_で始まる名前のデータベースに誰でもアクセスできる特権を削除できます。
# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL 
 SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

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

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

Set root password? [Y/n] <-- ENTER
New password: <-- yourrootsqlpassword
Re-enter new password: <-- yourrootsqlpassword
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] <-- ENTER
 ... 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] <-- ENTER
 ... 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] <-- ENTER
 - 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] <-- ENTER
 ... 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!

PHP5のインストール:

次は、FastCGIを使用してFedoraにPHP 5をインストールすることです。fedoraは、FastCGI対応のPHP5パッケージを提供します。次のコマンドを発行してインストールできます。

# yum install php-cli lighttpd-fastcgi

PHP 5の構成:

PHP5サポートをlighttpdで有効にするには、次のファイルでcgi.fix_pathinfoが1に設定されていることを確認してください。

#  vi /etc/php.d/lighttpd.ini 

cgi.fix_pathinfo=1

FastCGIの有効化:

FastCGIを有効にするには、次のファイルを編集する必要があります。

# vi /etc/lighttpd/modules.conf

[行番号:132]のコメントを外します。

include "conf.d/fastcgi.conf"

次のファイルを編集して、FastCGIを構成します。

# vi /etc/lighttpd/conf.d/fastcgi.conf

ファイルの最後に次の行を追加します。

fastcgi.server  = ( ".php" =>
                    ( "localhost" =>
                      (
                        "socket" => "/var/run/lighttpd/php-fastcgi.socket",
                        "bin-path" => "/usr/bin/php-cgi",
                        "max-procs" => 5,
                        "bin-environment" => (
                           "PHP_FCGI_CHILDREN" => "16",
                           "PHP_FCGI_MAX_REQUESTS" => "10000" ),
                        "broken-scriptfilename" => "enable"
                      )
                    )
                  )

次に、必要なすべてのサービスを再起動します。

# systemctl restart lighttpd.service

PHPのテスト:

PHPをテストするには、1つのPHPファイルをLighttpdのデフォルトディレクトリに配置します。デフォルトのWebサイトのドキュメントルートは/var/ www/lighttpdです。次に、そのディレクトリに小さなPHPファイル(info.php)を作成し、ブラウザで呼び出します。このファイルには、インストールされているPHPのバージョンなど、PHPのインストールに関する多くの役立つ詳細が表示されます。

ターミナルで次の行をコピーして貼り付けます:

# vi /var/www/lighttpd/info.php

これにより、info.phpというファイルが開きます。

この行をコピーしてphpinfoファイルに貼り付けます:

<?php phpinfo(); ?>

ファイルを保存して閉じます。 Esc +; wqを使用します ファイルを保存します。

次に、Webブラウザを開いて、Webアドレスに次のように入力します。

http://localhost/info.php

または

http://your.ip.add-ress/info.php

ページは次のようになります:

ブラウザを下にスクロールしてモジュールセクションに移動し、MySQLのサポートを確認します。以下のような画面が表示されます。

以上です!


Fedora
  1. PHP5とMySQLを使用してApache2をFedora15(LAMP)にインストールする方法

  2. PHP5FastCGIとMySQLを使用してFedora16にlighttpdをインストールする方法

  3. PHP-FPMとMySQLを使用してFedora16「Verne」にNginxをインストールする方法

  1. PHP5FastCGIとMySQLを使用してFedora20にlighttpdをインストールする方法

  2. openSUSE12.1にPHP5FastCGIとMySQLを使用してlighttpdをインストールする方法

  3. Ubuntu11.10にPHP5とMySQLを使用してNginxをインストールする方法

  1. CentOS 6 /RHEL6にPHP5FastCGIとMySQLを使用してlighttpdをインストールする方法

  2. PHP5とMySQLを使用してApache2をFedora16(LAMP)にインストールする方法

  3. Ubuntu11.04にPHP5とMySQLを使用してLighttpdをインストールする方法