0

I tried to transfer my CodeIgniter website to /var/www/html located within my Amazon EC2 micro instance using FileZilla. However, the transfer was unsuccessful as I received hundreds of transfer errors while attempting to transfer my CodeIgniter website.

My question is, how do I upload my CodeIgniter website to /var/www/html ?


The results of sudo ls -l /var/www are:

drwxrwxrw- 2 root root 4096 Apr 30 22:54 cgi-bin drwxrwxrw- 3 root root 4096 May 22 12:25 error drwxrwxrw- 2 root root 4096 Jan 6 2012 html drwxrwxrw- 3 root root 4096 May 22 12:25 ic

Anthony
  • 201
  • 1
  • 6
  • 12

1 Answers1

3

By default, ec2-user (the default Amazon AMI user) lacks permissions to the /var/www directory. To fix it, use:

usermod -a -G www-data ec2-user

This will add your ec2-user to apache's group so you can make the edits. Root is unable to log in via SSH by default (this can be adjusted, though) so this will work as a workaround. If the apache user is different, change www-data to the appropriate user.

Nathan C
  • 15,059
  • 4
  • 43
  • 62
  • +1 Thanks Nathan. Regarding the Apache user, how do I find that info? The following answer suggested this command: ps aux | grep apache but when I tried it, I see several rows with "apache" (and 1 with ec2-user) with several columns of numbers, question marks, data and /usr/sbin/httpd directory. I did not see apache user. (http://stackoverflow.com/questions/2509334/finding-out-what-user-apache-is-running-as) – Anthony May 23 '13 at 12:12
  • 1
    In `ps aux`, the user is the first column. Look for a line that shows `/usr/sbin/httpd` and the first column will have the name of the user. Typical names are "apache2", "apache", or "www-data". – Nathan C May 23 '13 at 12:14
  • I forgot to first mention that when I tried "sudo usermod -a -G www-data ec2-user", I got this message: "usermod: group 'www-data' does not exist". – Anthony May 23 '13 at 12:15
  • 1
    That's probably because the apache user is different. :-) – Nathan C May 23 '13 at 12:16
  • When I entered "sudo usermod -a -G apache ec2-user", it just returned to the prompt with no errors. However, when I tried to transfer my test file to /var/www/html , I got the same errors: "Error: /var/www/html/test.txt: open for write: permission denied Error: File transfer failed". – Anthony May 23 '13 at 12:23
  • I was transferring test.txt using FileZilla – Anthony May 23 '13 at 12:24
  • Ohh, do I have to restart apache? – Anthony May 23 '13 at 12:25
  • 1
    No, you shouldn't have to. Try this: `chmod -R 776 /var/www`. This should put the permissions as they should be. – Nathan C May 23 '13 at 12:29
  • Running "sudo chmod -R 776 /var/www" produced no errors (is it supposed to be /var/www/http ?). However, I tried to transfer the test.txt file to /var/www/http and got the same errors for /var/www. I tried to access /var/www using putty, but got the following error: "var/www: Permission denied". But the strangest thing I noticed is, my http directory disappeared from within the FileZilla "Remote site" window. – Anthony May 23 '13 at 12:45
  • 1
    Hm, your permissions are screwed up it looks like. Can you update your question with the output of `ls -l /var/www`? – Nathan C May 23 '13 at 12:54
  • "ls -l /var/www" displayed this: drwxrwxrw- 2 root root 4096 Apr 30 22:54 cgi-bin drwxrwxrw- 3 root root 4096 May 22 12:25 error drwxrwxrw- 2 root root 4096 Jan 6 2012 html drwxrwxrw- 3 root root 4096 May 22 12:25 ic – Anthony May 23 '13 at 13:04
  • Oh sorry, I'll update my question, now rereading your answer! – Anthony May 23 '13 at 13:06
  • 1
    I see, they're all owned by root. Type `chown -R apache:apache /var/www` to replace with the proper owner, where `apache` is your httpd's user. That'd by why it wasn't working :-) – Nathan C May 23 '13 at 13:13
  • +1 Yay! Yes it worked! – Anthony May 23 '13 at 13:36
  • Thanks a lot Nathan. You've been very helpful. I'll research every single command you've given me inorder to understand and master this. Thanks a whole lot! – Anthony May 23 '13 at 13:37