0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CentOS on EC2にLAMP環境を構築する

0
Posted at

1. はじめに

とあるホスティングサービスを使用していたが、思い立ってEC2に引っ越しをした時の導入メモです。
様々な所に先人の方々のもっと詳しい情報がありますが、自分のメモを兼ねて書いておきます。

1.1. PHP導入

1.1.1. remi リポジトリ導入

色々と調査し、バージョンは7.3を使用することにしました。
「remi」リポジトリを設定します。

$ sudo yum -y install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

リポジトリの登録が増えてきた・・・・。

$ sudo yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: d36uatko69830t.cloudfront.net
 * epel: nrt.edge.kernel.org
 * extras: d36uatko69830t.cloudfront.net
 * nux-dextop: mirror.li.nux.ro
 * remi-safe: ftp.riken.jp
 * updates: d36uatko69830t.cloudfront.net
repo id                             repo name                                                                     status
base/7/x86_64                       CentOS-7 - Base                                                               10,097
epel/x86_64                         Extra Packages for Enterprise Linux 7 - x86_64                                13,241
extras/7/x86_64                     CentOS-7 - Extras                                                                341
ius/x86_64                          IUS for Enterprise Linux 7 - x86_64                                              550
nux-dextop/x86_64                   Nux.Ro RPMs for general desktop use                                            2,717
remi-safe                           Safe Remi's RPM repository for Enterprise Linux 7 - x86_64                     3,794
updates/7/x86_64                    CentOS-7 - Updates                                                             1,787
repolist: 32,527

1.1.2. PHPのインストール

必要そうなものを入れておきます。(実は何度も試行してここに落ち着いた・・・)

$ sudo yum -y install --enablerepo=epel,remi,remi-php73 php php-cli php-common \
php-gd php-imap php-mbstring php-mysql php-odbc php-pdo php-pear php-pgsql \
php-process php-snmp php-xml php-xmlrpc php-fpm php-mcrypt php-pecl-zip \
phpMyAdmin

2. MySQL

2.1. 導入バージョン

Community Serverの5.7

Mariadbの削除

$ sudo yum remove mariadb-libs

2.2. 導入

こちらを参考にさせて頂きました。

$ sudo rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
$ sudo yum install -y mysql-community-server ; mysqld --version
mysqld  Ver 5.7.29 for Linux on x86_64 (MySQL Community Server (GPL))

$ sudo systemctl enable mysqld ; sudo systemctl start mysqld

初期パスワードを確認してから設定コマンドを実行。

$ sudo cat /var/log/mysqld.log | grep password
$ sudo mysql_secure_installation

3. apache (httpd)

3.1. デフォルトで導入されているパッケージを確認

httpdは入っていたのでそのまま使う。

$ yum list installed |grep httpd
httpd.x86_64                       2.4.6-90.el7.centos        @base
httpd-tools.x86_64                 2.4.6-90.el7.centos        @base

3.2. apacheのスタート・自動起動設定

$ sudo systemctl enable httpd ; sudo systemctl start httpd ;  httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Aug  8 2019 11:41:18

4. perl (CGI用)

少々調べた限りでは最近はcpanmを使うらしい。

4.1. 導入

$ sudo yum install -y perl perl-core perl-local-lib; perl -v

This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux-thread-multi
(with 39 registered patches, see perl -V for more detail)
(略)

パッケージを入れるため、cpanmも入れておく
$ sudo yum install -y perl-App-cpanminus ; cpanm -V
cpanm (App::cpanminus) version 1.6922 (/usr/bin/cpanm)
perl version 5.016003 (/usr/bin/perl)

MySQLを利用できるように追加
$ sudo yum install -y mysql-community-devel
$ sudo cpanm DBI ; sudo cpanm DBD::mysql
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?