[英]Start laravel app on apache2.4 on windows 10
I have a laravel app, which I test with php artisan serve
. 我有一个laravel应用,可通过
php artisan serve
测试。
I discovered that this is a bad practise, because it is not used on production. 我发现这是一个坏习惯,因为它没有在生产中使用。
I have installed apache2.4, it worked, when I open localhost I see 'It Works'. 我已经安装了apache2.4,它可以正常工作,当我打开本地主机时,我看到“有效”。
Now I try to start my laravel app through apache on my PC. 现在,我尝试通过PC上的apache启动laravel应用。
For this I have done the following steps: 为此,我完成了以下步骤:
httpd.conf
in Apache\\conf
, I uncommented this line: Apache\\conf
编辑了httpd.conf
,我没有对此行添加注释: LoadModule rewrite_module modules/mod_rewrite.so
httpd-vhosts.conf
in Apache\\conf\\extra
, I added: Apache\\conf\\extra
编辑了httpd-vhosts.conf
,我添加了: <VirtualHost *:80>
DocumentRoot "Y:/PHP-Projects"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "Y:/PHP-Projects/Project-Admin-PHP/public"
ServerName localhost.eu
</VirtualHost>
hosts
file in Windows\\System32\\drivers\\etc
, I added: Windows\\System32\\drivers\\etc
编辑了hosts
文件,我添加了: 127.0.0.1 www.localhost.eu localhost.eu
After every step I restarted the Apache2.4 service, but I still cant access my laravel application. 每一步之后,我都重新启动了Apache2.4服务,但仍然无法访问laravel应用程序。 The only thing, what changed is that I now get ' It Works ' also on this domain:
localhost.eu
唯一的变化是,我现在在以下域上也获得了“ It Works ”:
localhost.eu
What have I missed? 我错过了什么?
Currently I am starting my laravel app through php artisan serve
. 目前,我正在通过
php artisan serve
启动laravel应用。 I can then access the app at localhost:8000
. 然后,我可以在
localhost:8000
访问该应用程序。
Also I know I could set up homestead. 我也知道我可以建立家园。 But I discovered it too late.
但是我发现为时已晚。 I have already configured and installed everything myself, and besides this one issue, everything works.
我已经自己配置并安装了所有内容,除了这个问题之外,所有内容都可以正常使用。
I'd like to understand how I would connect my laravel app to the apache server correctly myself. 我想了解如何自己将laravel应用正确连接到apache服务器。
Probably you forgot include file httpd-vhosts.conf
file in httpd.conf
. 可能您忘记了在
httpd.conf
包含文件httpd-vhosts.conf
。 Sometimes this line commented by default and you should uncomment this line. 有时,默认情况下,此行注释,您应该取消注释此行。 After then you should restart apache2 service.
之后,您应该重新启动apache2服务。
Add server alias on your file config 在文件配置中添加服务器别名
<VirtualHost *:80>
DocumentRoot "Y:/PHP-Projects/Project-Admin-PHP/public"
ServerName localhost.eu
ServerAlias www.localcost.eu
</VirtualHost>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.