我是Laravel的新手,我使用
php artisan serve
每次使用Laravel。每次使用Laravel是否需要使用此命令?
答案 0 :(得分:0)
您可以配置nginx或apache2,因此无需每次都运行命令。 在生产中,您将需要一个真正的http服务器。 尝试this to configure apache for laravel project,or this for nginx with laravel
答案 1 :(得分:0)
C:\Windows\System32\drivers\etc
中打开hosts文件。将此添加到内容的底部。
192.168.1.120(Your local IP) test.local
保存文件。
然后从apache服务器打开conf文件。例如,如果您使用的是xampp,请在C:\xampp\apache\conf\extra
中打开httpd-vhosts.conf
文件。
将此添加到内容的底部。
<VirtualHost example.local:80>
DocumentRoot "C:/yourprojectfolder/public/"
ServerAdmin admin@example.local
ServerName example.local
<Directory "C:/yourprojectfolder/public/">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
然后,您无需工匠即可访问该项目。在浏览器中,打开http://example.local/
ta da!
答案 2 :(得分:0)
PHP是服务器端脚本语言,需要特殊的环境才能运行。这是一个http服务器。
所以答案是肯定的。您必须使用服务器来运行应用程序。
Laravel内置了一个由您运行的人:
php artisan serve
您当然可以使用其他Web服务器,例如Apache,Ngix,但这是另一个主题的问题,例如“如何在Apache上运行Laravel应用”。