laravel的部署与报错解决

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了laravel的部署与报错解决相关的知识,希望对你有一定的参考价值。

# Write by Leo #
一、安装composer
直接通过composer来安装,在命令行执行

cd ~
curl -sS https://getcomposer.org/installer | php

上面命令会安装composer
composer全局使用:
mv composer.phar /usr/local/bin/composer

二、创建laravel项目

进入/server/web目录下

composer config -g repo.packagist composer https://packagist.phpcomposer.com
composer create-project laravel/laravel laravel

cd ./laravel

composer install

(如果这一步没问题就可以继续往下做,有问题请参考报错)

三、配置目录权限
技术分享图片

四、配置文件

cd /server/conf/nginx/conf/vhost
vim laravel.conf
##Design by Leo
server {
    listen 80 ;
    listen [::]:80 default_server ipv6only=on;

    # 设定网站根目录
    root  /server/web/laravel/public;
    ####### 网站默认首页
    index index.php index.html index.htm;

    # 服务器名称,server_domain_or_IP 请替换为自己设置的名称或者 IP 地址
    server_name lv5.leoops.vip;

    # 修改为 Laravel 转发规则,否则PHP无法获取$_GET信息,提示404错误
    location / {
        try_files $uri $uri/ /index.php?$query_string;        
    }

    # PHP 支持
    location ~ .php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        fastcgi_pass unix:/tmp/php-cgi.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    #fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
    }
    access_log /server/logs/nginx/lv5/access.log;      #访问日志
    error_log /server/logs/nginx/lv5/error.log;           #错误日志(重点日志)
}

五、重启nginx服务


/usr/local/nginx/sbin/nginx -s reload

六、公网访问站点
技术分享图片

技术分享图片


报错解决:

1、错误一

Warning: This development build of composer is over 30 days old. It is recommend
ed to update it by running "C:ProgramDataComposerSetupincomposer.phar self-
update" to get the latest version.

解决方法:

composer selfupdate

2、错误二:

You are running composer with xdebug enabled. This has a major impact on runtime
performance. See https://getcomposer.org/xdebug
安装完成composer之后,cmd运行composer出现上述错误,需要打开PHP配置文件php.ini,找到zend_extension,讲该配置项注释掉即可解决

3、错误三:

Fatal error: Call to undefined method FxpComposerAssetPluginPackageVersionV
ersionParser::parseLinks() in C:Documents and SettingsAdministratorApplicatio
n DataComposervendorfxpcomposer-asset-pluginRepositoryVcsPackageFilter.php
on line 272

解决方法:

删除composer资源插件,重新安装
如果还有错误,尝试全局更新 

composer global update

4、错误四:如果是在使用yii框架的时候,会出现一下问题
The "yiisoft/yii2-composer" plugin requires composer-plugin-api 1.0.0, this *WIL L* break in the future and it should be fixed ASAP (require ^1.0 for example). The "fxp/composer-asset-plugin" plugin requires composer-plugin-api 1.0.0, this*WILL* break in the future and it should be fixed ASAP (require ^1.0 for example ).

解决办法:

Yii2 需要 composer-plugin-api 1.0 以上的版本,运行以下命令:

composer global require "fxp/composer-asset-plugin:~1.1.1"

5.将php.ini文件的disable_functions选项修改成如下
技术分享图片

6.错误六: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 18
PHP 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
![](http://i2.51cto.com/images/blog/201806/13/2d1034b5d806cf41cae428b972e8590a.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)

再执行:
php artisan migrate

技术分享图片

以上是关于laravel的部署与报错解决的主要内容,如果未能解决你的问题,请参考以下文章

mysql5.7.17安装方式-与报错解决方式

redis部分配置与报错解决

yarn安装与报错解决方案

yarn安装与报错解决方案

yarn安装与报错解决方案

图文详解python之matplotlib安装与报错解决办法