php 如何为生产或子域系统创建 Laravel 存储符号链接?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45825889/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 03:09:56  来源:igfitidea点击:

How to create laravel storage symbolic link for production or sub domain system?

phplaravelterminalconsolestorage

提问by Mizanur Rahman Khan

When I worked on laravel local development server php artisan storage:linkworks fine for me. But when I transfer my site to production server then I saw my public storage link was a folder. Then I delete that tried to create a link. I got an error because my app was in the root folder and tried to solve this problem.

当我在 laravel 本地开发服务器上php artisan storage:link工作时,我的工作正常。但是当我将我的网站转移到生产服务器时,我看到我的公共存储链接是一个文件夹。然后我删除了试图创建链接的那个。我收到一个错误,因为我的应用程序在根文件夹中并试图解决这个问题。

回答by Mizanur Rahman Khan

I solved this problem by another command for creating a symbolic link by terminal/cmd/shh:

我通过另一个用于通过终端/cmd/shh 创建符号链接的命令解决了这个问题:

ln -s /path/to/laravel/storage/app/public /path/to/public/storage

I solved this also Using laravel web route routes/web.php

我也使用 laravel web route routes/web.php 解决了这个问题

Route::get('/foo', function () {
    Artisan::call('storage:link');
});

回答by Fhulufhelo Mokhomi

Another simple way is to run Executing php artisan storage:linkCommand Programmatically

另一种简单的方法是以php artisan storage:link编程方式运行 Executing Command

On routes/web.php

在路由/web.php

Route::get('/foo', function () {
Artisan::call('storage:link');
});

回答by AL-IMRAN

assuming that your laravel project "public" directory and "public_html" directory are different. Or your subdomain pointer directory may be different , then use your subdomain pointer directory like "public_html" below given process.

假设您的 Laravel 项目“public”目录和“public_html”目录不同。或者您的子域指针目录可能不同,然后在给定的过程中使用您的子域指针目录,如“public_html”。

apply command: $ php artisan storage:link

应用命令: $ php artisan storage:link

this command will create symlink to "public" directory to your laravel project. not inside the "public_html" . so we need to move the "storage" link to "public_html" directory. for this you can move directly. if it doesn't work then move it using command . go inside the "public" directory and run the below command according to your "public_html" directory location.

此命令将创建指向 Laravel 项目的“public”目录的符号链接。不在 "public_html" 里面。所以我们需要将“storage”链接移动到“public_html”目录。为此,您可以直接移动。如果它不起作用,则使用 command 移动它。进入“public”目录并根据您的“public_html”目录位置运行以下命令。

$ mv storage /home/yourHostinInfo/domains/domainName/public_html

the path might be different based on your hosting information.

根据您的托管信息,路径可能会有所不同。