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

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

プログラミング
この記事は約 5 分で読めます。 2,791 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 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 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

前回までで、OS、apacheのインストール、ドメインの設定とPHP、MariaDBのインストールまで完了しました。

今回で最終回です。

最終回の今回は、ターミナルやコマンドプロンプトでSQLを書けなくても、ブラウザからGUIを使ってデータベースを操作することができるように、phpMyAdminのインストールを行なっていきます。

phpMyAdminとは

コマンドラインを使用して全てスムーズに操作ができる方は必須ではありませんが、データを一括インポートしたり、保存してあるデータをエクスポートしたりすることができるため、phpMyAdminを利用した方が操作は簡単なことも多いです。

まずはrootに切り替えをします。

su --

phpMyAdminをインストールする

remiを使ってphpMyAdminをインストールしていきます。

yum --enablerepo=remi,remi-php7 install phpMyAdmin

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

phpMyAdminの設定を変更する

インストールは完了しましたが、そのままですとブラウザからアクセスできません。

続いて、phpMyAdminの設定を編集していきます。

vi /etc/httpd/conf.d/phpMyAdmin.conf
<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     #Require local       
     AllowOverride all    
     Require all granted  
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
   </IfModule>
</Directory>

Require localをコメントアウトします
その下に
AllowOverride all
Require all granted
を追加します。

設定の意味と意図は

「AllowOverride all」は、
上のディレクトリで設定した設定値を、下層でも許可を与えるという意味です。

「Require local」 は、自分自身のサーバーからのアクセスのみ使用できる設定になっています。
これを「Require all granted」にすることで、全ての権限・端末からアクセスできるようにします。

apache2.4未満を使用していた方は、apache2.4系から「Require all granted」がないとエラーになってしまうので気をつけましょう

設定が完了したら、apacheを再起動しましょう

systemctl restart httpd

これで、
http://ドメイン/phpmyadmin
でアクセスすれば、phpMyAdminが表示されたはずです。

phpMyAdminのURLを変更する

このままですと、URLが推測されるためにセキュリティ上よくありません。

URLを変更していきます。

vi /etc/httpd/conf.d/phpMyAdmin.conf
#Alias /phpMyAdmin /usr/share/phpMyAdmin
#Alias /phpmyadmin /usr/share/phpMyAdmin
Alias /test /usr/share/phpMyAdmin

上の二行をコメントアウトします。
その下の前半がURLになります。

これを設定することで、
http://ドメイン/test

でphpMyAdminにアクセスすることが可能になります。(testもセキュリティや名前的に良くないので、適宜変更してください。)

設定が完了したら、apacheを再起動しましょう

systemctl restart httpd

まとめ

これでサーバー構築の基本は全て完了です。いかがでしたでしょうか?

そこまで難しくなかったのではないでしょうか?

サーバー設定は奥が深く、セキュリティ面での設定はまだまだしないといけないことがあります。

しかし、まずはサーバーを立てるという面では今回やってきたことで十分かと思います。

サーバーを構築するという難しそうなイメージを払拭できたのであれば幸いです。

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

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)プログラムを使用して、与えられた文章が何の言語なのか判定する

関連記事

  • 【初心者向け】Gitとは? 基本知識と特徴のまとめ

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

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

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

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

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