Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trouble with Vagrant - "404 - Not Found"

I am attempting to make a LAMP box using Vagrant. I have been told that it is quite simple to use. I am completely new to networks and virtual machines and have very little experience with Linux/Ubuntu. I have currently tried following the tutorial on the official documentation page: http://docs.vagrantup.com/v2/getting-started/networking.html.

I have gotten up to the networking article in the documentation and can't seem to get it working.

Now the problem is, due to my inexperience with networking and linux based OS's I have no idea where to begin trouble shooting. I will try to give as much information I can.

I'm running the latest version of Vagrant with the latest version of Virtualbox with Windows 8.1.

As per the tutorial, my current Vagrantfile looks like this:

Vagrant.configure(2) do |config|
  config.vm.box = "hashicorp/precise32"
  config.vm.provision :shell, path: "bootstrap.sh"
  config.vm.network :forwarded_port, host: 4567, guest: 80
end

My bootstrap.sh file looks like this:

#!/usr/bin/env bash

apt-get update
apt-get install -y apache2
if ! [ -L /var/www ]; then
  rm -rf /var/www
  ln -f /vagrant /var/www
fi

When I went to http://127.0.0.1:4567, it displayed an error page containing this message:

Not Found

The requested URL / was not found on this server.
===================================================
Apache/2.2.22 (Ubuntu) Server at 127.0.0.1 Port 4567

I would rather not edit any config files, unless there was an explanation, as I feel that would be a workaround. But regardless, ANY help would be appreciated. If I need to open up a port, then how do I'm at the point where I'm just considering using XAMPP.

like image 248
Dimi Avatar asked Jun 21 '15 01:06

Dimi


3 Answers

I had same problem. I tried to restart apache from the vagrant box, I got following warning on my terminal.

vagrant@vagrant-ubuntu-trusty-64:~$ sudo service apache2 restart
 * Restarting web server apache2   

AH00112: Warning: DocumentRoot [/var/www/html] does not exist
AH00558: apache2: Could not reliably determine the server's fully qualified 
domain name, using 10.0.2.15. Set the 'ServerName' directive globally to suppress this message

Create a DocumentRoot to fix the 404 issue by creating a directory called /var/www/html

like image 52
Chatura Dinesh Halwatura Avatar answered Sep 24 '22 02:09

Chatura Dinesh Halwatura


The issue is on /etc/apache2/sites-enabled 000-default file.

Apache2 is pointing to var/www/html and vagrant example to var/www just remove de /html and make a sudo service apache2 restart.

like image 41
cristiandley Avatar answered Sep 22 '22 02:09

cristiandley


Can you access your web server from inside your virtual machine ?

For example, try curl localhost:80

if curl is not installed, use sudo apt-get install curl on Ubuntu and try again.

Also, have you checked your apache virtual hosts ? Is there a 000-default file in /etc/apache2/sites-available ?

like image 33
jiop Avatar answered Sep 23 '22 02:09

jiop