Thanks so much for taking the time to help me with this issue:
I had a Wordpress blog hosted on a shared Bluehost hosting account. I'm currently in the process of migrating it manually over to an AWS Elastic Beanstalk created EC2 instance using an Amazon Linux AMI. Using SSH, I:
- exported and imported the database into the new server's MySQL database
- copied over all the Wordpress files with ownership as ec2-user:ec2-user
- set all of the directory permissions to 755, and all of the file permissions to 644.
At this point, the index of the blog loaded perfectly normal. However, when I attempted to click on one of the posts that previously used pretty permalinks, Wordpress couldn't load it because I didn't have the .htaccess file using mod_rewrite (please note that transferring the original .htaccess is not an option). So I logged into the admin section and under Settings > Permalinks, I attempted to recreate the .htaccess file. However, I received this message from Wordpress: "If your .htaccess file were writable, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your .htaccess file." I created a blank .htaccess file at this point with proper permissions and retried, but with the same result.
I also noticed at this point that within the admin section, I was unable to upload pictures to the media section. From there, I figured it was an ownership issue.
Based on the above two issues, I used
whoami via php's
shell_exec() to determine which user Wordpress was using, and learned that the user
webapp was being used. Elastic Beanstalk creates the
webapp user to use for uploading and deploying new code versions via the console (however, I'm manually uploading code via SFTP using the ec2-user account). From here I:
- changed all of the Wordpress file/directory ownership to webapp:ec2-user
- set all of the directory permissions to 775, and all of the file permissions to 664 (so that I as ec2-user may write to them as well)
At this point, media uploads worked perfectly. However, Wordpress could still not create/write to the .htaccess file. Frustrated at this point, I set permissions to 777 just to see if that would work, but that didn't work either.
Any help is greatly appreciated. And thanks again for your time!