共享托管 Laravel 8 托管问题:符号链接不起作用

时间:2020-12-31 06:35:07

标签: laravel web-hosting symlink shared-hosting laravel-8

我需要将我的 Laravel 项目部署到网络。有了这个 introduction 但托管服务提供商不允许我使用符号链接(符号链接),我打电话给客户服务,并告诉我出于安全原因被阻止。 所以,由于我没有使用符号链接,所以在上传图片和部署方面存在很大的问题。

有没有办法部署我的应用程序?

3 个答案:

答案 0 :(得分:1)

我更改了 index.php 中的公共路径,一切正常。

$app->bind('path.public', function() {
    return '/home/u8320874/domain.xyz';
});

答案 1 :(得分:0)

更改 public_path() 中的磁盘配置以通过 public_html 函数读取和写入公共文件夹。

如果您在共享主机上进行部署,您可能有另一个文件夹(如 ../../public_html/)作为您的公共文件夹,该文件夹未包含在您的源中。尝试使用点 'public' => [ 'driver' => 'local', // 'root' => storage_path('app/public'), 'root' => public_path(), 'url' => env('APP_URL'), 'visibility' => 'public', ], 'photos' => [ 'driver' => 'local', 'root' => public_path('photos'), 'url' => env('APP_URL') . '/photos', 'visibility' => 'public', ],

链接到 public_html
DECLARE @hid_Specific HIERARCHYID 
SET @hid_Specific = '/1/1/3/1/';

SELECT hrchy_id,* FROM tblHierarchyData 
WHERE PATINDEX(hrchy_id.ToString() + '%', @hid_Specific.ToString()) = 1

答案 2 :(得分:0)

另一种方法是使用 php 创建类似符号链接的东西,例如您可以创建如下所示的路由:

Route::get(
    '/storage/{file}',
    function ($file) {
        $filepath = "../storage/app/public/".$file;

        header("Cache-Control: public");
        header("Content-Type: ".mime_content_type($filepath));
        header('Content-Length: '.filesize($filepath));

        readfile($filepath);
        die();
    }
);

也许不是最佳实践,但它会解决您的问题。它的作用与符号链接相同。