Yesterday I did this question :
I made a REST api, using Laravel , for an application that I am doing, to carry out the requisition tests I created a VM where is the api.
Assign a fixed ip to this VM and disable the firewall to not to bother.
I configured this way:
In
/etc/apache2/sites-enabled/000-default.conf
:<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> <VirtualHost *:80> ServerName api.dev DocumentRoot /var/www/html/apiTeste/public </VirtualHost> <Directory "/var/www/html/apiTeste"> AllowOverride All </Directory> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
In
/etc/hosts
:127.0.0.1 localhost 127.0.1.1 ouvidoria 127.0.0.1 api.dev # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters
Testing within the same VM, using
http://api.dev
this returns the Laravel homepage, but is usedhttp://api.dev/api/unidades
this returns a404 Not Found
:Not Found The requested URL /api/unidades was not found on this server. Apache/2.4.25 (Ubuntu) Server at api.dev Port 80
However, the% s of% and access
php artisan serve
this returns the data correctly.
If you try to access from outside the VM, entering the address http://api.dev:8000/api/unidades
returns the page http://192.168.0.23/
as it should be.
Accessing Apache2 Ubuntu Default Page
shows me the http://192.168.0.23/apiTeste/public/
home page.
But if I enter the address of the request Laravel
this returns me an error of http://192.168.0.23/api/unidades
:
Not Found
The requested URL /api/unidades was not found on this server.
Apache/2.4.25 (Ubuntu) Server at 192.168.0.23 Port 80