laravel 图片本地 实现前台访问_轻松搞定Laravel安装过程中的遇到常见异常问题?

最近有小伙伴私信我说安装Laravel老是出现奇怪的报错,而且都是英文的,看不懂,为了帮助小伙伴们解决这些报错问题,也是非常耽搁时间,现在我专门发一篇文章总结一下Laravel安装常规错误详解,如果大家有这样的问题,请详细查看问题,帮助大家及时解决,本文安装laravel版本为Larave 7。

前言:Laravel的安装方式有好几种,常用的安装方式:直接下载压缩文件安装、composer安装、github安装等,现在我用composer安装,composer安装需要注意,你的机器上必须安装有composer软件。

1、首先根据官网执行composer安装

// 最好设置一个国内源,用阿里云的composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/// 开始安装项目composer create-project --prefer-dist laravel/laravel blog

2、设置一个唯一秘钥

php artisan key:generate

3、访问:

http://www.xxx.com/index.php

常见问题:

那么我们的问题来了哈!上面的安装很简单,但运行的时候到处都是问题。

1、安装要求:

  • PHP >= 7.2.5
  • BCMath PHP 拓展
  • Ctype PHP 拓展
  • Fileinfo PHP 拓展
  • JSON PHP 拓展
  • Mbstring PHP 拓展
  • OpenSSL PHP 拓展
  • PDO PHP 拓展
  • Tokenizer PHP 拓展
  • XML PHP 拓展

解决:首先你的开发环境就必须要满足以上的条件,差一个都要报错,如果不知道从哪里看扩展是否安装成功,在环境下新建一个phpinfo.php文件,访问:http://localhost/phpinfo.php,看到如下界面就是访问正常,再找到相应的扩展。

9ec7df6210049dfcbbc8bd3abdd15238.png
79e3656a7faff852ce6e912b25a92dbf.png

2、扩展也安装完成,却出现不能访问出现403情况,那是什么问题呢?

解决:php内部有禁用函数,需要把禁用函数释放掉。(我的是本地开发,全部去掉了,线上运行不要全部释放,需要禁用的还是要禁用)

f7ce205119e014329f8a8850a19c48d8.png

liunx环境下:/usr/local/nginx/conf fastpram.conf 注释最后一行

3、访问目录不存在

ccf0994121ddb29f8af178fb5bb413c7.png

解决:

// 执行composer install 或者 composer update

4、以下代码错误。

Fate:In Connection.php line 664:  SQLSTATE[HY000]: General error:PDO::ATTR_STATEMENT_CLASS requires format array(classname,array(ctor_args)); the classname must be a string specif  ying an existing class(SQL: select *from information_schema.tables where table_schema = blog and table_name = xxx_migrations)In PDOConnection.php line 50:  SQLSTATE[HY000]: General error:PDO::ATTR_STATEMENT_CLASS requires format array(classname,array(ctor_args)); the classname must be a string specif  ying an existing classIn PDOConnection.php line 47:  SQLSTATE[HY000]: General error:PDO::ATTR_STATEMENT_CLASS requires format array(classname,array(ctor_args)); the classname must be a string specif  ying an existing classIn PDOStatement.php line 40:  syntax error, unexpected const(T_CONST), expecting variable(T_VARIABLE)

解决:把版本升级到7.2.5以上,就直接解决。

5、以下代码错误。

composer installLoading composer repositories withpackage informationInstalling dependencies(including require-dev)from lock fileYour requirements could not be resolved to an installable setof packages.  Problem 1  - This package requires php >=7.0.0 but your PHPversion(5.6.27) does not satisfy that requirement.  Problem 2    - Installation request for doctrine/annotations v1.6.0-> satisfiable by doctrine/annotations[v1.6.0].    - doctrine/annotations v1.6.0 requires php ^7.1-> your PHPversion(5.6.27) does not satisfy that requirement.  Problem 3    - Installation request for doctrine/cache v1.7.1-> satisfiable by doctrine/cache[v1.7.1].    - doctrine/cache v1.7.1 requires php ~7.1-> your PHPversion(5.6.27) does not satisfy that requirement.

解决:把版本升级到7.1以上,就直接解决。

6、缓存问题。

f84c15c28445349a8e1d67092ae63adf.png

解决:上面的四个文件夹必须存在,如果没有需要手动创建,执行php artisan cache:clear清理缓存

7、以下所示:

0a12eb69062d32292c0d7e5354122f8d.png

解决如下,取消禁用函数。

89dc9d8110753551474d9a4d24f6d649.png

8、页面不能访问(liunx环境下)

c3f2cd8beb4979aad4ab0ead3bdd27f5.png

解决:由于strong没有写入权限导致的 进入项目根目录

chmod 777 strong -R

9、执行php artisan migrate报错

PHP Warning:require(/server/web/test_api/vendor/autoload.php): failed to open stream: No such file or directory in/server/web/test_api/artisan on line 18PHP Fatal error:require(): Failed opening required '/server/web/test_api/vendor/autoload.php'(include_path='.:/usr/local/php/lib/php')in/server/web/test_api/artisan on line 18

解决:先执行composer install 在执行 php artisan migrate

10、内存不足报错

2d8d7af8a44894dbcf091b0d8ff550b0.png

解决:只能加硬件了,没有其他办法

以上总结了部分常规问题,如果你遇到了,那么很快就能解决,后期遇到的问题,我都会记录下来,后面发文更新,记得随时关注哟!公众号(Laravel技术社区).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值