Centos下安装compoer, 解决vendor目录问题

laravel部署时使用git拉代码的话,vendor目录部署是没有提交到git上的,如果没有该目录,服务会报错如下

Warning: require(/opt/soft/pro/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /opt/soft/pro/bootstrap/autoload.php on line 17

Fatal error: require(): Failed opening required '/opt/soft/pro/bootstrap/../vendor/autoload.php' (include_path='.:/usr/share/pear:/usr/share/php') in /opt/soft/pro/bootstrap/autoload.php on line 17
解决办法:composer install --no-scripts

参考链接:https://stackoverflow.com/questions/26887111/laravel-php-fatal-error-require-failed-opening-required-bootstrap-autolo

安装composer步骤如下

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

php -r "if (hash_file('sha384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

php composer-setup.php

php -r "unlink('composer-setup.php');"

mv composer.phar /usr/bin/composer
原文地址:https://www.cnblogs.com/Kevin-1967/p/9959285.html