LoginSignup
25
25

More than 5 years have passed since last update.

vagrant内のCentOS7(PHP5.6 + MariaDB10 + Apache2.4+α)セットアップ

Last updated at Posted at 2015-06-02

vagrantの導入から環境構築まで2部構成になっています
1部 : vagrantの導入
2部 : vagrant内のCentOS7セットアップ← いまここ

CentOS7構築

CentOS7をコマンドラインからインストールする手順です。

CentOS7にPHPとMariaDBといった基本的なソフトウェアのインストール等の
環境構築をシンプルに説明するため細かな説明は省いています。

コマンドラインを起動

root権限に変更

$ su

password:

1. firewallの設定

1-1. ■WebのPort解放

$ firewall-cmd --permanent --add-port=80/tcp
$ firewall-cmd --permanent --add-port=443/tcp

1-2. ■メールのPort解放

$ firewall-cmd --permanent --add-port=25/tcp
$ firewall-cmd --permanent --add-port=110/tcp
$ firewall-cmd --permanent --add-port=143/tcp
$ firewall-cmd --permanent --add-port=465/tcp
$ firewall-cmd --permanent --add-port=587/tcp
$ firewall-cmd --permanent --add-port=993/tcp
$ firewall-cmd --permanent --add-port=995/tcp

1-3. ■mongoDBのPort解放

$ firewall-cmd --permanent --add-port=27017/tcp

1-4. ■jenkinsのPort解放

$ firewall-cmd --permanent --add-port=8080/tcp

1-5. ■ajentiのPort解放

$ firewall-cmd --permanent --add-port=8000/tcp

1-6. ■firewallをリロード

$ firewall-cmd --reload

2レポジトリのインストール

2-1. ■epel remi レポジトリ インストール

$ yum install -y epel-release

$ vi /etc/yum.repos.d/epel.repo

[epel] enabled= 1 → 0

2-2. ■remi レポジトリ インストール

$ rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

$ vi /etc/yum.repos.d/remi.repo

[remi] enabled= 1 → 0

2-3. ■rpmforge レポジトリ インストール

$ rpm -ivh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm

$ vi /etc/yum.repos.d/rpmforge.repo

[rpmforge] enabled= 1 → 0

2-4. ■iusのインストール

$ curl -I http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
$ yum localinstall https://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/ius-release-1.0-13.ius.centos7.noarch.rpm

2-5. ■MariaDB インストール

自分でrepoを作成する

$ vi /etc/yum.repos.d/MariaDB.repo

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1.4/centos7-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

2-6. ■mongoDB レポジトリ インストール

$ vi /etc/yum.repos.d/mongodb.repo

[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=0

2-7. ■Jenkins レポジトリ インストール

$ cd /etc/yum.repos.d
$ curl -O http://pkg.jenkins-ci.org/redhat/jenkins.repo
$ rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key

3. Webサーバーインストール

$ ### 3-1. ■Apache2.4インストール
$ yum install httpd

$ vi /etc/httpd/conf/httpd.confの95行目当たりに追加

ServerName tests:80

上記の「tests」は自分のサーバー名なので自由に決めてください。

3-2. ■Apacheの起動と自動起動設定

$ systemctl start httpd.service
$ systemctl enable httpd.service

4. データベースインストール

4-1. ■MariaDBインストール

$ yum install MariaDB-server MariaDB-client MariaDB-devel MariaDB-shared

4-2. ■MariaDB起動

$ systemctl start mysql.service

4-3. ■MariaDBセキュリティ設定

$ mysql_secure_installation

Set root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] n
Reload privilege tables now? [Y/n] Y

mysql -u root -p

4-4. ■Postfix/imapのインストール

$ yum install --enablerepo=epel,remi,remi-php56 postfix php-imap

4-5. ■Postfixの起動と自動起動設定

$ systemctl start postfix.service
$ systemctl enable postfix.service

4-6. ■MongoDBのインストール

$ yum install --enablerepo=mongodb mongodb-org

4-7. ■MongoDBの起動と自動起動設定

$ systemctl start mongod.service
$ chkconfig mongod on

5. PHPと付属アプリケーション全部インストール

5-1. ■PHP5.6インストール

$ yum install --enablerepo=remi,remi-php56 php

5-2. ■必要なものインストール1

$ yum install vim bash-completion wget curl lsof -y
$ yum install ansible docker-io
$ yum install yum-utils deltarpm -y

5-3. ■必要なものインストール2

$ yum install --enablerepo=epel,remi libmcrypt-devel libaio libaio-devel libmcrypt libtidy openssl-devel perl-DBI

5-4. ■PHPのプラグインインストール

$ yum install --enablerepo=remi,remi-php56 php-intl php-soap php-mcrypt php-mbstring php-gd php-devel php-odbc php-xml php-xmlrpc httpd-devel pcre-devel icu libicu-devel php-mysql php-mysqlnd php-pdo php-pear php-tidy

5-5. ■composerのインストール

$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer

5-6. ■画像操作系インストール

$ yum install --enablerepo=epel,remi,remi-php56 ImageMagick
$ yum install --enablerepo=epel,remi,remi-php56 php-pecl-imagick

5-7. ■opcacheのインストール

$ yum -y --enablerepo=epel,remi,remi-php56 install php-opcache.x86_64
$ yum --enablerepo=remi,remi-php56 install php-pecl-apcu php-pecl-mongo php-pecl-memcache php-pecl-memcached

5-8. ■php.iniの設定

$ vi /etc/php.ini

;timezoneの設定
date.timezone = "Asia/Tokyo"

;メモリ使用量の上限
memory_limit = 2000M

;POSTデータの最大サイズ ※合計サイズ
post_max_size = 2000M

;1ファイルあたりの最大アップロードサイズ
upload_max_filesize = 2000M

6. その他重要アプリケーションインストール

6-1. ■JAVAのインストール

$ curl -LO -H "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.rpm"
$ yum localinstall jdk-8u45-linux-x64.rpm

6-2. ■Jenkinsインストール

$ yum install --enablerepo=jenkins jenkins

6-3. ■Jenkinsの起動と自動起動設定

$ systemctl start jenkins
$ chkconfig jenkins on

6-4. ■Ajentiのインストール

$ yum install --enablerepo=epel python-daemon python-psutil python-passlib
$ curl https://raw.githubusercontent.com/Eugeny/ajenti/master/scripts/install-rhel7.sh | sh

7. 再起動

$ vagrant reload

サーバであれば

$ reboot

1部に戻る vagrantの導入

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