Last active
August 29, 2015 14:00
-
-
Save austenc/11381580 to your computer and use it in GitHub Desktop.
provisions Vagrantfile-laravel to have a nice usable setup
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
#!/usr/bin/env bash | |
## RENAME THIS FILE TO provision.sh TO USE WITH OTHER VAGRANTFILES | |
# update all packages | |
apt-get update | |
# enable add-apt-repository command | |
sudo apt-get install -y python-software-properties | |
# Get the latest php5, nodejs, and phpmyadmin | |
# since ubuntu 12.04 LTS has older versions and doesn't have node | |
add-apt-repository ppa:ondrej/php5-oldstable > /dev/null 2>&1 | |
add-apt-repository ppa:chris-lea/node.js > /dev/null 2>&1 | |
add-apt-repository ppa:tuxpoldo/phpmyadmin > /dev/null 2>&1 | |
# Update apt-get first | |
apt-get update | |
# install vim and unzip and apache | |
apt-get install -y vim unzip apache2 | |
# map apache's default directory to our (shared) project folder | |
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 "/vagrant/public" | |
ServerName localhost | |
<Directory "/vagrant/public"> | |
AllowOverride All | |
</Directory> | |
</VirtualHost> | |
EOF | |
) | |
echo "${VHOST}" > /etc/apache2/sites-enabled/000-default | |
# install mysql and create needed databases | |
export DEBIAN_FRONTEND=noninteractive | |
apt-get -q -y install mysql-server | |
# install php and turn on errors | |
echo -e "\n--- Installing PHP ---\n" | |
apt-get install -y php5 php-pear php5-dev php5-mysql php-cli | |
sudo sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php5/apache2/php.ini | |
sudo sed -i "s/display_errors = .*/display_errors = On/" /etc/php5/apache2/php.ini | |
# install phpmyadmin | |
echo phpmyadmin phpmyadmin/reconfigure-webserver text apache2 | sudo debconf-set-selections | |
echo phpmyadmin phpmyadmin/dbconfig-install boolean true | sudo debconf-set-selections | |
echo phpmyadmin phpmyadmin/app-password-confirm password | sudo debconf-set-selections | |
echo phpmyadmin phpmyadmin/mysql/admin-pass password | sudo debconf-set-selections | |
echo phpmyadmin phpmyadmin/password-confirm password | sudo debconf-set-selections | |
echo phpmyadmin phpmyadmin/setup-password password | sudo debconf-set-selections | |
echo phpmyadmin phpmyadmin/mysql/app-pass password | sudo debconf-set-selections | |
apt-get install -y phpmyadmin | |
sed -ire '/\$cfg\['\''Servers'\''\]\[\$i\]\['\''AllowNoPassword'\''\] = TRUE/ s/^.*\/\/ / /' /etc/phpmyadmin/config.inc.php | |
# install composer | |
apt-get install -y curl git-core | |
curl -sS https://getcomposer.org/installer | php | |
# make composer available globally | |
mv composer.phar /usr/local/bin/composer | |
# make sure the rewrite module is enabled | |
a2enmod rewrite | |
service apache2 restart | |
# enable htaccess files everywhere since this is local dev | |
sed -i '/AllowOverride None/c\AllowOverride All' /etc/apache2/sites-available/default | |
# install nodeJS and grunt | |
sudo apt-get -y install nodejs | |
sudo npm install -g grunt-cli | |
# install grunt's dependencies | |
cd /vagrant | |
sudo npm install --no-bin-links | |
# install bower | |
sudo npm install -g bower --no-bin-links | |
# install dependencies from composer, laravel, etc.. | |
composer install --dev | |
# create a database to use | |
mysql -u root -Bse "CREATE DATABASE IF NOT EXISTS testmaster;" | |
# (optional) Uncomment to enable. Run migrations and seed database | |
# php artisan migrate | |
# php artisan db:seed | |
# restart apache one last time | |
service apache2 restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment