Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I access my Laravel app from another PC?

Tags:

php

laravel

I'm trying to access my Laravel app from another PC in the same network using IP address but I can't get it to work by accessing 192.168.1.101:8000 in my browser.

What should I do?

like image 772
DNM Avatar asked Mar 10 '15 05:03

DNM


People also ask

How can I access laravel site from another network?

If you are on Linux or Mac, type ifconfig at the terminal. If you are on Windows, type ipconfig at the command prompt. If you'd also like to pass the port parameter, just add --port=XX to the artisan serve command. And voila!


4 Answers

Why don't you use Laravel's artisan for it? Very simple:

sudo php artisan serve --host 192.168.1.101 --port 80

Now from other computers, you can type: http://192.168.1.101

Do not forget to replace the IP with your own local one. That's it.

Note: The sudo is only needed if you wanna serve on port 80.

like image 135
Mustafa Ehsan Alokozay Avatar answered Oct 24 '22 03:10

Mustafa Ehsan Alokozay


Access laravel using your IP address

php artisan serve --host 0.0.0.0 

Now you can access laravel server by http://laravel-server-ip-address:8000

If you want to change the port as well then

php artisan serve --host 0.0.0.0 --port 8101

Now your laravel server is http://laravel-server-ip-address:8101

like image 34
Bhavsar1311 Avatar answered Oct 24 '22 04:10

Bhavsar1311


  1. Go to httpd.conf in Apache folder and find the following lines:

    DocumentRoot "c:/wamp/www"
    <Directory "c:/wamp/www">
        # ...Stuffs in here
        Options Indexes FollowSymLinks
        # ...Stuffs in here
        AllowOverride All
        #
        # Controls who can get stuff from this server.
        #
        Require all granted
    </Directory>
    
  2. Then replace the last line within <Directory> tag for:

         Order Deny,Allow
         Deny from all
         Allow from 127.0.0.1
         Allow from ::1
         Allow from localhost
    </Directory>
    
  3. Add a virtual host for your laravel application, go to httpd-vhosts.conf and add the following lines:

    <VirtualHost *:80>
        DocumentRoot "D:/.../your-laravel-app-path/public"
        ServerName yourservername.dev
        <Directory "D:/.../your-laravel-app-path/public">
            AllowOverride All
            Order deny,allow
            Allow from all
            Require all granted
        </Directory>
    </VirtualHost>
    
  4. Restart all your apache services

This should do it, i'm using wamp on Windows and works for me.

like image 9
Robin Curbelo Avatar answered Oct 24 '22 05:10

Robin Curbelo


Use this command in which ip address is ip-v4. Check ip-v4 from your wifi connection properties.

php artisan serve --host 192.168.10.15 --port 5000
like image 1
Ahsan Khan Avatar answered Oct 24 '22 05:10

Ahsan Khan