alias lamp="curl -L -o 'install.sh' http://bit.ly/1hBfq57 && curl -L -o 'Vagrantfile' http://bit.ly/1mE3Qt9 && vagrant up" |
This comment has been minimized.
This comment has been minimized.
Do you use it this way yourself (with the shortened links in your alias)? |
This comment has been minimized.
This comment has been minimized.
I use something a bit more robust - but for quick setups, this is a good option. (If people don't trust the shortened links, they can inspect them first.) |
This comment has been minimized.
This comment has been minimized.
Allright! Was just wondering :) |
This comment has been minimized.
This comment has been minimized.
Is it bad practice to put multiple project on the same vagrant machine? |
This comment has been minimized.
This comment has been minimized.
@krizzlix - that's a decision you can make based on your own needs. If you have different apps with different environments (PHP differences, installations like Nemcache or APC, etc), you may want to differentiate. If you're rolling with the same stuff on each project, or the differences don't matter, go ahead and use the same box for anything. Definitely take the time to learn how to setup Apache virtualhosts to make any option you'd like available to yourself :D Naturally I'll also mention serversforhackers.com here... |
This comment has been minimized.
This comment has been minimized.
Okei, thanks ;) |
This comment has been minimized.
This comment has been minimized.
Great! Thanks again for all the tips Jeffrey |
This comment has been minimized.
This comment has been minimized.
I pretty much use the same thing but I use the awesome puphpet.com to do my orchestration. |
This comment has been minimized.
This comment has been minimized.
First of all thx for the script. I would love to see a section on what to do for a laravel setup somewhere in the documentation. I would suggest Extra Credit 5 is laravel specific. ;-) Thx |
This comment has been minimized.
This comment has been minimized.
@MaartenD - Okay, I'll add Extra Credit 5 today. Update: done. |
This comment has been minimized.
This comment has been minimized.
For the record, in Windows, if you have the cUrl library installed, you need to use this instead: Also thank you so much @JeffreyWay and @fideloper you guys gave me the push to try vagrant again and your scripts made it super simple! Thank you tons! |
This comment has been minimized.
This comment has been minimized.
Thanks, this works just fine, almost anyway. After a while, only a white page is displayed, it does not display any error message. No errors appear in the logs How do I resolve this? Why does this happen? |
This comment has been minimized.
This comment has been minimized.
@LPMAXI - You need to set the proper permissions. chmod -R 777 app/storage |
This comment has been minimized.
This comment has been minimized.
Is there a windows alternative to all this? It looks amazing! |
This comment has been minimized.
This comment has been minimized.
@bgallagh3r I tried using curl, but at the end of it, it said... Could not resolve host: Vagrant. Could not resolve host: up. I know curl and Vagrant are working, is there a certain version I should be using for this? I'm on a Windows 8 PC. :) |
This comment has been minimized.
This comment has been minimized.
Setting Also tried the trick described here with settings |
This comment has been minimized.
This comment has been minimized.
Jeffrey, |
This comment has been minimized.
This comment has been minimized.
@ronnyandre I had the same problem but the trick with the mount_options seems to work for me. Thank you! |
This comment has been minimized.
This comment has been minimized.
Same as @ronnyandre, tried EDIT: |
This comment has been minimized.
This comment has been minimized.
When I setup "Extra Credit 5: Laravel Setup" it works for about 5 mins, then I get a white screen with this console error. "Uncaught TypeError: Cannot call method 'create' of undefined" I tried restarting vagrant box but nothing works. Anyone knows whats wrong? PS. |
This comment has been minimized.
This comment has been minimized.
I fixed it by using: sudo chmod -R guo+w app/storage Does anyone know why? |
This comment has been minimized.
This comment has been minimized.
Getting blank screen on Laravel. Tried chmod on storage, but doesn't seem to help. What could do the trick? |
This comment has been minimized.
This comment has been minimized.
@nicoeg this worked for me: $ cd app/storage (not sure if it's best practice or not...) |
This comment has been minimized.
This comment has been minimized.
oops, that didn't show up right... should be a * on both sides of the slash. See here (http://laravel-recipes.com/recipes/43) |
This comment has been minimized.
This comment has been minimized.
Why Guest additions are only on version 4.2 not 4.3? Can this cause problems to folder sharing? |
This comment has been minimized.
This comment has been minimized.
Thank you so much. Love laracasts. I am curious why, in step 5, Laravel is setup from the local host rather than from within the guest environment - is this required or could you run all steps after vagrant ssh? I also experience the same issue as @nicoeg, the laravel screen appears on first load, but then loads a blank page with no errors. If I shut my mac down, come back, vagrant up etc then the laravel image loads when I goto the root of the page, but it will not reload again with a refresh, no matter how many tries. Permissions on app/storage are wide open. Any help or insight appreciated. Finally figured it out - it was permissions related, but permissions on the vendor folder and below - it worked the first time because it had read access, but I guess a refresh triggered a write within the log folder - for similarities sake I ran chmod -R 777 on the vendor folder. Although it sucked up some hours, it was a great learning experience (I'm new). Great video - loving Laracasts. |
This comment has been minimized.
This comment has been minimized.
I was having a similar permissions problem as those described above. Initially I thought I solved it by doing sudo chmod -R 0777 app/storage on host computer rather than vagrant box. However, the blank white screens returned whenever laravel tried to write to the sessions file. After some Googling the following solution worked for me. Change the Vagrant config file to read like this on line 12:
Run vagrant reload and the problem should be solved. |
This comment has been minimized.
This comment has been minimized.
Thank you @davecoggins |
This comment has been minimized.
This comment has been minimized.
This is fantastic. Also the sql databases, are they stored inside the project in question, or are they stored globally in mac. Using mamp , there have been times when I added a project to git and forgot to export the DB, in this case is the DB within the same folder, Hope I am making sense |
This comment has been minimized.
This comment has been minimized.
Humm... all of sudden "lamp" command installs nothing... |
This comment has been minimized.
This comment has been minimized.
I managed to get both sites working - sort of. I have one that is local.dev which refers to the vagrant directory (var/www on the vm) and index.php shows up there. |
This comment has been minimized.
This comment has been minimized.
Thanks for this. I would add that it was hanging on the message "Verifying Hyper-V is enabled", this is because vboxmanage wasn't available and meant I had to add "C:\Program Files\Oracle\VirtualBox" to my Path environment variable |
This comment has been minimized.
This comment has been minimized.
Another thank you to @davecoggins EDIT: I just reverted my config.vm.synced_folder line in vagrant back to the original settings. I opted to edit /etc/apache2/envvars and have apache2 run as vagrant user and group. |
This comment has been minimized.
This comment has been minimized.
Can anyone confirm if this still works? I haven't been able to get it to work at all. To clarify: Running the script works fine and vagrant seems to be set up properly, but navigating to the server's IP address results in a 403 Forbidden error. I've followed to steps carefully, repeatedly, but no luck. If anyone can confirm this still works properly, I guess I'll look into troubleshooting it further. Thanks. |
This comment has been minimized.
This comment has been minimized.
Yes this is work. |
This comment has been minimized.
This comment has been minimized.
Thanks heaps for this.... Can anyone please help me access the mysql from an IDE such as Sequel Pro. what is the ssh username and password? |
This comment has been minimized.
This comment has been minimized.
In windows, make lamp.bat and put this in: curl -L -o install.sh http://bit.ly/1hBfq57 |
This comment has been minimized.
This comment has been minimized.
vagrant ssh |
This comment has been minimized.
This comment has been minimized.
Does anyone know what the username and password is for the VM? If say I wanted to SSH in without using Vagrant. Great walkthrough by the way, and thanks @davecoggins, lifesaver! |
This comment has been minimized.
This comment has been minimized.
Found it, username = vagrant, password = vagrant. Sequel Pro now connects to the remote mysql without any extra configuration. @JeffreyWay and @fideloper what are your thoughts on hosting the DB on the virtual server, now that it's so easy to set up its also easy to destroy, and lose all of your development data. |
This comment has been minimized.
This comment has been minimized.
are we updating this alias and setup? |
This comment has been minimized.
This comment has been minimized.
would be great if someone creates an install.sh for nginx php-fpm. |
This comment has been minimized.
This comment has been minimized.
could get the install to work.. Fixed the File with http://foo-o-rama.com/vagrant--stdin-is-not-a-tty--fix.html# edited the Vagrantfile # -*- 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| config.vm.provision "fix-no-tty", type: "shell" do |s| s.privileged = false s.inline = "sudo sed -i '/tty/!s/mesg n/tty -s \\&\\& mesg n/' /root/.profile" end config.vm.box = "precise64" config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.network :private_network, ip: "192.168.101.101" config.vm.provision :shell, :path => "install.sh" config.vm.synced_folder ".", "/var/www" end |
This comment has been minimized.
This comment has been minimized.
@JeffreyWay How can I install node.js on this box to use Elixir |
This comment has been minimized.
This comment has been minimized.
I think I've done something wrong. When I get to Step 4 above, here's what happens: vagrant up vm:
Please advise. Thanks. |
This comment has been minimized.
This comment has been minimized.
Hi,
Thanks, |
This comment has been minimized.
This comment has been minimized.
Getting errors when running this culminating in the following; The SSH command responded with a non-zero exit status. Vagrant Full log here https://gist.github.com/devonmather/6c50c824ad89efac15e85a323c52c879 I've listed the errors from the console output that were red below the gist in a comment |
This comment has been minimized.
Step 0: Video
Laracasts users can watch this entire process in screencast form.
Step 1: Install Vagrant and Virtual Box
Step 2: Add the Alias
Add the alias above to
~/.bashrc
(or wherever you prefer).Step 3. Install
cd
to your desired directory in the Terminal, and runlamp
to install your LAMP stack.Step 4. Done. Go Poke Around.
Your MySQL username and password, by default, will be 'root'.
To test things out, try:
If you
cd
to/vagrant
, this folder will be shared with your project root on your local/host machine. That means, when you create a file on your Mac, it will instantly be shared (both ways) with the/vagrant
directory on your VM. However, we're also syncing with the/var/www
directory on your VM, which is the Apache root. That means, if you visit http://192.168.33.21, you should see "It Worked!" You can change the IP address in your Vagrantfile, if you need to.Have fun! This also installs and enables X-Debug for you. You can stop using MAMP now.
Extra Credit 1
Edit your hosts file to set a simpler address, like
http://app.dev/
.At the bottom of this file, add:
Now, browse to
http://app.dev
.Extra Credit 2
By default, Apache will set your document root to
/var/www/html
. If you don't want this...Reload the browser. Now, your local project root will be treated as Apache's document root. Typically, though, you'll want to set Apache's document root to something like the
public
directory - soDocumentRoot /var/www/public
.Extra Credit 3
Learn more about Vagrant:
Extra Credit 4: Multiple Websites With the Same VM
Maybe you want to run all of your sites and demos within this VM. Here's how.
For this example, maybe we're building a new app, called "Larabook." Begin by creating a new directory, "larabook" within the same directory that has the Vagrantfile that you pulled in during Step 3. Add a dummy
index.php
file here, just to prove that it's working.Next:
$ vagrant ssh $ cd /etc/apache2/sites-available/ $ sudo cp 000-default.conf larabook.conf
Open `larabook.conf, and set:
You don't have to for this example, but you'd probably want to add some additional config to this file - like:
Next, enable the new vhost, and reload Apache.
Lastly, don't forget to update your hosts file (on your local machine, not the VM):
And add:
That's it. Browse to
http://larabook.local
, and you'll correctly see the contents of the file in your ./larabook directory. :)Extra Credit 5: Laravel Setup
Let's add a Laravel project.
laravel new laravel vagrant ssh cd /etc/apache2/sites-available/ sudo cp 000-default.conf laravel.conf sudo vi laravel.conf
Within this file, set:
Next, enable the site:
On your host/local machine, update the
/etc/hosts
file:Finally, if you view
http://laravel.dev
in the browser and see a blank screen, that's usually a permissions issue on theapp/storage
directory. From yourwebsites/laravel
directory, run:And reload the browser. Done!