Centos Laravel 安装

一、安装Composer

下载composer.phar最新版后

mv composer.phar /usr/local/bin/composer

二、安装Laravel

必须翻墙

composer global require laravel/installer

三、配置Laravel权限

vi ~/.bashrc

新增一行

export PATH=$HOME/.config/composer/vendor/bin:$PATH

保存,生效

source ~/.bashrc

测试报错:

/root/.config/composer/vendor/bin/laravel:行14: /root/.config/composer/vendor/laravel/installer/laravel: 权限不够

增加执行权限:

chmod u+x /root/.config/composer/vendor/laravel/installer/laravel

测试:

[root@localhost ~]# laravel -v
Laravel Installer 2.1.0

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  help  Displays help for a command
  list  Lists commands
  new   Create a new Laravel application

开始你的表演。

 

PS:

proc_open, which is not available on your PHP i nstallation.

需要在PHP.ini中删除proc_open:

disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru

还要放开putenv()函数禁用

我服了 new laravel后没有vender,报错:

Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for league/flysystem 1.0.53 -> satisfiable by league/flysystem[1.0.53].
    - league/flysystem 1.0.53 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
  Problem 2
    - league/flysystem 1.0.53 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
    - laravel/framework v5.8.29 requires league/flysystem ^1.0.8 -> satisfiable by league/flysystem[1.0.53].
    - Installation request for laravel/framework v5.8.29 -> satisfiable by laravel/framework[v5.8.29].

  To enable extensions, verify that they are enabled in your .ini files:
    - /www/server/php/71/etc/php.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Application ready! Build something amazing.

这个问题终于搞出来了,需要安装:

fileinfo 通用扩展 用于获取文件MIME,编码等信息!

如果:laravel接口报错cURL error 6: Could not resolve host ......

方法一:接口有时可以,有时报这个错。

搞了半天,网上说本机DNS解析问题,hosts,resolv.conf 都改过没卵用。

最后找到方法,死马当活马医,居然成了。如果是centos7的话用systemctl restart php-fpm重启下即可解决;如果是centos6的话就用service php-fpm restart。具体为啥不知道,先用再说

方法二:今天在一新买的VPS上练手easypanel,才开始安装就提示 curl: (6) Couldn’t resolve host ... ,网上有说是因为开启了VPS IPV6的缘故,但凭直觉还是DNS解析的嫌疑更大,直接PING 国内域名,果然不通,更有把握了。

centos 6修改DNS非常简单,直接

vi /etc/resolv.conf

在里面按下面格式添加后保存生效即可

nameserver 119.29.29.29

nameserver 8.8.8.8

 

点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注

1 + 12 =