Laravel development server cannot be accessed outside Vagrant - php

I'm trying to run a simple Laravel project inside a Vagrant (VirtualBox) VM. The guest is Ubuntu 14.04 x64, and the host is Windows 7 x64. I've set up port forwarding (8000 on host to 8000 on guest), but when I run php artisan serve, though I get a message stating that the server is running on port 8000, when I visit localhost:8000 on my host machine, Chrome tells me 'this webpage is not available'. There are two complications:
First, if I use curl from inside the VM, I receive the correct page contents - so it appears the server is working fine.
Second, if I run a Python web server using python -m SimpleHTTPServer on the same VM, I can access it fine on my host OS. Visiting localhost:8000, I see the directory contents listed. So it appears the port forwarding is working fine.
I tried deleting the public/.htaccess file in the Laravel project, to no avail. I'm no PHP expert, and this problem is hard to Google! Any pointers would be appreciated.

After reading this question I tried
php artisan serve --host 0.0.0.0
And it works fine now.

Related

laravel port is changing automatically?

laravel port changing automatically after i started my server the server is restarted each time i refresh the page or move to another page the port is changing
(http://127.0.0.1:8000 => http://127.0.0.1:8001 =>...........)
even when i used the option --port the server stopped from running
i am running
Laravel Framework 8.11.2
PHP 7.4.9
#vue/cli 4.5.9
Ubuntu machine

Running a PHP site in an unoccupied port

I have a different app runnning in localhost:8000. If I run a second app through the server, it dumps the one running and it places itself in this port. I need to be able to run both. Ideally in separate ports:
App1 in localhost:8000 Which runs a React/webpack/node app
App2 in localhost:8080 Which runs the PHP version of the site.
I'm using atom as my IDE with a built-in command terminal if that helps. And Apache as my local server (XAMPP and WAMPP in mac and Win respectively)
I found the way to do it without having to do much work creating VirtualHosts and using PHP Built-in Server
Step 1 - Open your XAMPP console and click on the Shell
Step 2 - CD to $PATH. For example cd c:\xampp\htdocs\site_folder
Step 3 - Type php -S localhost:8080 and hit Enter
Step 4 - In the browser, navigate to localhost:8080 and it will show.
Step 5 - For the second website, open a separate CMD terminal and repeat the process by selecting the $PATH to that website folder and assigning a different port numbe (i.e 8000), hit Enter, navigate to that localhost:8000 in a separate browser tab or window and voila! Now both sites are running independently!

Port 8000 not responding. Others will

So, ran into something very weird. Pretty new to Laravel.
Created a Laravel project and did some coding before running anything. I had previously created just a blank Laravel app and it was running just fine using all defaults. This was a second new project.
In the new project I can get Laravel running fine using php artisan serve --port=81 (non-default) but if I use just "php artisan serve" or "php artisan serve --port=8000" I get no response. Netstat shows no other processes using 8000, I've explicitly punched holes in Windows Firewall for that port and for php just in case. Nothing odd in hosts file. Not seeing anything that should be causing it.
There aren't any errors thrown when running php artisan serve, it comes up normally telling me it has started on port 8000. But whenever I try to access anything on that port it just doesn't respond. There's no "Whoops" message, it (Chrome or Postman) just sits there waiting for a response. Change it to port 81, 82, whatever, works as expected.
I have XAMPP installed though I'm not using it for Apache just now so Apache is turned off. Just for giggles I changed apache config to point at the public folder of that project on port 8000 and started it ... Worked fine; got the expected result from public/index.php.
Working with PHPStorm version 2017.2. I do have XDebug installed. Configured for port 9000. Not debugging via PHPStorm, just running artisan server.
PHP 7.1, Laravel 5.4, Windows 10
Any suggestions? I'm at a bit of a loss as I'm not seeing any errors anywhere and being rather new not sure where else to look/how to debug.
Holy poopies.
Got it figured out.
As it turns out, when I added XDebug for PHP I fat fingered the default port for that to 8000 rather than 9000 in PHP.ini. It was then intercepting all the http requests on that port and swallowing them up it seems.
Everything pointed to some sort of configuration setting but when looking at settings in PHPStorm it still showed XDebug as set for port 9000. Since that's what I thought I entered in PHP.ini I assumed it was pulling it from there so I never looked at the ini file directly.

Laravel 5 application moved from local machine to hosting server causing errors

I developed an application in laravel 5.0 in local machine using xampp and it's working fine. After i uploaded the project to hosting server using ftp now i am getting following errors one below the other.
The issue is you don't have right permission on project/storage/framework/sessions folder, so give the permission to 0777 i.e read write execute and after that run the following command:
php artisan config:cache
through terminal or putty on server and every thing will be fine.

Access PHP website on virtual linux machine from host machine

I have installed Ubuntu Server 10 on a virtual machine (VMWare) and I have set up a LAMP stack. Everything runs fine when I go to "mysitename" in Firefox on the linux virtual machine, but when I try to access it on my windows machine, it only gives me the HTML in my .php file, and does not execute the PHP. Can anyone provide some suggestions? I'm guessing it will be an apache setting, but I'm not sure.
What URL are you accessing from your Windows machine? Are you sure that the PHP file is actually interpreted when you're accessing it from the Linux Guest?

Categories