无法在 Linux 上启动 Laravel 开发服务器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33691609/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to start laravel development server on linux
提问by Fokwa Best
I am using laravel 5 for my project and everything has been working fine but recently I am facing this problem which I done understand.
我正在为我的项目使用 laravel 5,一切正常,但最近我遇到了这个我完全理解的问题。
devboy@devboy-hp ~/sonel_ims_project/ims_eneo $ php artisan serve
Laravel development server started on http://localhost:8000/
[Fri Nov 13 12:00:56 2015] Failed to listen on localhost:8000 (reason: Address already in use)
I have tried devboy@devboy-hp ~ $ sudo netstat -plnt
and get
我已经尝试devboy@devboy-hp ~ $ sudo netstat -plnt
并得到
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1840/dnsmasq
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1985/cupsd
tcp 0 0 127.0.0.1:8888 0.0.0.0:* LISTEN 7563/php-5.6.3
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 1656/master
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 6966/httpd
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 740/smbd
tcp 0 0 127.0.0.1:6942 0.0.0.0:* LISTEN 7442/java
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 6931/php-5.6.3
tcp 0 0 0.0.0.0:6667 0.0.0.0:* LISTEN 1539/ircd
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 740/smbd
tcp 0 0 127.0.0.1:63342 0.0.0.0:* LISTEN 7442/java
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 6966/httpd
tcp6 0 0 :::21 :::* LISTEN 7337/proftpd: (acce
tcp6 0 0 ::1:631 :::* LISTEN 1985/cupsd
tcp6 0 0 :::3128 :::* LISTEN 1416/squid3
tcp6 0 0 :::25 :::* LISTEN 1656/master
tcp6 0 0 :::445 :::* LISTEN 740/smbd
tcp6 0 0 :::3306 :::* LISTEN 7343/mysqld
tcp6 0 0 :::139 :::* LISTEN 740/smbd
Then I change port like so php artisan serve --port="8888"
but get similar error like below after a while:
然后我像这样更改端口,php artisan serve --port="8888"
但一段时间后得到类似如下的错误:
Laravel development server started on http://localhost:8888/
[Fri Nov 13 12:01:02 2015] Failed to listen on localhost:8888 (reason: Address already in use)
The first time it happened, it was java using port 8000, so I killed the process and started the server and it worked. Upon stopping and restarting, I get the same error. What could be the problem (as I said everything has been working fine except now and I have not done any major update)?
第一次发生时,它是使用端口 8000 的 java,所以我终止了该进程并启动了服务器并且它工作了。停止并重新启动后,我得到同样的错误。可能是什么问题(正如我所说的,除了现在一切正常,而且我还没有进行任何重大更新)?
采纳答案by Fokwa Best
This is exactly what I did for the problem.
这正是我为这个问题所做的。
- I exit PHPStorm
sudo netstat -plnt
kill 7563 (Process using port 8888)
kill 6931 (Process using port 8000)
sudo /opt/lampp/lampp restart
(Restart my server altogther)php artisan serve
- Launch PhpStorm
- 我退出 PHPStorm
sudo netstat -plnt
kill 7563 (Process using port 8888)
kill 6931 (Process using port 8000)
sudo /opt/lampp/lampp restart
(重新启动我的服务器)php artisan serve
- 启动 PhpStorm
Now everything is working fine. What caused the problem anyway?
现在一切正常。到底是什么导致了这个问题?
回答by Gujarat Santana
Your previous deployment in your local is already running that's why you can't run php artisan serve
. You can solve your issue by following this command in your terminal:
您之前在本地的部署已经在运行,这就是您无法运行php artisan serve
. 您可以通过在终端中执行以下命令来解决您的问题:
ps -ef | grep php
you'll see this list:gujarat 6690 3500 0 05:55 pts/1 00:00:00 php artisan serve
gujarat 6694 6690 0 05:55 pts/1 00:00:00 sh -c '/usr/bin/php5' -S localhost:8000 '/home/gujarat/WebDevelopment/quickstart-basic'/server.php
gujarat 6695 6694 0 05:55 pts/1 00:00:00 /usr/bin/php5 -S localhost:8000 /home/gujarat/WebDevelopment/quickstart-basic/server.php
gujarat 7436 3500 0 06:26 pts/1 00:00:00 grep --color=auto phpNow kill it using:
sudo kill 6690
if still exist then use thissudo kill -9 6690
you'll see this result:[1]+ Killed php artisan serve
ps -ef | grep php
你会看到这个列表:古吉拉特邦 6690 3500 0 05:55 pts/1 00:00:00 php 工匠服务
古吉拉特邦 6694 6690 0 05:55 pts/1 00:00:00 sh -c '/usr/bin/php5' -S 本地主机: /home/gujarat/WebDevelopment/quickstart-basic'/server.php
gujarat 6695 6694 0 05:55 pts/1 00:00:00 /usr/bin/php5 -S localhost:8000 /home/gujarat/WebDevelopment/quickstart-基本/server.php
古吉拉特邦 7436 3500 0 06:26 pts/1 00:00:00 grep --color=auto php现在使用以下方法杀死它:
sudo kill 6690
如果仍然存在,则使用它,sudo kill -9 6690
您将看到以下结果:[1]+ 杀死 php artisan serve
Now you can serve your local using php artisan serve
again
现在您可以php artisan serve
再次使用本地服务
回答by Sudhakar Annadurai
please restart apache server
请重启apache服务器
sudo apache restart
And once again run your project in another port
再次在另一个端口运行你的项目
php artisan serve --port=2020
回答by user2182349
Using lsof, you can see what is listening on the port.
使用 lsof,您可以查看端口上正在侦听的内容。
sudo lsof -i :80
Change the 80 to whichever port you're interested. You need to be root or sudo.
将 80 更改为您感兴趣的任何端口。您需要是 root 或 sudo。
回答by Shabeer Sha
Run this comment
运行此评论
sudo netstat -plnt
The output will show like this
输出将显示如下
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 14 0 127.0.0.1:8000 0.0.0.0:* LISTEN 3648/php7.3
Then kill the port:8000 using this comment
然后使用此注释杀死端口:8000
kill -9 3648
回答by Huey Mataruse
Well the problem might be it didnt stop the expected way previously eg via CTRL+Cso what you can do is to check for running php processes and kill them 1 by 1.
那么问题可能是它没有停止以前的预期方式,例如通过CTRL+C所以你可以做的是检查正在运行的 php 进程并一一杀死它们。
i) Run ps -A
from the terminal then identify the php process ids (most of the times they are two)
i)ps -A
从终端运行,然后识别 php 进程 ID(大多数情况下它们是两个)
ii) Run sudo kill -9 pid#
corresponding to the php pids.
ii) 运行sudo kill -9 pid#
对应的php pids。
iii) Run php artisan serve
and it will work.
iii) 运行php artisan serve
,它将起作用。