1

I'm building an EC2 LAMP server for the first time, and so far so good.

Except I can't seem to get the

require 'vendor/autoload.php'; working right

I get this error message whenever I write that line above

Warning: require(/home/ec2-user/vendor/autoload.php): failed to open stream: Permission denied in /var/www/html/tables.php on line 6 Fatal error: require(): Failed opening required '/home/ec2-user/vendor/autoload.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/tables.php on line 6

I know I have those files. My path to the file is:

/home/ec2-user/vendor/composer/autoload.php

The files that represent my web page are in

/var/www/html/

I can verify both using Filezilla.

Do I need to configure permissions, or move the whole vendor folder to a place where it can be accessed? Did I make an error with the path?

Thanks in advance.


ps aux | grep apache gives me this: I think this means that its running under ec2-user?

How do I switch it, then?

apache    1511  0.0  1.5 407000  9376 ?        S    15:30   0:00 /usr/sbin/httpd
apache    1512  0.0  1.3 407376  8380 ?        S    15:30   0:00 /usr/sbin/httpd
apache    1513  0.0  1.5 406996  9368 ?        S    15:30   0:00 /usr/sbin/httpd
apache    1514  0.0  1.3 406880  8388 ?        S    15:30   0:00 /usr/sbin/httpd
apache    1515  0.0  1.5 406880  9368 ?        S    15:30   0:00 /usr/sbin/httpd
apache    1516  0.0  1.3 406880  8320 ?        S    15:30   0:00 /usr/sbin/httpd
apache    1517  0.0  1.5 406880  9356 ?        S    15:30   0:00 /usr/sbin/httpd
apache    1518  0.0  1.3 406880  8380 ?        S    15:30   0:00 /usr/sbin/httpd
ec2-user  2191  0.0  0.1 103416   828 pts/0    S+   17:45   0:00 grep apache
2
  • Have you tried require 'vendor/composer/autoload.php';?
    – ceejayoz
    May 15, 2013 at 16:59
  • @ceejayoz yeah, but that didn't work
    – user173757
    May 15, 2013 at 17:03

2 Answers 2

0

/home/ec2-user has only rwx------ permissions, thous webserver ( running as apache), doesn't have read rights.
Do a

chmod 755 /home/ec2-user
3
  • will this be okay for security?
    – user173757
    May 15, 2013 at 17:55
  • Yes, that changes only /home/ec2-user and not the files in it. Or you can move the 'vendor' folder to somewhere else (/var/www/html/vendor, /srv/www/vendor), plenty choices, in some case may require additional apache config. May 15, 2013 at 17:58
  • well, that worked, but now I have an unrelated error. Thanks.
    – user173757
    May 15, 2013 at 18:01
0

I guess wrong owner of the files. Apache would be running as apache,apache2,httpd or www-data user (those are the usual ones). If you created those files as somebody else, the webserver probably cannot read them.

8
  • Oh, I see. That makes sense. Do you suggest, then, that I login as apache, or something, then install composer?
    – user173757
    May 15, 2013 at 17:07
  • If it is not a security risk, you could just add the read privilege for the apache user (or for all), but generally i don't recommend that. If you can, issue the chown command (either as a root or the owner of files) and change the ownership of files to the apache user.
    – Fiisch
    May 15, 2013 at 17:09
  • I input chown -R apache home/ec2-user/vendor, but it says no such file or directory, despite me confirming the path with filezilla.
    – user173757
    May 15, 2013 at 17:20
  • you have written the relative path, you probably meant chown -R apache /home/ec2-user/vendor also, have you confirmed the apache really runs under apache user?
    – Fiisch
    May 15, 2013 at 17:32
  • I did the command successfully. No change. No, I have not confirmed that the apache really runs under apache user. How do I check that, or switch it?
    – user173757
    May 15, 2013 at 17:39

You must log in to answer this question.