-
-
Save mrfolkblues/a32d72af059b23f778fbcadbc05c81dc to your computer and use it in GitHub Desktop.
Vagrant / Ubuntu 14.04.5 + PHP 7.1 + MariaDB 10.1 + Apache 2.4.7
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
#filename: provision.sh | |
#!/usr/bin/env bash | |
########################################### | |
# edited by Matt Engel # | |
# https://gist.github.com/mrfolkblues # | |
# # | |
# forked from Ricardo Canelas # | |
# https://gist.github.com/ricardocanelas # | |
#-----------------------------------------# | |
# + Apache # | |
# + PHP 7.1 # | |
# + MariaDB 10.1 # | |
# + NodeJs, Git, Composer, etc... # | |
########################################### | |
# Update your Vagrant install before using. | |
# --------------------------------------------------------------------------------------------------------------------- | |
# Variables & Functions | |
# --------------------------------------------------------------------------------------------------------------------- | |
APP_DATABASE_NAME='app' | |
echoTitle () { | |
echo -e "\033[0;30m\033[42m -- $1 -- \033[0m" | |
} | |
# --------------------------------------------------------------------------------------------------------------------- | |
echoTitle 'Virtual Machine Setup' | |
# --------------------------------------------------------------------------------------------------------------------- | |
# Update packages | |
apt-get update -qq | |
apt-get -y install git curl vim | |
# --------------------------------------------------------------------------------------------------------------------- | |
echoTitle 'Installing and Setting: Apache' | |
# --------------------------------------------------------------------------------------------------------------------- | |
# Install packages | |
apt-get install -y apache2 libapache2-mod-fastcgi apache2-mpm-worker | |
# linking Vagrant directory to Apache 2.4 public directory | |
# rm -rf /var/www | |
# ln -fs /vagrant /var/www | |
# Add ServerName to httpd.conf | |
echo "ServerName localhost" > /etc/apache2/httpd.conf | |
# Setup hosts file | |
VHOST=$(cat <<EOF | |
<VirtualHost *:80> | |
DocumentRoot "/var/www/default" | |
ServerName app-php71.test | |
ServerAlias app-php71.test | |
<Directory "/var/www/default"> | |
AllowOverride All | |
Require all granted | |
</Directory> | |
</VirtualHost> | |
EOF | |
) | |
echo "${VHOST}" > /etc/apache2/sites-enabled/000-default.conf | |
# Loading needed modules to make apache work | |
a2enmod actions fastcgi rewrite | |
sudo service apache2 restart | |
# --------------------------------------------------------------------------------------------------------------------- | |
echoTitle 'Maria-Database' | |
# --------------------------------------------------------------------------------------------------------------------- | |
# Install MariaDB | |
export DEBIAN_FRONTEND=noninteractive | |
debconf-set-selections <<< 'mariadb-server-10.0 mysql-server/root_password password root' | |
debconf-set-selections <<< 'mariadb-server-10.0 mysql-server/root_password_again password root' | |
apt-get install -y mariadb-server | |
# Set MariaDB root user password and persmissions | |
mysql -u root -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION; FLUSH PRIVILEGES;" | |
# Open MariaDB to be used with Sequel Pro | |
sed -i 's|127.0.0.1|0.0.0.0|g' /etc/mysql/my.cnf | |
# Restart MariaDB | |
sudo service mysql restart | |
# --------------------------------------------------------------------------------------------------------------------- | |
echoTitle 'Installing: PHP' | |
# --------------------------------------------------------------------------------------------------------------------- | |
# Add repository | |
add-apt-repository ppa:ondrej/php | |
apt-get update | |
apt-get install -y python-software-properties software-properties-common | |
# Remove PHP5 | |
# apt-get purge php5-fpm -y | |
# apt-get --purge autoremove -y | |
# Install packages | |
apt-get install -y php7.1 php7.1-fpm | |
apt-get install -y php7.1-mysql | |
apt-get install -y mcrypt php7.1-mcrypt | |
apt-get install -y php7.1-cli php7.1-curl php7.1-mbstring php7.1-xml php7.1-mysql | |
apt-get install -y php7.1-json php7.1-cgi php7.1-gd php-imagick php7.1-bz2 php7.1-zip | |
# --------------------------------------------------------------------------------------------------------------------- | |
echoTitle 'Setting: PHP with Apache' | |
# --------------------------------------------------------------------------------------------------------------------- | |
apt-get install -y libapache2-mod-php7.1 | |
# Enable php modules | |
# php71enmod mcrypt (error) | |
# Trigger changes in apache | |
a2enconf php7.1-fpm | |
sudo service apache2 reload | |
# Packages Available: | |
# apt-cache search php7-* | |
# --------------------------------------------------------------------------------------------------------------------- | |
# echoTitle 'Installing & Setting: X-Debug' | |
# --------------------------------------------------------------------------------------------------------------------- | |
# cat << EOF | sudo tee -a /etc/php/7.1/mods-available/xdebug.ini | |
# xdebug.scream=1 | |
# xdebug.cli_color=1 | |
# xdebug.show_local_vars=1 | |
# EOF | |
# --------------------------------------------------------------------------------------------------------------------- | |
# Others | |
# --------------------------------------------------------------------------------------------------------------------- | |
echoTitle 'Installing: Node 6 and update NPM' | |
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - | |
apt-get install -y nodejs | |
npm install npm@latest -g | |
echoTitle 'Installing: Git' | |
apt-get install -y git | |
echoTitle 'Installing: Composer' | |
curl -s https://getcomposer.org/installer | php | |
mv composer.phar /usr/local/bin/composer | |
echoTitle 'Getting vhost command' | |
wget -O /usr/local/bin/vhost https://gist.github.com/fideloper/2710970/raw/5d7efd74628a1e3261707056604c99d7747fe37d/vhost.sh | |
sudo chmod guo+x /usr/local/bin/vhost | |
# --------------------------------------------------------------------------------------------------------------------- | |
# Others | |
# --------------------------------------------------------------------------------------------------------------------- | |
# Output success message | |
echoTitle "Your machine has been provisioned" | |
echo "-------------------------------------------" | |
echo "MariaDB is available on port 3306 with username 'root' and password 'root'" | |
echo "(you have to use 127.0.0.1 as opposed to 'localhost')" | |
echo "Connect using SSH with host '192.168.71.71', username 'vagrant' and password 'vagrant'" | |
echo "Apache is available on port 80" | |
echo -e "Head over to http://192.168.71.71 to get started" |
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 : | |
# Update your Vagrant install before using. | |
Vagrant.configure("2") do |config| | |
config.vm.box = "ubuntu/xenial64" | |
config.vm.network "private_network", ip: "192.168.71.71" | |
# This line may require you to enter a password during vagrant up | |
# config.vm.synced_folder "~/Web", "/var/www/", :nfs => { :mount_options => ["dmode=777","fmode=666"] } | |
# If you have trouble with NFS above, comment it out and use the following instead | |
config.vm.synced_folder "~/Web", "/var/www/", :mount_options => ["dmode=777", "fmode=666"] | |
# config.vm.synced_folder "~/Web", "/var/www/", :owner=> 'www-data', :group=>'root' | |
config.vm.provider "virtualbox" do |vb| | |
vb.memory = "1024" | |
vb.cpus = 1 | |
end | |
config.ssh.insert_key = false | |
config.vm.provision :shell, keep_color: true, path: "provision.sh" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment