【问题标题】:The laravel project is not working in "http://localhost/public/" the page says "This page isn’t working"laravel 项目在“http://localhost/public/”中不起作用,页面显示“此页面不起作用”
【发布时间】:2020-08-08 23:50:18
【问题描述】:

laravel 项目在 OpenServer localhost 的 "http://localhost/public/ 文件夹中不起作用。然而,它与 localhost/8000 上的 php artisan 服务器配合得很好。但我需要在我的本地主机中使用该项目并进行进一步部署。[

外观截图

【问题讨论】:

  • 启用调试,以便您了解遇到错误 500 的原因

标签: laravel localhost public


【解决方案1】:

您需要按照Laravel documentation/ web server configuration 中的说明配置服务器。

如果您想将 apache 配置为您的服务器,您应该在 /etc/apache2/site-available/000-default.conf 中添加以下行

<VirtualHost *:80>

    ServerAdmin webmaster@localhost
    DocumentRoot /home/{user}/{project_root}/public

    ServerName example.local
    ServerAlias www.example.local

    <Directory /home/{user}/{project_root}/public/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/example_error.log
    CustomLog ${APACHE_LOG_DIR}/example_access.log combined

</VirtualHost>

{user} 中插入您的用户名,在{example} 中插入您想要的域。

然后,运行 sudo a2enmod rewritesudo systemctl restart apache2

之后,将/etc/hosts 中的 ip 添加到您想要的域,如下所示:

127.0.0.1 example.local

【讨论】:

    【解决方案2】:

    本地主机允许访问您的

    • htdocs 文件夹 (如果使用 xamp)
    • www 文件夹 (正在使用 wamp)

    您还需要在您的网址中添加项目名称

    例子:

    http://localhost/&lt;project_name&gt;/public

    【讨论】:

    • 感谢您的回答,但我的项目已经在 localhost 中,非常适合其他静态项目。当我打开 laravel 项目时问题来了
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-16
    • 2018-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多