Created
August 31, 2017 03:19
-
-
Save saboyutaka/5fc3b209194e61b78968d67b5b0d6277 to your computer and use it in GitHub Desktop.
vagrant for AmazonLinux, php71, laravel, nginx, mysql, redis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
root /vagrant/www/public; | |
index index.php; | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
location ~* \.(css|js|gif|jpe?g|png)$ { | |
expires max; | |
} | |
location ~* \.php$ { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
include fastcgi_params; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_intercept_errors on; | |
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# #!/usr/bin/env bash | |
# Set timezone | |
ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime | |
yum update | |
yum install -y git tig htop | |
# ssh passwordでログイン | |
sed -i -e 's/^PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config | |
/etc/init.d/sshd restart | |
# install nginx | |
yum install nginx -y | |
mv /home/vagrant/nginx.conf /etc/nginx/nginx.conf | |
mv /home/vagrant/app.conf /etc/nginx/conf.d/app.conf | |
service nginx restart | |
chkconfig nginx on | |
# install php7.1 | |
yum install -y http://rpms.famillecollet.com/enterprise/remi-release-6.rpm | |
yum-config-manager --enable epel | |
yum install -y --disablerepo=amzn-main libwebp | |
yum install | |
yum install -y httpd libXpm gd-last libtool-ltdl automake zlib-devel gcc openssl-devel wget lbzip2 | |
yum install -y --disablerepo=amzn-main --enablerepo=epel --enablerepo=remi-php71 php php-mysqlnd php-mbstring php-mcrypt php-pdo php-xml php-gd php-pear php-fpm php-devel php-zip | |
pecl install xdebug | |
cat >> /etc/php.ini <<EOS | |
zend_extension=/usr/lib64/php/modules/xdebug.so | |
; see http://xdebug.org/docs/all_settings | |
html_errors=on | |
xdebug.collect_vars=on | |
xdebug.collect_params=4 | |
xdebug.dump_globals=on | |
xdebug.dump.GET=* | |
xdebug.dump.POST=* | |
xdebug.show_local_vars=on | |
xdebug.remote_enable = on | |
xdebug.remote_autostart=on | |
xdebug.remote_handler = dbgp | |
xdebug.remote_connect_back=on | |
xdebug.profiler_enable=0 | |
xdebug.profiler_output_dir="/vagrant/www/tmp/profile" | |
xdebug.max_nesting_level=1000 | |
xdebug.remote_host=192.168.123.1 | |
xdebug.remote_port = 9001 | |
xdebug.idekey = "mydebug" | |
EOS | |
# curl with openssl | |
wget http://curl.haxx.se/download/curl-7.54.0.tar.bz2 | |
tar xf curl-7.54.0.tar.bz2 | |
cd curl-7.54.0 | |
./configure --enable-libcurl-option | |
make | |
make install | |
echo '/usr/local/lib' > /etc/ld.so.conf.d/curl-x86_64.conf | |
ldconfig -v | |
cd | |
rm -rf curl-7.54.0 | |
rm curl-7.54.0.tar.bz2 | |
# php-fpm | |
sed -i -e 's/^listen\ =/;listen\ =/' /etc/php-fpm.d/www.conf | |
cat >> /etc/php-fpm.d/www.conf << EOS | |
listen = /var/run/php-fpm/php-fpm.sock | |
listen.owner = nginx | |
listen.group = nginx | |
EOS | |
service php-fpm restart | |
chkconfig php-fpm on | |
# install composer | |
curl -sS https://getcomposer.org/installer -o composer-setup.php | |
php composer-setup.php --install-dir=/usr/local/bin --filename=composer | |
rm composer-setup.php | |
# install mysql | |
yum install -y mysql56 mysql56-server | |
# sed -i -e 's/^socket/# socket/' /etc/my.cnf | |
cat >> /etc/my.cnf << EOS | |
[client] | |
default-character-set = utf8mb4 | |
[mysql] | |
default-character-set=utf8mb4 | |
[mysqld] | |
skip-character-set-client-handshake | |
character-set-server = utf8mb4 | |
collation-server = utf8mb4_general_ci | |
init-connect = SET NAMES utf8mb4 | |
# socket = /var/run/mysqld/mysqld.sock | |
EOS | |
service mysqld restart | |
chkconfig mysqld on | |
# install redis | |
yum install -y --enablerepo=remi redis | |
service redis start | |
chkconfig redis on | |
# install nodejs, npm, yarn | |
wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo | |
curl --silent --location https://rpm.nodesource.com/setup_6.x | bash - | |
yum install -y gcc-c++ make | |
yum install -y nodejs yarn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Install laravel | |
composer global require "laravel/installer" | |
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.bash_profile | |
source ~/.bash_profile | |
mkdir -p /vagrant/www/tmp/profile | |
cd /vagrant/www | |
if [ ! -f .env ]; then | |
cp .env.example .env | |
fi | |
composer install | |
composer global require hirak/prestissimo | |
mysql -uroot -e 'CREATE DATABASE IF NOT EXISTS irodori_development;' | |
php artisan migrate | |
php artisan db:seed | |
yarn install | |
yarn run dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
worker_processes 1; | |
error_log /var/log/nginx/error.log; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; | |
# multi_accept on; | |
} | |
http { | |
include /etc/nginx/mime.types; | |
access_log /var/log/nginx/access.log; | |
sendfile on; | |
#tcp_nopush on; | |
#keepalive_timeout 0; | |
keepalive_timeout 65; | |
tcp_nodelay on; | |
gzip on; | |
gzip_disable "MSIE [1-6]\.(?!.*SV1)"; | |
include /etc/nginx/conf.d/*.conf; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
VAGRANTFILE_API_VERSION = "2".freeze | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "mvbcoding/awslinux" | |
# Mount shared folder | |
config.vm.synced_folder ".", "/vagrant/www" | |
config.vm.network "private_network", ip: "192.168.123.100" | |
config.vm.network "forwarded_port", guest: 80, host: 8080 | |
config.vm.network "forwarded_port", guest: 8000, host: 8000 | |
config.vm.provider :virtualbox do |vb| | |
vb.customize ["modifyvm", :id, "--memory", 4096, "--cpus", 4, "--ioapic", "on"] | |
end | |
config.vm.provision :file, source: "vagrant/nginx/app.conf", destination: "app.conf" | |
config.vm.provision :file, source: "vagrant/nginx/nginx.conf", destination: "nginx.conf" | |
config.vm.provision :shell, path: "vagrant/bootstrap.sh" | |
config.vm.provision :shell, path: "vagrant/bootstrap_vagrant.sh", privileged: false | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment