-
-
Save matheus-souza/aa45d27cbf0e7975a3431dbf5e30bf22 to your computer and use it in GitHub Desktop.
Vagrant config file and provisioning script
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 | |
echo '' | |
echo ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' | |
echo ' Installing Ubuntu Precise 32bit for Laravel 4' | |
echo ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' | |
echo ' Apache 2.2, PHP 5.3/5.4/5.5, MySQL 5.5' | |
echo ' Vim, cURL, Git, Composer, pip, HTTPie' | |
echo '' | |
# --------------- | |
# Various fixes | |
# --------------- | |
echo '- Fixing locales issues with Ubuntu...' | |
dpkg-reconfigure locales | |
update-locale LANG=en_US.UTF-8 | |
echo '...done' | |
# ------------------------ | |
# Update and basic tools | |
# ------------------------ | |
echo '- Updating apt-get repositories...' | |
apt-get update | |
echo '...done' | |
echo '- Installing vim...' | |
apt-get install -y vim | |
echo '...done' | |
# --------------- | |
# Apache 2.2.22 | |
# --------------- | |
echo '- Installing Apache 2...' | |
apt-get install -y apache2 | |
echo '...done' | |
echo '- Setting up Apache 2 virtual host...' | |
# Remove /var/www default | |
rm -rf /var/www | |
# Symlink /vagrant to /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> | |
ServerName localhost | |
DocumentRoot "/vagrant/public" | |
<Directory "/vagrant/public"> | |
Options +ExecCGI -Indexes +Includes -FollowSymLinks +SymLinksIfOwnerMatch +MultiViews | |
AllowOverride All | |
Order allow,deny | |
Allow from all | |
</Directory> | |
ErrorLog ${APACHE_LOG_DIR}/error.log | |
CustomLog ${APACHE_LOG_DIR}/access.log combined | |
</VirtualHost> | |
EOF | |
) | |
echo "${VHOST}" > /etc/apache2/sites-enabled/000-default | |
# Enable mod_rewrite | |
a2enmod rewrite | |
# Restart apache | |
service apache2 restart | |
echo '...done' | |
# --------- | |
# PHP 5.4 | |
# --------- | |
echo '- Installing python-software-properties...' | |
apt-get install -y libapache2-mod-php5 | |
apt-get install -y python-software-properties | |
echo '...done' | |
# #For PHP 5.4 uncomment the following lines | |
# echo '- Adding PHP 5.4 PPA...' | |
# add-apt-repository ppa:ondrej/php5-olstable | |
# echo '- Updating apt-get repositories...' | |
# apt-get update | |
# echo '...done' | |
# #For PHP 5.5 uncomment the following lines | |
# echo '- Adding PHP 5.5 PPA...' | |
# add-apt-repository ppa:ondrej/php5 | |
# echo '- Updating apt-get repositories...' | |
# apt-get update | |
# echo '...done' | |
echo '- Installing PHP...' | |
apt-get install -y php5 | |
echo '...done' | |
echo '- Installing required PHP modules' | |
# Command-Line Interpreter | |
apt-get install -y php5-cli | |
# MySQL database connections directly from PHP | |
apt-get install -y php5-mysql | |
# cURL is a library for getting files from FTP, GOPHER, HTTP server | |
apt-get install -y php5-curl | |
# Module for MCrypt functions in PHP | |
apt-get install -y php5-mcrypt | |
echo "date.timezone = Europe/Berlin" > /etc/php5/conf.d/date.ini | |
service apache2 restart | |
echo '...done' | |
# ------ | |
# cURL | |
# ------ | |
echo '- Installing cURL...' | |
apt-get install -y curl | |
echo '...done' | |
# ----------- | |
# MySQL 5.5 | |
# ----------- | |
echo '- Installing MySQL...' | |
export DEBIAN_FRONTEND=noninteractive | |
apt-get -q -y install mysql-server-5.5 | |
# ----- | |
# Git | |
# ----- | |
echo '- Installing Git...' | |
apt-get install -y git-core | |
echo '...done' | |
# ---------- | |
# Composer | |
# ---------- | |
echo '- Installing Composer...' | |
curl -s https://getcomposer.org/installer | php | |
# Make Composer available globally | |
mv composer.phar /usr/local/bin/composer | |
echo '...done' | |
# -------------- | |
# pip & HTTPie | |
# -------------- | |
echo '- Installing pip...' | |
curl -s http://python-distribute.org/distribute_setup.py | python | |
easy_install pip >/dev/null | |
echo '...done' | |
echo '- Installing HTTPie...' | |
pip install --upgrade httpie >/dev/null | |
rm distribute-0.6.48.tar.gz | |
echo '...done' | |
# ------------- | |
# Final setup | |
# ------------- | |
# Add aliases | |
sed -i '$a alias art="php artisan"' /home/vagrant/.bashrc | |
# Create script for python smtpd | |
SMTPD=$(cat <<EOF | |
#!/usr/bin/env bash | |
echo '' | |
echo 'Starting Python SMTP daemon...' | |
echo 'Listening to port 25' | |
echo 'Outgoing emails will display in this session' | |
echo 'Ctrl-C to quit' | |
sudo python -m smtpd -n -c DebuggingServer localhost:25 | |
EOF | |
) | |
echo "${SMTPD}" > /usr/local/bin/pysmtpd | |
chmod +x /usr/local/bin/pysmtpd | |
# Set up the database | |
echo "CREATE DATABASE IF NOT EXISTS matisse" | mysql | |
echo "CREATE USER 'matisse'@'localhost' IDENTIFIED BY 'mysql'" | mysql | |
echo "GRANT ALL PRIVILEGES ON matisse.* TO 'matisse'@'localhost' IDENTIFIED BY 'mysql'" | mysql |
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/syntax version. Don't touch unless you know what you're doing! | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
# Box to build off of. | |
config.vm.box = "precise32" | |
# The URL that the configured box can be found at. | |
config.vm.box_url = "http://files.vagrantup.com/precise32.box" | |
# The hostname of the machine. | |
config.vm.hostname = "matisse.dev" | |
# Configures networks on the machine. | |
config.vm.network :private_network, ip: "10.0.0.100" | |
# Configures synced folders. | |
config.vm.synced_folder "app/storage", "/vagrant/app/storage", :owner => 'vagrant', :group => 'www-data', :mount_options => ['dmode=775,fmode=664'] | |
# Configures provisioners. | |
config.vm.provision :shell, :path => "install.sh" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment