Remote Access With Sublime Text 3

I want to use Sublime Text 3 directly with my external servers so that I can avoid needing to upload changed files from my desktop using another FTP program. I also want to be able to launch it from the command line.

My first approach was to install ST3 directly on one my servers (T60). While this made it available on the server, it also meant that I needed to be on the server in order to access the app.

I started out at https://opensourceinside.blogspot.ca/2016/02/how-to-install-sublime-text-3-build.html . First, I made sure I was logged in to the server as myself (not as root) and then made sure I was in my home directory. Then I ran the following command to complete the install:

cd && wget https://download.sublimetext.com/sublime-text_build-3103_i386.deb && sudo dpkg -i sublime-text_build-3103_i386.deb

Next, I needed to make it possible to launch the app from the command line. I went here http://askubuntu.com/questions/273034/lauching-sublime-text-from-command-line to find more. I ran this command to to enable this capability:

sudo ln -s /opt/sublime_text/sublime_text /usr/local/bin/subl

Now all I need to do to launch ST3 from the command line is run:

subl

This works beautifully, so long as I’m working directly on the server.

I needed another approach for tunneling in remotely from my desktop machine. The simplest solution was to add the Sublime SFTP package (https://wbond.net/sublime_packages/sftp) to my desktop install.

Once added, I followed the instructions in the package description file to set up the config files. There’s a bit more on using public/private key authorization here at https://wbond.net/sublime_packages/sftp/faq#SSHKeys and at https://wbond.net/sublime_packages/sftp/settings .

Works like a charm now!

Well, almost… When I tried to upload changes to the Cake project via Sublime SFTP, I ran into a permissions error since I was not logged in as root. When installed, Cake sets the default owner & group to root:root.

When I did a chown on the app to set a new owner and group, I caused a bit of havoc. It turns out, after doing the chown, I then needed to run the following commands to update permissions on the tmp and log folders and files:

HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1`
setfacl -R -m u:${HTTPDUSER}:rwx tmp
setfacl -R -d -m u:${HTTPDUSER}:rwx tmp
setfacl -R -m u:${HTTPDUSER}:rwx logs
setfacl -R -d -m u:${HTTPDUSER}:rwx logs

All good again:-)

Installing CakePHP

I started out at http://cakephp.org with reading the cookbook. After skimming the intro, I went to the install instructions as recommended.

First thing, I needed to install was Composer. Although easy, I’ve never used Composer. So, it took me a while to figure out what I was doing (and why). In the end, I opted for the easy route by installing Composer directly into the public html folder:

curl -s https://getcomposer.org/installer | php

Next, I installed CakePHP by using composer to create a new project for the bookmarks tutorial in the html folder, like so:

composer create-project --prefer-dist cakephp/app bookmarker

This is where I ran into my first glitch. The installation wouldn’t complete properly because my Php installation did not include the ‘intl’ or ‘mbstring’ modules. The (simple) solution was to install these modules like so:

 apt-get install php-intl

 apt-get install php-mbstring

… Then reload the server:

service apache2 reload

… And then confirm the installation succeeded:

php -m

Once the needed modules were installed, the previous ‘create-project’ instruction worked perfectly and Composer successfully set up the tutorial project as promised.

FYI, I let Composer set permissions automatically

Well, almost as promised. The default home page showed up in my browser, but the CSS files couldn’t be found.

It turns out that ‘URL rewriting’ wasn’t properly configured on my server. As a result, the server was looking for the ‘/css’ folder in the project’s root directory, instead of the ‘/webroot’ folder.

At this point, I switched to the manual installation instructions on the CakePHP site for more precise guidance. It turns out that I had two issues to resolve.

The first issue related to allowing .htaccess files to overwrite the server’s default configuration settings. The fix for this was easy enough:

# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
<Directory /var/www />
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

The second issue was that mod_rewrite was turned off in apache by default, so the .htaccess files were not being read. The fix was easy too:

a2enmod rewrite

service apache2 restart

With these fixes behind me, everything showed up in my browser just as promised, including a message to tell me the app couldn’t connect to the database (as expected).

I now went back to the quick start guide and followed the instructions to create a database and add some tables for the tutorial by copying and pasting the code provided. Then I modified the installation’s config/app.php file by setting the user, password, and database name defaults so the app could make the connection.

Another browser refresh and, WooHoo, the oven is hot!

A New Project

I’ve decided to start a new project.

A short while ago, I started tinkering with a portfolio site as a means of becoming more familiar with Bootstrap and Less. As these sorts of things do, this led to lots of project ideas.

Cutting to the chase, I want to build an online business application template that runs ‘out-of-the-box’ and is ready for skinning.

My goal is to create a production-ready asset to be used as the basis for several possible revenue streams.

On a more personal level, I want to progress from being a ‘skilled amateur’ to a ‘skilled professional’: a level where I can earn a viable income.

My game-plan is to leverage what I’ve already done with mystudioassistant.com and camperella.com rather than to start from scratch. My biggest challenge is that I’ll need to learn a lot of complicated technologies which will push me well beyond my comfort zone.

I’m not sure about timelines yet. This will need to come as I step further in… something about laying down the path as you walk.

Anyway, here goes.

Sublime Text 3: Setup, Package Control & Settings

I had already installed Sublime Text 3, but had not gone much further than using some of the basic functions. To help me get the most out of the app, I followed this video from Corey Schafer.

Related links:

Here’s some more stuff from TutsPlus and Scotch.io: