doupa2871 2016-02-05 03:18 采纳率: 100%
浏览 100

Amazon Server ec2上的Composer - 自动加载不起作用

I configured an Amazon Cloud server, installed php, apache, etc. Then installed composer and ran $php composer.phar and its working.

But when I tried to include the vendor/autoload.php file (which I can clearly see on the server), I get this warning and fatal error because it can't seem to find the file:

Warning: require(/home/ec2-user/vendor/autoload.php): failed to open stream: Permission denied in /var/www/html/index.php on line 12

Fatal error: require(): Failed opening required '/home/ec2-user/vendor/autoload.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/index.php on line 12

Line 12 is simply:

require "/home/ec2-user/vendor/autoload.php";

Does anybody know what is causing this error or anything that would help eliminate the error? Thanks.

  • 写回答

1条回答 默认 最新

  • dsdxlibt98300 2017-01-14 22:06
    关注

    I had the same problem, here are the steps i followed to solve it:

    1. Install composer as described in: https://docs.aws.amazon.com/aws-sdk-php/v3/guide/getting-started/installation.html
    2. Copy all composer components under www root
    3. Change ownership of composer components to apache
    4. If you are using an ini file for the AWS credentials, place it under /.aws (under the root folder)

    Here are the steps:

    cd ~
    mkdir composer
    cd composer
    curl -sS https://getcomposer.org/installer | php
    php composer.phar require aws/aws-sdk-php
    sudo cp -r ~/composer /var/www/html
    sudo chown -R apache:apache /var/www/html/composer
    sudo mkdir /.aws
    

    Don't forget to copy the credentials file to ./aws. You can also restrict read access to the credentials file to apace only:

    sudo chown apahce:apache ./aws/credentials
    sudo chmod 440 ./aws/credentials
    

    Finally, update the required statement in the php file. In the example above i placed composer in its own folder so the reference would be:

    require 'composer/vendor/autoload.php';
    
    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法