-
-
Save fideloper/7074502 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash | |
echo ">>> Starting Install Script" | |
# Update | |
sudo apt-get update | |
# Install MySQL without prompt | |
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root' | |
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root' | |
echo ">>> Installing Base Items" | |
# Install base items | |
sudo apt-get install -y vim tmux curl wget build-essential python-software-properties | |
echo ">>> Adding PPA's and Installing Server Items" | |
# Add repo for latest PHP | |
sudo add-apt-repository -y ppa:ondrej/php5 | |
# Update Again | |
sudo apt-get update | |
# Install the Rest | |
sudo apt-get install -y git-core php5 apache2 libapache2-mod-php5 php5-mysql php5-curl php5-gd php5-mcrypt php5-xdebug mysql-server | |
echo ">>> Configuring Server" | |
# xdebug Config | |
cat << EOF | sudo tee -a /etc/php5/mods-available/xdebug.ini | |
xdebug.scream=1 | |
xdebug.cli_color=1 | |
xdebug.show_local_vars=1 | |
EOF | |
# Apache Config | |
sudo a2enmod rewrite | |
curl https://gist.github.com/fideloper/2710970/raw/vhost.sh > vhost | |
sudo chmod guo+x vhost | |
sudo mv vhost /usr/local/bin | |
# PHP Config | |
sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php5/apache2/php.ini | |
sed -i "s/display_errors = .*/display_errors = On/" /etc/php5/apache2/php.ini | |
sudo service apache2 restart | |
# Git Config and set Owner | |
curl https://gist.github.com/fideloper/3751524/raw/.gitconfig > /home/vagrant/.gitconfig | |
sudo chown vagrant:vagrant /home/vagrant/.gitconfig | |
echo ">>> Installing Composer" | |
# Composer | |
curl -sS https://getcomposer.org/installer | php | |
sudo mv composer.phar /usr/local/bin/composer | |
echo ">>> Setting up Vim" | |
# Create directories needed for some .vimrc settings | |
mkdir -p /home/vagrant/.vim/backup | |
mkdir -p /home/vagrant/.vim/swap | |
# Install Vundle and set finally owner of .vim files | |
git clone https://github.com/gmarik/vundle.git /home/vagrant/.vim/bundle/vundle | |
sudo chown -R vagrant:vagrant /home/vagrant/.vim | |
# Grab my .vimrc and set owner | |
curl https://gist.github.com/fideloper/a335872f476635b582ee/raw/.vimrc > /home/vagrant/.vimrc | |
sudo chown vagrant:vagrant /home/vagrant/.vimrc | |
# Install Vundle Bundles | |
sudo su - vagrant -c 'vim +BundleInstall +qall' |
@toblebooth Thank you very much for the clarification on this... Just wanted to make sure I wasn't forgetting something.
This will also install Apache 2.4+ (2.4.6 as of this writing). This update to Apache (2.4) has some new things to pay attention to if you're used to configuring Apache virtual hosts.
So, it is basically working... But it doesnt seem to host the laravel code (although it appears there when I have an ssh connection). When I hit localhost:4567 (my defined port in VagrantFile) I see the follow
It works!
This is the default web page for this server.
The web server software is running but no content has been added, yet.
Hey @mikeerickson - did you figure out the next steps?
Something like this (I haven't tested any of these yet:
# Create Laravel Project
cd /vagrant
composer create-project laravel/laravel project-name
# Set virtual host to Laravel Project web root
# using provided "vhost" tool:
sudo vhost -s mysite.local -d /vagrant/project-name/public
sudo service apache2 reload
Essentially you need to create a laravel project and then setup a virtual host. Then you can use your host file to point the domain (mysite.local in this example) to your virtual machine. I always give my Vagrant box a static IP address rather than use port forwarding.
If you use the standard port forwarding settings, you probably want to use the VM's "localhost" (default site) to point to the laravel project's public
directory.
You can edit /etc/apache2/sites-available/000-default.conf
and change the DocumentRoot
path there, and skip the "vhost" commands above.
-OR-, perhaps easier, you can symlink the "/var/www" directory to your laravel project's web root:
# Create Laravel Project
cd /vagrant
composer create-project laravel/laravel project-name
# Symlink /var/www to laravel project web root
sudo rm -rf /var/www
sudo ln -s /vagrant/project-name/public /var/www
What of apache to remove to support Nginx?
@renege - That's something I'd like to build as well. This blog post goes over installing Nginx and is otherwise mostly the same.
Note that you'd need to replace the Apache install stuff with Nginx, remove the install of the vhost
tool, then add-in the install of the php5-fpm
package, and then finally configure Nginx to read php5-fpm. That's outlined in the blog post linked above.
Hopefully I get to that sometime soon...
You can follow the following to get zsh working in Ubuntu as well.
Is this still actual? :) Looks very good!
Is this still actual? :) Looks very good!
Great question.
Great question!
I'm working with a modded version (I left out the last part concerning vim, and also on line 15, because I prefer nano), now I get this error:
Vagrantfile:32:in `block (2 levels) in <top (required)>': wrong number of arguments (1 for 0) (ArgumentError)
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.2/plugins/kernel_v2/config/vm_provisioner.rb:72:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.2/plugins/kernel_v2/config/vm_provisioner.rb:72:in `add_config'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.2/plugins/kernel_v2/config/vm.rb:336:in `provision'
from /Users/admin/VagrantBoxes/vagrant_1st_project/Vagrantfile:31:in `block in <top (required)>'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.2/lib/vagrant/config/v2/loader.rb:37:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.2/lib/vagrant/config/v2/loader.rb:37:in `load'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.2/lib/vagrant/config/loader.rb:113:in `block (2 levels) in load'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.2/lib/vagrant/config/loader.rb:107:in `each'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.2/lib/vagrant/config/loader.rb:107:in `block in load'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.2/lib/vagrant/config/loader.rb:104:in `each'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.2/lib/vagrant/config/loader.rb:104:in `load'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.2/lib/vagrant/vagrantfile.rb:28:in `initialize'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.2/lib/vagrant/environment.rb:746:in `new'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.2/lib/vagrant/environment.rb:746:in `vagrantfile'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.2/lib/vagrant/environment.rb:492:in `host'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.2/lib/vagrant/environment.rb:214:in `block in action_runner'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.2/lib/vagrant/action/runner.rb:33:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.2/lib/vagrant/action/runner.rb:33:in `run'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.2/lib/vagrant/environment.rb:479:in `hook'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.2/lib/vagrant/environment.rb:728:in `unload'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.2/bin/vagrant:130:in `ensure in <main>'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.2/bin/vagrant:130:in `<main>'
@mikeerickson This will install php 5.5 from the ondrej PPA. You've however been misinformed about 5.5 not having JSON support, further details here: http://philsturgeon.co.uk/blog/2013/08/fud-cracker-php-55-never-lost-json-support