Since c9.io has been forwarding new users to the new AWS Cloud9 service, I’ve been struggling for some time when I can finally move my development environment. Since I’ve been using c9.io for development for years and then publishing my projects via DigitalOcean, I thought, why not just use AWS Cloud9 with DigitalOcean? In this tutorial, I’ll show you how to do this without any major problems – it took me some time to make it work.
Prepare AWS account
If you have not already done so, please create an account with AWS and then log in (console.aws.amazon.com). Since the AWS Cloud9 service requires an IAM user instead of the main user, it is important to use the service with an IAM user. After successful login you open the IAM service and create a new user (in my case “main”). I have simply assigned the new user admin permissions, but you can customize it as you like. After the user has been created, you can log in with the new user using an own “Portal” link. Now you should be able to read the following at the top right: main @ 7268-xxxx-5200. Note that AWS Cloud9 is not yet available in all regions, therefore I navigate to EU Ireland.
Prepare DigitalOcean account
To establish a secure connection between AWS Cloud9 and DigitalOcean, DigitalOcean must know a public SSH key of your AWS account. To get it, please navigate to the AWS Cloud9 service in AWS and create a new SSH workspace. There you should be able to see your SSH key, which you copy and then add to your DigitalOcean account. Copy your SSH public key and paste it to your DigitalOcean account Dashboard > Security > SSH Keys > Add.
It is also necessary to create a local SSH key on your PC so that you can first connect to your droplet via CMD. See Add SSH Keys
Prepare Droplet for AWS Cloud9
Our two services AWS Cloud9 and DigitalOcean now know each other. We create a new Droplet in DigitalOcean. In this example I create a WordPress instance on Ubuntu. Before I create the droplet, I select both SSH keys, which I have added previously. The newly created Droplet is not yet fully executable with the Cloud IDE, because the following components are required:
- Another admin user than root which has access to SSH
- Node Package Manager (npm)
To set up the above component, please first connect to SSH with your droplet on your local computer and execute the following commands, see also One-Click WordPress.
Create admin user
In this tutorial I am using matzeeable as new username.
|# Create droplet admin user|
|usermod -aG sudo matzeeable|
|# Add your key here|
|# Show the authorized keys so you can copy|
|sudo cat /root/.ssh/authorized_keys|
The nano command edits the sshd_config file so you can add this line (AllowUsers matzeeable root) to allow SSH access for the newly created user (CTRL + X, type “Y” to save).
In order to test the new user right away, we now log in with it and set the correct permissions for the .ssh and /var/www/html folder. In addition, you need to add the public SSH keys to the newly created file ~/.ssh/authorized_keys so that the clients (in this case AWS Cloud9 and your local computer) can access this server with this new user again. Note: If you do not know the keys at the moment you can use the keys from your root access and copy them:
|su - matzeeable|
|# Create SSH folder for the new user|
|mkdir -p .ssh|
|chmod 700 .ssh|
|chmod 644 .ssh/authorized_keys|
|# AWS Cloud9 only works when the initial path has the same owner as the connecting user|
|sudo chown -R matzeeable:matzeeable /var/www/html|
Instsall NodeJS and NPM
In this tutorial I am using nvm to install NodeJS and the Node Package Manager:
|curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash|
|nvm install node|
After successful installation copy the path of your node installation to clipboard because this is needed later when creating the AWS Cloud9 SSH workspace. Last but not least we restart the SSH service:
|# Get path of node version|
|# Exit -su and reload SSH service|
|service sshd reload|
Create AWS Cloud9 SSH workspace
Everything is ready and we can finally create the SSH Workspace. This is now very easy:
- User: The newly created user
- Host: The DigitalOcean Droplet IP
- Port: 22
- Environment path: The initial path (the tree on the left side of your IDE)
- Node.js binary path: The above copied
Create it and the IDE starts to load. It then starts an installation process. This may stop at some points, but I noticed that reloading the IDE and reinstalling it more often leads to success. Happy Coding!
If you encounter problems while installing plugins or updates with the following error message Could not create directory or FTP credentials login you can use the following. Add
define('FS_METHOD', 'direct'); to your wp-config.php file – this skips the FTP credentials input. Afterwards change the apache2 user to your username which you used in the above
|# Edit environment variables|
|sudo nano /etc/apache2/envvars|
|# Restart apache|
|sudo service apache2 restart|
If you want to create a error log file diretly in your workspace tree you can modify the
error_log value in your php.ini file to
/var/www/html/php_errors.log and also restart apache2.
The terminal does not scroll as expected? This can be an issue with tmux > 2.2. Please refer to this forum post or run the following commands:
|tar xzf tmux-2.2.tar.gz|
|sudo apt-get install libevent-dev ncurses-dev -y|
|ln -sf /home/matzeeable/.c9/local/bin/tmux /home/matzeeable/.c9/bin/tmux|
Author: Matthias Günter
Creative designer and programer from Low-Bavaria. I love to simplify things, especially when it comes to WordPress. If you like, you can take a look at my plugins.