Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update wordpress theme on ec2

I'm hosting a wordpress site on ec2 and I'm trying to update my theme through the admin screen. Its asking me for Hostname and ftp username and password. Is ec2-xxx.compute-1.amazonaws.com:22 my hostname? I tried along with ec2user and root for my ftp username but no luck. What am I doing wrong?

like image 996
Spencer Carnage Avatar asked Dec 31 '11 03:12

Spencer Carnage


People also ask

Can I update an AMI of EC2 instance?

The answer is that you cannot replace the AMI for an existing EC2 instance. However, you can replace the root volume with a new volume which is basically the same thing. That new root volume can come from another EC2 instance.


1 Answers

Skip the FTP info altogether and just change the permission of the directory structure where Wordpress is installed.

VIA SSH

sudo chown -R apache:apache path/to/wordpress
  • sudo makes sure you execute as the root user
  • chown will change the owner of the directory
  • -R will make it recursive, so it changes all files and directories within
  • apache:apache is user:group

And then the path to wordpress. Could be /var/www/html/sitename.com or if you navigate to the folder where Wordpress is installed, you can use a period (.) to tell it to change the current directory.

This will make is so that you can't copy files via sftp though, so it is good to change at least the themes directory back to the ec2-user:ec2-user user and group.

So this changes back to your ssh/sftp user:

sudo chown -R ec2-user:ec2-user path/to/wordpress

You can assign the folders to the ftp user and the apache group and then make them group writable as well. This will allow you to ftp into the directory, and allow everything to be auto updated within Wordpress.

// Set the wp-contents into the apache group and then make files group writable
sudo chgrp -R apache wp-content
sudo chmod -R g+w wp-content
// This makes new files created in wp-content and all of its sub-directories group-writable.
sudo chmod g+s wp-content

Then add this to wp-config.php to force Wordpress to update when only applying this wp-content:

define('FS_METHOD', 'direct');

You can also apply to the whole Wordpress install to auto update Wordpress and not just plugins/themes. If you do this, I would recommend putting your wp-config.php file one directory above your Wordpress install though, so you can lock it down separately.

EDIT: Whenever I am having permission troubles on EC2, I go to site root directory, and paste these lines in. I apply it to the whole Wordpress install these days:

sudo find . -type d -exec chmod 0755 {} \;
sudo find . -type f -exec chmod 0644 {} \;
sudo chown -R ec2-user:apache .
sudo chmod -R g+w .
sudo chmod g+s .

I use something similar on my Mac as well.

like image 170
Jake Avatar answered Oct 27 '22 00:10

Jake