系统运维专家运维工具程序员

laravel部署与错误解决

2018-06-13  本文已影响10人  恒动力

'#write by Leo#'
一、安装composer

直接通过composer来安装,在命令行执行

cd ~

curl -sS [https://getcomposer.org/installer](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](https://packagist.phpcomposer.com/)

composer create-project laravel/laravel laravel

cd ./laravel

composer install

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

三、配置目录权限


3

四、配置文件

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

六、公网访问站点


6.1 6.2

报错解决:

1、错误一:

Warning: This development build of composer is over 30 days old. It is recommend

ed to update it by running "C:\ProgramData\ComposerSetup\bin\composer.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](https://getcomposer.org/xdebug)

解决方法:
安装完成composer之后,cmd运行composer出现上述错误,需要打开PHP配置文件php.ini,找到zend_extension,讲该配置项注释掉即可解决

3、错误三:

Fatal error: Call to undefined method Fxp\Composer\AssetPlugin\Package\Version\V

ersionParser::parseLinks() in C:\Documents and Settings\Administrator\Applicatio

n Data\Composer\vendor\fxp\composer-asset-plugin\Repository\VcsPackageFilter.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.错误五:

The Process class relies on proc_open, which is not available on your PHP installation.

解决办法:

将php.ini文件的disable_functions选项修改成如下: 5

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
6-1.png

再执行

php artisan migrate
6-2.png
上一篇下一篇

猜你喜欢

热点阅读