はじめに
LAMP環境 + git + Node.js(gulp) を自動インストールする Vagrantfile を作成しました。
Webサイト制作など比較的小規模な開発環境としての利用を想定しています。
junsan50/Vagrant-LAMP-CentOS7.3
検証環境
- Vagrant 1.9.7
- VirtualBox 5.1.26
概要
- Apache License 2.0
- box は bento/centos-7.3 を使用
- Apache(2.4.6)
- PHP(7.1.8)
- MariaDB は 公式 のインストール方法と同様(10.1.26)
- git は CVE-2017-1000117 修正済みバージョン(2.14.1)
- Node.js は
n stable
でインストール(v8.4.0)
※ バージョン情報は2017年8月23日現在
使い方
get_started
git clone https://github.com/junsan50/Vagrant-LAMP-CentOS7.3.git
cd Vagrant-LAMP-CentOS7.3
vagrant up
setup.sh について
Apache ドキュメントルート変更
デフォルトで /vagrant/html
となります。
変更したい場合はsed置換している部分を任意のパスに修正してください。
setup.sh
### Apache ###
sudo yum -y install httpd
# ここを修正してください
sudo sed -i -e "/\/var\/www\/html/s/\/var\/www\/html/\/vagrant\/html/g" /etc/httpd/conf/httpd.conf
mod_ssl をインストールする場合
setup.sh
### SSL Module (If necessary) ###
sudo yum -y install mod_ssl # コメントを解除
mod_security をインストールする場合
setup.sh
### WAF Module (If necessary) ###
# sudo yum -y install mod_security # コメントを解除
別バージョンの PHP をインストールする場合
PHPインストールを行なっている部分を修正してください。
パッケージを変更する場合も同様になります。
setup.sh
### PHP7.1 ###
sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
sudo yum -y install --enablerepo=remi,remi-php71 php php-devel php-common php-cli php-pear php-pdo php-mysqlnd php-opcache php-gd php-mbstring php-mcrypt php-xml php-fpm
Node.js について
CentOS7.3の場合、普通に yum -y install nodejs
すると http-parser
の依存関係でコケるようです…
http-parser
を rpm
でインストールして依存関係を解決しています。
その他
mysql_secure_installation
は vagrant up
完了後に手動でお願いします。
[追記] 2017.10.28
Xdebugの追加
PhpStormでのデバッグ用としてXdebugのインストールスクリプトを追加しました。
※ idekeyをphpstorm
にしてるだけなので、SublimeText3とかでも使えるはず
PhpStorm側の設定については以下を参考にしてください。
PhpStorm で Vagrant 環境のリモートデバッグを実行する