Last active
October 25, 2023 07:33
-
-
Save ducngtuan/036b7a43585dade772702fa25496822c to your computer and use it in GitHub Desktop.
Vagrantfile Setup for PHP 5.6
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 : | |
Vagrant.configure("2") do |config| | |
config.vm.box = "ubuntu/trusty64" | |
# Create a forwarded port mapping which allows access to a specific port | |
# within the machine from a port on the host machine. In the example below, | |
# accessing "localhost:8080" will access port 80 on the guest machine. | |
# config.vm.network "forwarded_port", guest: 80, host: 8080 | |
config.vm.network "private_network", ip: "192.168.33.10" | |
config.vm.synced_folder "./", "/var/www", :mount_options => ["dmode=777", "fmode=666"] | |
config.vm.hostname = "devbox" | |
config.vm.provider "virtualbox" do |vb| | |
vb.memory = "512" | |
end | |
config.vm.provision "shell", inline: <<-SHELL | |
# Set timezone | |
timedatectl set-timezone "Europe/Berlin" | |
# Set language | |
locale-gen en_US en_US.UTF-8 | |
dpkg-reconfigure locales | |
# Update packages | |
apt-get update -qq | |
apt-get upgrade -qq | |
apt-get install -y python-software-properties build-essential vim curl git | |
apt-get autoremove -y -qq | |
SHELL | |
apache_php_setup_script = <<-SHELL.gsub /^\s*/, '' | |
debconf-set-selections <<< "mysql-server mysql-server/root_password password root" | |
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password root" | |
debconf-set-selections <<< "phpmyadmin phpmyadmin/dbconfig-install boolean true" | |
debconf-set-selections <<< "phpmyadmin phpmyadmin/app-password-confirm password root" | |
debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/admin-pass password root" | |
debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/app-pass password root" | |
debconf-set-selections <<< "phpmyadmin phpmyadmin/reconfigure-webserver multiselect none" | |
# Add PPA for PHP 5.6 | |
add-apt-repository ppa:ondrej/php | |
apt-get update -qq | |
# Install php 5.6 | |
apt-get install -y php5.6 php5.6-common php5.6-mysql php5.6-mbstring \ | |
php5.6-cli mysql-server phpmyadmin apache2 libapache2-mod-php5.6 \ | |
php5.6-xml php5.6-json php5.6-gd php5.6-mcrypt php5.6-intl php-xdebug \ | |
php-xcache php5.6-zip | |
# Enable Apache rewrite mod | |
a2enmod rewrite | |
sed -i "s/AllowOverride None/AllowOverride All/g" /etc/apache2/apache2.conf | |
# Set Apache global ServerName | |
sed -i '1s;^;ServerName devbox.local\\n;' /etc/apache2/apache2.conf | |
# Remove the /var/www/html created by Apache by default | |
if [ -d /var/www/html ]; then | |
rm -rf /var/www/html | |
fi | |
# Create /var/www/public_html if not exist | |
if [ ! -d /var/www/public_html ]; then | |
mkdir /var/www/public_html | |
fi | |
# Config document root if needed | |
sed -i s,/var/www/html,/var/www/public_html,g /etc/apache2/sites-available/000-default.conf | |
# Config xdebug | |
cat <<EOT > /etc/php/5.6/apache2/conf.d/30-xdebug.ini | |
xdebug.remote_enable = 1 | |
xdebug.remote_connect_back = 1 | |
xdebug.remote_port = 9001 | |
xdebug.scream=0 | |
xdebug.cli_color=1 | |
xdebug.show_local_vars=1 | |
EOT | |
# Config extra PHP settings | |
cat <<EOT > /etc/php/5.6/apache2/conf.d/30-php.ini | |
error_reporting = E_ALL | |
display_errors = On | |
display_startup_errors = On | |
track_errors = On | |
intl.error_level = E_ALL | |
short_open_tag = On | |
extension=php_mbstring.dll | |
EOT | |
service apache2 restart | |
apt-get autoremove -y -qq | |
# Install Composer | |
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | |
SHELL | |
config.vm.provision "apache_php_setup", type: "shell", inline: apache_php_setup_script | |
config.vm.provision "node_setup", type: "shell", inline: <<-SHELL | |
curl -sL https://deb.nodesource.com/setup_7.x | bash - | |
apt-get install -y -qq nodejs | |
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - | |
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list | |
apt-get update -qq | |
apt-get install -y -qq yarn | |
SHELL | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment