vagrant(CentOS6.7)でApache2.4+PHP7+MySQL5.7のインストール方法

# vagrant(CentOS6.7)でApache2.4+PHP7+MySQL5.7のインストール方法 

## 準備
vagrantのデフォルトのメモリだとインストール中にエラーが起きるので
メモリー量を2048Mbにする

```shell-session

  config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
     vb.memory = "2048"
   end

```

## Apache2.4のインストール
まず、apr-1.5.2をインストール

```shell-session
[root@vagrant-centos67 ~]# yum -y update
[root@vagrant-centos67 ~]# yum -y install wget
[root@vagrant-centos67 ~]# yum -y install gcc apr-devel apr-util-devel pcre-devel libxml2-devel bzip2-devel libcurl-devel openssl-devel gd-devel gdbm-devel libdbi-devel libc-client-devel libicu-devel gcc-c++ libmcrypt-devel freetds-devel postgresql94-devel
[root@vagrant-centos67 ~]# wget http://ftp.riken.jp/net/apache//apr/apr-1.5.2.tar.gz
[root@vagrant-centos67 ~]# tar xzvf apr-1.5.2.tar.gz
[root@vagrant-centos67 ~]# cd apr-1.5.2
[root@vagrant-centos67 apr-1.5.2]# ./configure
[root@vagrant-centos67 apr-1.5.2]# make
[root@vagrant-centos67 apr-1.5.2]# make install
```

次に、apr-util-1.5.4をインストール

```shell-session
[root@vagrant-centos67 apr-1.5.2]# cd ..
[root@vagrant-centos67 ~]# wget http://ftp.riken.jp/net/apache//apr/apr-util-1.5.4.tar.gz
[root@vagrant-centos67 ~]# tar xzvf apr-util-1.5.4.tar.gz
[root@vagrant-centos67 ~]# cd apr-util-1.5.4
[root@vagrant-centos67 ~]# ./configure --prefix=/usr/local/apr-util-1.5.4 --with-apr=/usr/local/apr
[root@vagrant-centos67 apr-util-1.5.4]# make
[root@vagrant-centos67 apr-util-1.5.4]# make install
```

## 最後に apache2.4をインストール＆起動

```shell-session
[root@vagrant-centos67 apr-util-1.5.4]# cd ..
[root@vagrant-centos67 ~]# wget http://ftp.tsukuba.wide.ad.jp/software/apache//httpd/httpd-2.4.20.tar.gz
[root@vagrant-centos67 ~]# tar xzvf httpd-2.4.20.tar.gz
[root@vagrant-centos67 ~]# cd httpd-2.4.20
[root@vagrant-centos67 httpd-2.4.20]# ./configure --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util-1.5.4 --enable-module=all --enable-module=so
[root@vagrant-centos67 httpd-2.4.20]# make
[root@vagrant-centos67 httpd-2.4.20]# make install
[root@vagrant-centos67 httpd-2.4.20]# /usr/local/apache2/bin/apachectl start

```

## PHP7.0.5のインストール

```shell-session
[root@vagrant-centos67 httpd-2.4.20]# cd ..
[root@vagrant-centos67 ~]# wget http://jp2.php.net/distributions/php-7.0.5.tar.gz
[root@vagrant-centos67 ~]# tar xzvf php-7.0.5.tar.gz
[root@vagrant-centos67 ~]# cd php-7.0.5
[root@vagrant-centos67 php-7.0.5]# ./configure --with-apxs2=/usr/local/apache2/bin/apxs --libdir=/usr/lib64 --with-libdir=lib64 --with-curl --disable-debug --with-pic --disable-rpath --without-pear --with-bz2 --with-freetype-dir --with-png-dir --with-xpm-dir --enable-gd-native-ttf --without-gdbm --with-gettext --with-iconv --with-jpeg-dir --with-openssl --with-pcre-regex --with-zlib --enable-exif --enable-ftp --enable-sockets --enable-calendar --with-libxml-dir --enable-xml --with-mhash --enable-mbstring --enable-mbregex --with-gd --enable-bcmath --with-xmlrpc --with-mysqli --with-curl --with-pdo-mysql --enable-json --enable-zip --without-readline --with-mcrypt
[root@vagrant-centos67 php-7.0.5]# make
[root@vagrant-centos67 php-7.0.5]# make install
```

## apacheの設定
vi /usr/local/apache2/conf/httpd.conf
下記を追加

```shell-session
<IfModule php7_module>
        AddType application/x-httpd-php .php
        AddType application/x-httpd-php-source .phps
</IfModule>
```

## apacheの再起動

```shell-session
[root@vagrant-centos67 htdocs]# /usr/local/apache2/bin/apachectl restart
```

## PHPの動作確認

vi /usr/local/apache2/htdocs/test.php

```php
<?php
phpinfo();
```

phpinfoのページが出たらOK

## MySQL5.7のインストール

```shell-session
[root@vagrant-centos67 php-7.0.5]# cd ..
[root@vagrant-centos67 ~]# wget http://repo.mysql.com//mysql57-community-release-el6-8.noarch.rpm
[root@vagrant-centos67 ~]# yum localinstall mysql57-community-release-el6-8.noarch.rpm 
[root@vagrant-centos67 ~]# yum install mysql mysql-devel mysql-server
[root@vagrant-centos67 ~]# service mysqld start
```