[已解决]执行php artisan storage:link报错
1. 运行环境
nginx
1). 当前使用的 Laravel 版本?
Laravel Framework 9.37.0
2). 当前使用的 php/php-fpm 版本?
PHP 版本:
with Zend OPcache v8.0.24, Copyright (c), by Zend Technologies
php-fpm 版本:
3). 当前系统
macos
4). 业务环境
5). 相关软件版本
Nginx,mysql
2. 问题描述?
执行
php artisan storage:link
报错:
Call to undefined function Illuminate\Filesystem\symlink()
我的 config/filesystems.php
文件
<?php
return [
'default' => env('FILESYSTEM_DISK', 'local'),
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
'throw' => false,
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public/'),
'url' => env('APP_URL') . '/storage/app/public',
'visibility' => 'public',
'throw' => false,
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
],
],
'links' => [
public_path('storage') => storage_path('app/public'),
],
];
以下处理方式是正确的,我自己的问题是因为我安装了多版本PHP,导致查看php.ini文件的时候,未能正确修改。
度娘结果
去PHP安装目录找到php.ini,ctrl+F搜索“disable_functions”,找到如下属性配置,将“disable_functions”中的scandir、symlink删除,并保存php.ini文件,重启服务,刷新页面。
我看了我的php.ini配置文件,里面的disable_functions值是空的,如下图
php禁用了函数
symlink
,删除就好了,你这个可以看一下cli
和fpm
是否加相同配置文件,可以使用php --ini
查看一下