Access Laravel Project on Network Machine - php

i am new to laravel and basically i am a nodejs developer, i basically develop application in sailsjs and i access my sailjs application on another machine within same network by using my machine ip on which the project is running.
like i lift main salsjs application on A machine using sails lift --port 1334 and then goto another machine B within same network and access is with my A machine ip , like 192.168.10.2:1334
now i want to do the same thing with laravel, i've lifted my server using laravel command
ahsan#ahsan-Inspiron-N5110:~/Desktop/Development/laravell/laravel$ sudo php artisan serve --port 1334
Laravel development server started on http://localhost:1334
and now the application is running on 1334 port and when i try to access it from machine B within same network it just says unble to connect.
Please let me knowo what do i need to do to access it over network with my machine A ip address.
Thanks.
Note: i am using UBUNTU on Machine A and have access to sailsjs application on Machine B which is windows based but not the laravel application access

php artisan serve --host 0.0.0.0 --port 1334
or
php artisan serve --host 192.168.10.2 --port 1334
in most cases you will need permissions (sudo) to start this. If its not working, check your firewall (iptables)

Related

How do I successfully serve a local Laravel app on my phone without the connection refused error?

I'm running a Laravel 9 app on my MacBook using php artisan serve. I would like to see the app on my Android phone, but I'm failing.
Both the computer and the phone are connected to the same WiFi network. I serve the app on my computer and access its public IP:port on my phone, like this:
HTTP://192.168.1.10:8000
However, all I'm getting is an error in Chrome: Err_Connection_Refused. Tried Firefox as well.
What might be wrong or missing here?
The full artisan command for running a Laravel application that you want reached from other devices is
sudo php artisan serve --host 192.168.1.10 --port 8080
This opens up listening to the external port of 8080 for incoming traffic from outside localhost or 127.0.0.1

How to use custom domain on Laravel in Windows Server

Am looking for an approach to dealing with the following issue. Any assistance is greatly appreciated.
I have 3 Laravel applications running on a windows server with the server name "php_apps".
Each laravel application is served to a port. e.g;
php artisan serve --port 8001 --host 0.0.0.0
php artisan serve --port 8002 --host 0.0.0.0
php artisan serve --port 8003 --host 0.0.0.0
And the URLs are http://php_apps:8001, http://php_apps:8002, and http://php_apps:8003
How do I replace the port numbers with names, to read something like; http://php_apps/first_app, http://php_apps/second_app, and http://php_apps/third_app
My aim is to replace the port numbers with something more descriptive and readable.
How best would you suggest I go about it?
Just use Valet for windows :) Enjoy

Gcloud expose yii on LAMP stack

How to expose yii2 basic or advanced project to localhost:80 on gcloud vm LAMP instance with numerical external address? Right now LAMP is running /var/www/shared and can pickup {exteralip}/phpmyadmin/ page.
Yii2 start serve start on localhost:8080
I can see ::1:8080 LISTEN with sudo netstat -ntlp
And i opened firewall 0.0.0.0/0 tcp:8080 to test it, but {externalip}:8080/ returns connection refused
How i could test yii2 and have it in gcloud?

How can i access a second laravel app from another pc

On this link:
how can i access my laravel app from another pc?
It is perfectly described how to access an laravel app from another pc on the same network.
Now, my question is:
How to access another app served on the same pc?
I have a virtual machine serving two apps app.dev and demo.dev
both are accessible inside VM through internet browser
app.dev is accessible on http://localhost and http://app.dev
demo.dev is accessible only on http://demo.dev
Outside VM only app.dev is accessible on IP address 192.168.0.60
i have used this command inside VM
sudo php artisan serve --host 192.168.0.60 --port 80
Should i use again
sudo php artisan serve ????
but how? anybody help?
Laravel's artisan serve command uses the PHP Built-in web server. Because that is not a full featured web server, it has no concept of virtual hosts, so it can only run one instance of the server mapped to an IP and port pair.
Normally to serve two hosts from the same IP address you'd add in your VM's /etc/hosts file the following mappings:
192.168.0.60 app.dev
192.168.0.60 demo.dev
Now you can run app.dev by running:
php artisan serve --host app.dev --port 80
And it will be available on your host machine using http://app.dev. However if you would try to spin up a second server instance for demo.dev using this:
php artisan serve --host demo.dev --port 80
It won't work and will complain that:
Address already in use
You could get around that by using a different port for your demo.dev app by using for example this:
php artisan serve --host demo.dev --port 8080
And now you'd be able to access http://demo.dev:8080 for your second app on your host machine.
That being said, I suggest you install a full featured web server such as Apache or nginx and then setup a virtual host for each application (just make sure to keep the mappings from the /etc/hosts file I showcased above).
Setting up virtual hosts can be really easy for both server solutions. Below are links to two articles from the Laravel Recipes website that showcase how to do that specifically for Laravel:
Creating an Apache VirtualHost
Creating a Nginx VirtualHost

How to set up access to Symfony2 application via web browser?

I have a Linux virtual box, built using Vagrant. I am working on an application built using Symfony2 and wish to use PHP's built in server to host the application. I have got the PHP server running successfully using the command: php bin/console server:start. This tells me:
[OK] Web server listening on http://127.0.0.1:8000
I've specified the following in the Vagrantfile:
config.vm.network "private_network", ip: "192.168.56.109
I want to access the application via the browser on my host machine which is running on Windows 7.
How can I achieve this?
The default IP for the built-in web server is 127.0.0.1. In order for it to be visible outside your vagrant machine, you need to bind it to 0.0.0.0:
php bin/console server:start 0.0.0.0
Then you access http://192.168.56.109:8000 and it should work correctly.

Categories