How to Auto serving laravel - php

is there any way to auto serving you laravel project?
i'm using virtual host.
<VirtualHost *:80> #laragon magic!
DocumentRoot "C:/laragon/www/pos/public/"
ServerName apk.dev
ServerAlias *.apk.dev
</VirtualHost>
and to access it locally i open the Cmdr and write
php artisan serve --host 192.168.1.100 --port 80
every single time.
and i access it with other device with 192.168.1.100 it's working fine, i just want to know is there any way that i don't need to repeat it, and just by running the laragon i also can access the apk.dev from other device with my local network?

Related

How to open laravel website in VMWARE from local PC?

I have a laravel apps that i installed on VMWARE Redhat and using SQL Server on my local pc. I can open the website in VMWARE and it can connect to my local Sqlserver. I also can open my local website from VMWARE browser.
But how to open my laravel website on VMWARE from local pc?
in /etc/hosts, i add this line
192.168.0.154 laravel.example.com
and here is my httpd.conf
<VirtualHost *:80>
ServerName 192.168.0.154
ServerAlias laravel.example.com
DocumentRoot /var/www/xxx/public
Redirect permanent / https://192.168.0.154
<Directory /var/www/xxx/public>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<VirtualHost _default_:443>
ServerName 192.168.0.154
ServerAlias laravel.example.com
ServerAdmin admin#laravel.example.com
DocumentRoot /var/www/xxx/public
SSLEngine on
SSLCertificateFile "/etc/pki/tls/certs/laravel.example.com-selfsigned.crt"
SSLCertificateKeyFile "/etc/pki/tls/private/laravel.example.com-selfsigned.key"
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
i already run php artisans serve using port 80/8080/433, and open the website in local pc with url http://laravel.example.com:port/ and still get error
php artisan serve --host laravel.example.com --port 8080
Do you have some log on your web server when you try to connect on it ? If so, you will get more information that might help you to solve your problem.
Did you add 192.168.0.154 laravel.example.com on your local PC too ? It's necessary.
You can check if the firewall on your VM doesn't block your connection.

How to share a laravel project on the local network

I have a laravel project and its user has a virtual domain how do I publish it in the local network only
This is my configuration in httd.vhosts.conf file
<VirtualHost *:80>
ServerName smarts.local
DocumentRoot "C:/xampp/htdocs/smarts/public"
SetEnv APPLICATION_ENV "development"
<Directory "C:/xampp/htdocs/smarts/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
This is in my hosts file
127.0.0.1 smarts.local
Currently it works on my pc only but does not work on other devices in the network.
you can use the artisan command,
first run the cmd on your computer,
then go to the folder of your project like this: cd c:\wamp64\your_project_folder,
then type this code: php artisan serve --host=YOUR IP --port=ONE FREE PORT
you can find your computer port with the running this command in cmd: ipconfig /all
your command should be like this:
php artisan serve --host=192.168.1.106 --port=8080
and the others can run your project from your computer with writing this code in the addressBar of their own browser : 192.168.1.106:8080
If you want others to access smarts.local.
make sure your system ip address is static.
then every one who wants to access smarts.local should add the following to their hosts file
127.0.0.1 smarts.local (Replace 127.0.0.1 with ur public static ip)
or you should use DNS server in your network.
You can also write a startup command which will execute php artisan serve.(But you have to make sure ur public ip is static)
Its so much easy to do.
1.In windows go to cmd and type ipconfig.
2.get you local IPv4 Address (e.g:192.168.1.5).
3.Go to visual studio code and open Terminal
4.Type like this (php artisan serve --host=IPv4 Address)
Hopefully this will help you to share your project inside your same network.

Creating a virtual host for laravel project

I am using localhost:8080. Does this make any difference while virtual hosting? when I enter lsapp.test in browser, it says page cannot be reached.
Try to change your port to 8080 in httpd-vhosts file
<VirtualHost *:8080>
...
...
...
# Other directives here
</VirtualHost>
then restart your apache server and access like this lsapp.test:8080.

Serve Laravel app with Apache (wampserver) to access from other computers in same LAN

I need to access my Laravel app that is served with Apache (wampserver) from other computers in the same LAN.
OS: Windows 8.1
Wampserver version: 3.0.6
Apache version: 2.4.23
I can access my app from other computers by the following URL:
http://192.168.12.13/scms/public/
The following URLs also work:
http://192.168.12.13/scms/public/categories/create
But it does not work when I submit POST request from the above URL. It redirects to the following -
http://192.168.12.13/categories
And shows "Not Found". So, it does not work.
To solve the issue, I have setup virtual host for my app which works perfectly in my own computer. But I cannot access it from other computers.
My setup:
In file:
C:\wamp64\bin\apache\apache2.4.23\conf\httpd.conf
Added this line:
Listen 192.168.12.13:80
In file:
C:\wamp64\bin\apache\apache2.4.23\conf\extra\httpd-vhosts.conf
Full code:
# Virtual Hosts
# wamp
<VirtualHost *:80>
DocumentRoot "C:\wamp64\www"
ServerName localhost
</VirtualHost>
# scms
<VirtualHost *:80>
DocumentRoot "C:\wamp64\www\scms\public"
ServerName local.scms-ananta.com
<Directory "C:\wamp64\www\scms\public">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
In file:
C:\Windows\System32\drivers\etc\hosts
Added the following lines:
127.0.0.1 local.scms-ananta.com
192.168.12.13 local.scms-ananta.com
With the above setup, I can perfectly work with my app using the following URL in my own computer:
http://local.scms-ananta.com
But I cannot access it from other computers on my network.
Kindly note, serving with php artisan serve will not serve my purpose. I need to serve it with Apache.
Any help is highly appreciated.
First of all editing host file will not help you while accessing from other computer unless you also edit all of those PC's host file. So it would be best to access with IP.
Now problem with your configuration is that for serving/deploying laravel website in your server you have to put public folder as your document root.
Follwoing is your configuration for localhost
# wamp
<VirtualHost *:80>
DocumentRoot "C:\wamp64\www"
ServerName localhost
</VirtualHost>
Change the documentroot to the following will solve your problem.
DocumentRoot "C:\wamp64\www\scms\public"

How can I access my Laravel app from another PC?

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?
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.
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
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>
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>
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>
Restart all your apache services
This should do it, i'm using wamp on Windows and works for me.
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
Find your machine local IP:
ifconfig
Go to project folder and type following command:
sudo php artisan serve --host your_ip --port your_port
example:
sudo php artisan serve --host 192.168.1.70 --port 8080
Browse form other computer:
192.168.1.70:8080
You can do it by using laravel's built in command php artisan serve.
Follow the steps:
Go to your project's root directory within command line.
run php artisan serve
If you still can't access port 8000 or it is already in use then run:
php artisan serve --port 8383
And it should listen on new port you provided. Also you can set other options for this command. Look for the help php artisan help serve.

Categories