Last active
June 8, 2018 20:46
-
-
Save cweagans/4e879a72985905e145df to your computer and use it in GitHub Desktop.
Vagrantfile
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
# Up to date version can always be found at https://gist.github.com/cweagans/4e879a72985905e145df | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "ubuntu/xenial64" | |
config.vm.synced_folder ".", "/srv", type: "nfs" | |
config.vm.network "private_network", ip: "192.168.205.142" | |
config.vm.network "forwarded_port", guest: 80, host: 8085 | |
config.vm.provider "virtualbox" do |vb| | |
vb.customize ["modifyvm", :id, "--memory", "1024"] | |
vb.customize ['modifyvm', :id, '--paravirtprovider', 'kvm'] | |
end | |
$script = <<SCRIPT | |
echo "Installing required software" | |
sudo apt-get update -qq | |
sudo apt-get install -qqy git debconf-utils curl vim > /dev/null | |
echo "Installing Apache" | |
sudo apt-get install -qqy apache2 > /dev/null | |
echo "Installing PHP" | |
sudo apt-get install -qqy php7.0 php7.0-mcrypt php7.0-mysql php7.0-gd php7.0-curl php7.0-xml > /dev/null | |
sudo sed -i.back 's/\/run\/php\/php7.0-fpm.sock/127.0.0.1:9000/g' /etc/php/7.0/fpm/pool.d/www.conf | |
echo "Installing Composer" | |
curl -sS https://getcomposer.org/installer | php >> /dev/null | |
sudo mv composer.phar /usr/local/bin/composer | |
echo 'export PATH=$PATH:/home/ubuntu/.composer/vendor/bin' >> ~/.bashrc | |
echo 'export PATH=$PATH:/home/ubuntu/.composer/vendor/bin' >> /home/ubuntu/.bashrc | |
echo "Installing MySQL" | |
echo "mysql-server mysql-server/root_password password root" | sudo debconf-set-selections | |
echo "mysql-server mysql-server/root_password_again password root" | sudo debconf-set-selections | |
sudo apt-get install -qqy mysql-server > /dev/null | |
mysqladmin -u root -proot create drupal > /dev/null | |
echo "Configuring Apache" | |
sudo a2enmod rewrite > /dev/null | |
sudo a2enmod proxy_fcgi > /dev/null | |
sudo cat <<EOF > /tmp/apache_vhost | |
<VirtualHost *:80> | |
DocumentRoot /srv/web | |
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/srv/web/$1 | |
<Directory /> | |
Options FollowSymLinks | |
AllowOverride None | |
</Directory> | |
<Directory /srv/web> | |
Order allow,deny | |
Allow from all | |
AllowOverride FileInfo All | |
Require all granted | |
</Directory> | |
</VirtualHost> | |
EOF | |
sudo mv /tmp/apache_vhost /etc/apache2/sites-available/000-default.conf | |
sudo apache2ctl graceful > /dev/null | |
echo "Installing xdebug" | |
sudo apt-get install -qqy php-xdebug > /dev/null | |
sudo echo "xdebug.remote_enable = on" >> /etc/php/7.0/mods-available/xdebug.ini | |
sudo echo "xdebug.remote_connect_back = on" >> /etc/php/7.0/mods-available/xdebug.ini | |
sudo echo 'xdebug.idekey = "vagrant"' >> /etc/php/7.0/mods-available/xdebug.ini | |
sudo apache2ctl graceful | |
sudo service php7.0-fpm reload | |
echo "" | |
echo "Installation complete." | |
echo "Database username: root" | |
echo "Database password: root" | |
echo "Database host: localhost" | |
echo "Database name: drupal" | |
SCRIPT | |
config.vm.provision "shell", inline: $script | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment