【发布时间】:2021-06-17 08:28:01
【问题描述】:
我在工作服务器上的新 public_html 目录中创建了一个新的 laravel 项目,使用
composer create-project laravel/laravel public_html
我创建了 .vue 组件和控制器以在访问该站点时显示主页,但显示的只是:
这里是处理请求的 web.php 文件:
<?php
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', [HomepageContoller::class, 'index'])
->name('home');
这里是 HomepageController 类:
<?php
namespace App\HTTP\Controllers;
use Inertia\Inertia;
class HomepageContoller extends Controller {
public function index() {
return Inertia::render('Homepage/Index');
}
}
?>
这里是 .vue 组件:
<template>
<div>
<h1>Brite Visual Products<h1>
</div>
</template>
<script>
export default {
metaInfo: { title: 'Brite Visual Products' },
}
</script>
一切都在它所属的地方,自从composer create-project调用以来没有任何东西被移动
更新:
似乎问题只是 web 根目录指向 public_html/ 而不是 public_html/public/
为了解决我需要在我的工作服务器上拥有更高权限的问题,稍后将发布完整的解决方案
【问题讨论】:
-
您的网络服务器配置不正确。
-
是的,很明显问题在于 web 根指向的位置,但是在我的 etc 文件中没有 apache2 目录来编辑通常在站点可用或 conf 目录中找到的根配置
-
如果你进入公共目录并点击 index.php 会发生什么?它会下载那个文件吗?
-
@Kerkouch 您的意思是在显示的 / 页面的索引中吗?如果是这样,不,如果我尝试查看任何 .php 文件,它会返回 500 错误,.json 和其他类似类型没有问题
-
500 错误表示 PHP 已安装并正在运行。您需要在
/etc/apache/sites-available/下配置VirtualHost,并设置DocumentRoot指向public/目录,然后启用站点。
标签: php vuejs2 single-page-application laravel-7 inertiajs