Score:0

Apache Default page instead of Laravel Application

cn flag

I am sure this is the kind of question that is annoying, but I am brand new to ubuntu and I am totally lost, hence I don't know what to google for.

I have to deploy a laravel application on a Ubuntu 21.04 VM, I connect via SSH & a VPN to the VM (its from my university).

I installed the laravel application successfully and when I run php artisan serve it works, I get the message PHP 7.4.16 Development Server (http://127.0.0.1:8000) started

However, when I then enter the IP of the server in my browser I get the default apache webpage, when I enter the IP with port 8000 I get that the server is not responding.

I tried googling but I just don't know what to google for, any help appreciated!

Score:1
jp flag
Dan

When you are running php artisan serve, that command is starting its own webserver. And based on the output you posted, it is listening only on 127.0.0.1:8000.

So accessing it outside of that machine is not allowed. Based on this question on Stack Overflow, you can override the default host with the --host parameter.

In your case you can run it like so:

php artisan serve --host=<IP_ADDRESS_OF_THE_VM>

or you can make it open to the world with

php artisan serve --host=0.0.0.0
cn flag
Sadly the outcome or rather the things I see when visiting the site are the same :/
jp flag
Dan
@newbie When you run the command, is the output changing from `http://127.0.0.1:8000` to the host you are setting?
cn flag
Yes that works! I get this PHP 7.4.16 Development Server (http://132.231.36.101:8000) started - but I still have that the server is not responding
cn flag
I tried some more stuff and when I try to run your command now I get error message that it "Failed to listen on <IP_Address> + a port - reason: Cannot assign requested address
jp flag
Dan
@newbie does it work when you use `0.0.0.0` in the command? Do you have any firewall enabled?
cn flag
gotta try that! I am not sure since I didn't set up the server. It is from my university and I need to have the vpn running to access it, so it is just available inside the university network
cn flag
I just tried wit `0.0.0.0`but it doesn't work either. I am so fucked
cn flag
I don't know that the issue in the end was, but I just wiped everything, tried it again and then your solution worked! Thanks a lot :)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.