Last active
May 24, 2024 23:20
-
-
Save carthegian/b2451320bd0dda6b2df4c79b73b412f6 to your computer and use it in GitHub Desktop.
A quick gist for Vagrant with Amazon Linux 2 + PHP 7.4. Specifically for kickstart communicating with Google APIs using gRPC.
This file contains 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 : | |
@script = <<SCRIPT | |
# Install php and extensions | |
# PHPと拡張をインストールする | |
sudo amazon-linux-extras install php7.4 | |
sudo ln -s /usr/bin/php /usr/local/bin/php | |
sudo sed -i 's/memory_limit\s*=.*/memory_limit=2G/g' /etc/php.ini | |
sudo sed -i "s|;date.timezone =|date.timezone =Asia/Tokyo|" /etc/php.ini | |
sudo yum -y install php-bcmath | |
sudo yum -y install php-mbstring | |
sudo yum -y install php-xml | |
# Install composer | |
# composerをインストールする | |
curl -sS https://getcomposer.org/installer | php | |
sudo mv composer.phar /usr/local/bin/composer | |
# Install gRPC and protobuff | |
# gRPCとprotobufをインストールする | |
sudo yum -y install php-pear php-devel gcc-c++ | |
sudo pecl channel-update pecl.php.net | |
sudo yum -y install zlib-devel | |
# sudo pecl install grpc --> always install latest version | |
sudo pecl install grpc-1.32.0 | |
sudo sed -i -e '$aextension=grpc.so' /etc/php.ini | |
# sudo pecl install protobuf --> always install latest version | |
sudo pecl install protobuf-3.13.0 | |
sudo sed -i -e '$aextension=protobuf.so' /etc/php.ini | |
# Install Xdebug and update php.ini | |
# XdebugをインストールしてPHPを更新する | |
sudo pecl install xdebug | |
sudo sed -i -e '$azend_extension=/usr/lib64/php/modules/xdebug.so' /etc/php.ini | |
sudo sed -i -e '$axdebug.mode=debug' /etc/php.ini | |
sudo sed -i -e '$axdebug.start_with_request=yes' /etc/php.ini | |
sudo sed -i -e '$axdebug.discover_client_host=1' /etc/php.ini | |
touch /home/vagrant/xdebug.log | |
sudo sed -i -e '$axdebug.log=/home/vagrant/xdebug.log' /etc/php.ini | |
sudo sed -i -e '$axdebug.client_port=9003' /etc/php.ini | |
sudo sed -i -e '$axdebug.client_host=192.168.33.101' /etc/php.ini | |
# Restart PHP | |
# PHPをリスタートする | |
sudo service php-fpm restart | |
SCRIPT | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "gbailey/amzn2" | |
config.vm.box_version = "20201002.0.0" | |
config.vm.network "forwarded_port", guest: 8443, host: 8449 | |
config.vm.network "forwarded_port", guest: 80, host: 8181 | |
config.vm.network "private_network", ip: "192.168.33.100" | |
config.vm.provision 'shell', inline: @script | |
config.vm.provider "virtualbox" do |vb| | |
vb.customize ["modifyvm", :id, "--memory", "2048"] | |
vb.customize ["modifyvm", :id, "--name", "amazonlinux2-php7.4"] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you