Set port for php artisan.php serve

2019-01-12 23:00发布

How do we set a custom port for test server?

Normally when we do

php artisan serve

the folder gets served as :

localhost:8000

How do could we access one folder as:

localhost:8080

I want to access two different development sites on my localhost.

5条回答
我命由我不由天
2楼-- · 2019-01-12 23:42

Andreas' answer above was helpful in solving my problem of how to test artisan on port 80. Port 80 can be specified like the other port numbers, but regular users do not have permissions to run anything on that port.

Drop a little common sense on there and you end up with this for Linux:

sudo php artisan serve --port=80

This will allow you to test on localhost without specifying the port in your browser. You can also use this to set up a temporary demo, as I have done.

Keep in mind, however, that PHP's built in server is not designed for production. Use nginx/Apache for production.

查看更多
叛逆
3楼-- · 2019-01-12 23:43

as this example you can change ip and port this works with me

php artisan serve --host=0.0.0.0 --port=8000
查看更多
淡お忘
4楼-- · 2019-01-12 23:50

One can specify the port with: php artisan serve --port=8080.

查看更多
别忘想泡老子
5楼-- · 2019-01-12 23:52

For port 8080:

 php artisan serve --port=8080

And if you want to run it on port 80, you probably need to sudo:

sudo php artisan serve --port=80
查看更多
ゆ 、 Hurt°
6楼-- · 2019-01-13 00:00

You can use

php artisan serve --port 80

Works on Windows platform

查看更多
登录 后发表回答