1. TOP
  2. プログラミング
  3. VPSサーバーの構築 第4回 CentOS7 apache MariaDB PHP7 2018

VPSサーバーの構築 第4回 CentOS7 apache MariaDB PHP7 2018

プログラミング
この記事は約 4 分で読めます。 2,676 Views

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1434

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1434

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1434

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1434

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1434

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1434

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1434

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1434

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1451

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1451

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1451

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1451

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1451

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1451

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1451

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1451

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1216

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1216

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1216

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1216

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1216

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1216

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1216

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1216

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1226

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1226

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1226

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1226

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1226

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1226

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1226

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1226

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1239

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1239

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1239

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1239

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1239

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1239

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1239

Warning: Undefined array key 3 in /home/octo8/dainamo.jp/public_html/wp/wp-content/themes/surfing/lib/table-of-contents-plus/surfing_toc.php on line 1239

apacheのインストールやユーザの追加、権限の設定にドキュメントルートの設定が完了しました。
さて、いよいよPHPのインストールとMariaDBのインストールを行います。

remiとは

早速PHPのインストールといきたいところですが、その前にやらないといけないことがあります。

remiのインストールです。

今回は最新のPHP7をインストールしますが、PHP7はCentOS7の公式アプリケーションサーバーではサポートされていないため、
remiという非公式リポジトリをインストールした後に最新のPHP7を入れていきます。

CentOSは安定性重視のサーバー

CentOSは非常に安定重視なため、頻繁に更新が行われません。そのため、remiをインストールして最新のPHPを使用するということです。

非公式といっても、remiはCentOS公式のリポジトリからインストール出来るため、安全性は高いと言えます。

EPEL

もう一つ、EPELというものもあるのですが、こちらもremiと同じく非公式のリポジトリです

こちらはさくらではすでにインストールと設定が完了しているので何もする必要はありません。

remiのインストール

まずはremiのインストールから行います。

rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rp

remiが正しくインストールが完了したら、いよいよPHPのインストールを行なっていきます。

PHP7をインストール

yum install --enablerepo=remi,remi-php70 php php-devel php-mbstring php-pdo php-gd

全てyで進んでいくと完了します。

php.iniの設定

さて、これでPHPが使えるようになりましたが、デフォルトのままだと不都合があります。

例えばphpで容量が制限されていたり、セキュリティ上あまりよろしくありません。

いくつか設定をしておきましょう。

vi /etc/php.ini

以下のように設定をしてきます。

expose_phpをOnからoffに変更します。これはPHPのバージョンが表示されないようにするためです。

max_execution_time(スクリプト最大実行時間)を30から300に変更します。

error_reportingをE_All&~E_DEPRECATEDからE_ALL & ~E_NOTICEに変更します。

post_max_size(最大POSTアップロードサイズ)を8Mから20M程度に変更します。

先頭の「;」を削除して、default_charsetを文字コードにUTF-8を指定します。

upload_max_filesize(最大アップロードファイルサイズ)を2Mから20M程度に変更します。

先頭のコメントを解除して、date.timezone=”Asia/Tokyo”に変更します。

mbsting.language=Japaneseとします。

EUC-JPをUTF-8に変更します。mbstring.internal_encoding="UTF-8"

autoをUTF-8に変更します。mbstring.http_input="UTF-8"

SJISをpassに変更します。mbstring.http_output=pass

mbstring.encoding_translation=On

mbstring.detect_order=auto

mbstring.substitute_charset=none;

これで設定が完了しました。

再起動

systemctl restart httpd

apacheを再起動しておきましょう。

まとめ

いよいよ設定も残すところもあと少しになってきました。

次回は、mariaDBのインストールを行なっていきます。

制作のご依頼・ご相談はこちら

dainamoでは魅力的なWEBサイトや、アプリ、ツール、ポスター、パンフレット、チラシなど幅広く承っております。ご相談、見積もり、お問い合わせなど、お気軽にご連絡ください。

今すぐご相談・問い合わせをする

\ SNSでシェアしよう! /

web制作・デザイン・システム開発・管理なら dainamo(ダイナモ)の注目記事を受け取ろう

この記事が気に入ったら
いいね!しよう

web制作・デザイン・システム開発・管理なら dainamo(ダイナモ)の人気記事をお届けします。

  • 気に入ったらブックマーク! このエントリーをはてなブックマークに追加
  • フォローしよう!

ライター紹介 ライター一覧

kz

kz

税金にも詳しいエンジニア

サーバーの構築からフロントエンド、iOSアプリの作成も行います。
WEBアプリや会員サービスの構築を得意としています。

制作物の一部を紹介
・海外旅行者向け事業者サービス
https://vacation-japan.com

・記憶術を使ったWEBアプリ会員サイト

その他、教育アプリetc..

この人が書いた記事  記事一覧

  • 【VPN】自宅のMacから会社のMacにリモートアクセスする場合のVPNの設定と画面共有方法【リモートデスクトップ】

  • Apacheのバージョン情報を隠してセキュリティを向上させる

  • 文字コードとは一体何なのか?MacでCSVの文字コードをUTF-8に変換する

  • 教師ありの機械学習(AI)プログラムを使用して、与えられた文章が何の言語なのか判定する

関連記事

  • 【初心者向け】cron(クーロン)を使って、自動でプログラムを設定する

  • 会員サイトで、特定のディレクトリ内にアクセス制限をかける

  • 教師ありの機械学習(AI)プログラムを使用して、与えられた文章が何の言語なのか判定する

  • VPSサーバーの構築 第6回 CentOS7 apache MariaDB PHP7 2018

  • 【コピペでOK】期間を指定して表示・非表示するPHP関数

  • Linuxのプロンプトの色をユーザーによって切り分ける