Skip to content

Instantly share code, notes, and snippets.

@cullylarson
Last active January 31, 2016 00:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cullylarson/7bd20b5bf934af340c82 to your computer and use it in GitHub Desktop.
Save cullylarson/7bd20b5bf934af340c82 to your computer and use it in GitHub Desktop.
Vagrant CentOS 6.6
#!/bin/sh
# set timezone
echo "\n--- Set timezone to America/Los_Angeles\n"
rm /etc/localtime && ln -s /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
# update
echo "\n--- Updating Yums"
yum -y update
# install packages
echo "\n--- Installing packages\n"
yum -y install httpd mysql-server php php-common php-process php-mbstring php-gd php-xml php-mysql php-cli php-pdo php5-mcrypt php5-json git sendmail vim-enhanced screen patch
# start mysql
echo "\n--- Starting MySQL\n"
service mysqld start
# create mysql database
echo "\n--- Creating MySQL Database\n"
mysql -u root -e "CREATE DATABASE dev; GRANT ALL PRIVILEGES ON dev.* TO dev@localhost IDENTIFIED BY 'dev'; FLUSH PRIVILEGES;"
# setup webroot
echo "\n--- Setting Up Webroot\n"
if ! [ -L /var/www ]; then
rm -rf /var/www
mkdir -p /var/www
ln -fs '/vagrant' /var/www/html
fi
# configure apache
echo "\n--- Configuring Apache\n"
# make apache run as vagrant user
sed -i 's/User\sapache/User vagrant/' /etc/httpd/conf/httpd.conf
# include site-specific conf files
sed -i "s|Include conf\.d/\*\.conf|Include conf.d/\*\.conf\nInclude conf\.d/sites/\*\.conf|" /etc/httpd/conf/httpd.conf
# create a default conf file
mkdir /etc/httpd/conf.d/sites
echo '<VirtualHost *:80>' > /etc/httpd/conf.d/sites/default.conf
echo ' ServerAdmin webmaster@localhost' >> /etc/httpd/conf.d/sites/default.conf
echo ' DocumentRoot /var/www/html' >> /etc/httpd/conf.d/sites/default.conf
echo ' ErrorLog /etc/httpd/logs/error_log' >> /etc/httpd/conf.d/sites/default.conf
echo ' CustomLog /etc/httpd/logs/access_log combined' >> /etc/httpd/conf.d/sites/default.conf
echo ' <Directory "/var/www/html">' >> /etc/httpd/conf.d/sites/default.conf
echo ' AllowOverride All' >> /etc/httpd/conf.d/sites/default.conf
echo ' DirectoryIndex index.php' >> /etc/httpd/conf.d/sites/default.conf
echo ' Options Indexes FollowSymLinks' >> /etc/httpd/conf.d/sites/default.conf
echo ' </Directory>' >> /etc/httpd/conf.d/sites/default.conf
echo '</VirtualHost>' >> /etc/httpd/conf.d/sites/default.conf
# configure PHP
echo "\n--- Configuring PHP\n"
echo 'file_uploads = On' > /etc/php.d/vagrant.ini
echo 'upload_max_filesize = 50M' >> /etc/php.d/vagrant.ini
echo 'post_max_size = 70M' >> /etc/php.d/vagrant.ini
# turn off iptables because it's stupid
echo "\n--- Turning of iptables\n"
service iptables stop
chkconfig iptables off
# make services run on startup
echo "\n--- Turning Services On\n"
chkconfig httpd on
chkconfig mysqld on
# start apache
echo "\n--- Starting Apache\n"
service httpd start
# SSH keys
echo "\n--- Generate SSH key\n"
ssh-keygen -f /home/vagrant/.ssh/id_rsa -t rsa -N ''
sed -i 's/root@localhost.localdomain/vagrant@localhost.localdomain/' /home/vagrant/.ssh/id_rsa.pub
chown -R vagrant:vagrant /home/vagrant/.ssh
# install composer
echo "\n--- Installing Composer\n"
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
# install node
echo "\n--- Installing Node\n"
runuser -l vagrant -c "curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash"
runuser -l vagrant -c "nvm install v0.12.8"
runuser -l vagrant -c "echo v0.12.8 > ~/.nvmrc"
# install gulp
echo "\n--- Install npm Packages\n"
npm install --global gulp
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "puppetlabs/centos-6.6-64-nocm"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.provision "shell", path: "./vagrant-provision.sh"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment