LoginSignup
3
3

More than 5 years have passed since last update.

CentOS7でLAMP環境構築

Last updated at Posted at 2016-05-02

各種パッケージのアップデート

OSインストール後は各種パッケージのアップデートを行う
# yum update

MySQL5.6のインストール

MySQLをインストールするためリポジトリを追加

CentOS7からデフォルトでMariaDBがインストールされるためMySQLのリポジトリ設定をDLする
# cd ~/
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# rpm -Uvh mysql-community-release-el7-5.noarch.rpm

MySQLのリポジトリ設定が追加されているか確認

# cd /etc/yum.repos.d
# ls -al

MySQLのインストール

# yum install mysql-community-server

MySQLがインストールされているか確認

# rpm -qa | grep mysql

MySQLの起動

起動

# systemctl start mysqld

ステータス確認

# systemctl status mysqld

停止

# systemctl stop mysqld

自動起動をOnにする

# systemctl enable mysqld

MySQLに接続

# mysql -u root

MySQLの初期設定

mysql_secure_installation の実行

# mysql_secure_installation

PHP5.6のインストール

Remi リポジトリの追加

EPEL リポジトリの追加

# yum install epel-release

Remi のリポジトリの追加

# cd /etc/yum.repos.d
# wget http://rpms.famillecollet.com/enterprise/remi.repo

PHP5.6のインストール

# yum --enablerepo=remi,remi-php56 install php php-common

PHPのバージョン確認

# php -v

Apache2.4のインストール

インストール

# yum --enablerepo=remi,remi-php56 install httpd

起動

# systemctl start httpd

自動起動をOnにする

# systemctl enable httpd

Web接続する

設定ファイルの保存場所を確認

# httpd -V

設定ファイルの中身を確認

DocumentRootのディレクトリを確認する
# less /etc/httpd/conf/httpd.conf

htmlファイルの設置

cd /var/www/html/
vim index.html

phpMyAdminをインストールする

※おそらくphpMyAdminをYumでいれればその他のパッケージも自動でインストールされると思います。

php-mbstringのインストール

# yum --enablerepo=remi,remi-php56 install php-mbstring

php-pdoのインストール

# yum --enablerepo=remi,remi-php56 install pdo

php-mysqlndのインストール

# yum --enablerepo=remi,remi-php56 install php-mysqlnd

phpMyAdminインストール

# yum --enablerepo=remi,remi-php56 install phpMyAdmin

設定ファイルを修正

デフォルトでローカルからのみアクセスが許可されているのでその制限を外す

/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>

Apache再起動

※reloadでもいい
# systemctl restart httpd

接続

http://<ip>/phpMyAdmin/

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3