PHP artisan use domain without port number - php

When I serve my laravel project with php artisan serve --host=yum-yums.local, I can access the site via http://yum-yums.local:8000
My host file has 127.0.0.1 yum-yums.local
How can I access the site with just yum-yums.local please, with no port number appended?

80 port is the default port number of http so you have to use this command to omit the port number:
sudo php artisan serve --host=localhost --port=80

Related

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

How to set a domain name with php artisan serve

I am new to PHP and Laravel. While virtualhosting with Wamp, I could specify the documentroot, servername and the port number - hence specifying the domain name. But with the command php artisan serve, I am able to specify the port address but not the domain name.
Is it possible to set the domain name?
also, what is the difference between hosting with this command and with wamp ?
n.b I am new to server side languages, sorry for asking these basics !
EDIT: I've used php artisan serve --host=blog.local --port=8001 but error is showing up
I've cleared the configuration and application cache.
You can explicitly define the host and the port with artisan serve command:
php artisan serve --host=somedomain.com --port=8001
Note: Remember to enable to port with your firewall.
Though it is too late.
Make an entry in the system host file. in case of windows it is at
C:\Windows\System32\Drivers\etc\hosts
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 blog.local
Then run your command:
php artisan serve --host=blog.local --port=8001
It's easy, just pass the --host parameter.
php artisan serve --host=example.com
Try to command like this:
php artisan serve --host=<host IP address> --port=<port to use>
Example:
php artisan serve --host=127.0.0.1 --port=8080
First of all you will need to add your local domain in the host file. The path is C:\Windows\System32\drivers\etc and you will found the host file.
Open with notepad and write this line 127.0.0.1 <your_domain_name> to the last line. For example 127.0.0.1 lala.com
Then the command on your terminal,
php artisan serve --host=<your_domain_name_in_the_host_file>
and system will auto generate a port number for you like
php artisan serve --host=lala.com
Laravel development server started: http://lala.com:8000
Now then, you are able to surf your localhost, which is http://lala.com:8000 with your custom domain name but also with the port number.
If you want a custom port number then just specify the port number at the end of the command,
php artisan serve --host=lala.com --port=8088
and url will be http://lala.com:8088
Try this command.
php artisan serve --host=0.0.0.0 --port=8000
You can try it:
php artisan serve --host 192.168.0.1 --port 80
Change your host and port

PHP artisan serve error - failed to listen on 127.0.0

I was writing in terminal to install Laravel on my PC but this is what I’m getting. Is that has to do something with my IP address? I’ve downloaded Xampserver to fix this but still nope.
Try changing artisan serve port using this command:
php artisan serve --port=4546
You can do two things
change a port
Stop applications which runs on port 80(Skype probably )
Changing port
php artisan serve --port=8085
Stop Skype
Skype>Tools>Options>Advanced>Connection.
Untick/Uncheck Use port 80 and 443 as an alternatives for incoming connections
click Save

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 enable PHP's built-in web server on wercker

I have setup my wercker.yml file with the following step midway:
- script:
name: Serve application
code: php -S localhost:8000 >> /dev/null &
That appears to run, however, in another step when I try cURL to http://localhost:8000 I get the following:
curl: (7) Failed to connect to localhost port 8000: Connection refused
It does it for all ports, not just 8000. Has anyone else managed to get PHP's in built server working in wercker, or open any ports?
Assuming you're using the wercker CLI and trying to set up a development pipeline, you need to use wercker dev with the --publish 8000 argument. This will forward the traffic from your host on port 8000 to the container on port 8000.
Also, if you're using boot2docker, you can't specify localhost, since boot2docker spins up a VM that runs docker. In that case you'll need to use your boot2docker IP, which you can find by running the boot2docker ip command.

Categories