Notes from a Newbie 16: Deploy

Notes from a Newbie document the creation and deployment of yardbirdfanclub.org with Perl Catalyst on shared hosting. They are intended for a Perl Catalyst Newbie who would like to study the creation and deployment of a simple Perl Catalyst application.

Now that we've developed a simple, functional application I will give you some information and advice about deploying it to a shared host.

Choosing a Shared Host

When I began to look for a place to deploy yardbirdfanclub.org I started here:

I decided to go with pair.com and signed-up on their website for their "pairLite" plan. After initial attempts to deploy failed, I contacted customer support and was told a Perl Catalyst application would not run on the plan I chose. I was advised to go with their pairVPS (Virtual Private Servers) plan, but I couldn't afford it. Charges were refunded, the "pairLite" account closed and an account with their "Basic" plan opened:

At this point the pairLite account is being closed, and the charges refunded. You should see the credit post back to your credit card in the next day, or so.

In addition, I also went ahead and setup the Basic account that utilizes our standard pair.com servers that include some more features that aren't available with pairLite.

As I mentioned, this is something that's typically not done on this lower tiered style of account, but considering your needs it seems like it would be worth a shot.

If you still aren't able to get things running on the new account just let me know, and I can get this one closed for you as well. If it does work out for you the normal charges of $10/month would take effect starting February 1st.

I continued to try and deploy my application with a little help from customer support and people at irc.perl.org, but ultimately failed and the account was closed.

Although attempts to deploy with pair.com failed, not all was lost and I have the utmost respect for them. Telephone support was prompt and courteous and several people sincerely tried to help, though they always prefaced our conversation with something like:

We only support PHP with fastcgi for this type of account. You may be able to get your Perl Catalyst application to run, but we don't support it.

I only called a few times, but the last person I talked to stated definitively that a Catalyst application would not run on the account. By then I was very frustrated, so I gave up.

In fairness to pair.com, I had practically no system administration experience going into this, and no experience deploying any kind of website on any kind of a server. With the experience I have since gained, I might be able to successfully deploy if I tried to do so again.

asmallorange.com

I went back to wiki.catalystframework.org/wiki/hosting/ and continued my research, this time inquiring at irc.perl.org and surfing the Internet as well. I emailed and called several providers that interested me, and asmallorange.com was the only one that promptly responded. Among other things I asked:

I am looking for shared web hosting to deploy my perl catalyst application, this is what I would like to do:

Install the current maintenance version 5.16.2 of perl in my home directory, along with perl modules needed by my catalyst app. I want to deploy it with my local perl rather than the system perl, using apache's mod_fastcgi. Will you support that?

Among other things, the reply was:

All of your technical specs sound totally doable.

I liked what I saw at their website, found many happy customers on the Internet, and was satisfied with their responses to my inquires, so I signed-up for their medium shared hosting and am glad I did.

It was fortunate that I asked the above question, and I would advise you to do the same before signing up with anybody for shared hosting, including asmallorange.com. The problem with shared hosting is that you don't have root access to the server, leaving you at the mercy of your provider to configure anything that requires root access. My deployment required two such administrative actions:

  • Enable "gcc" and "as" compiler access.
  • Resolve localhost in the /etc/hosts file, i.e. fix the issue that prevents '127.0.0.1' resolving.

I initiated support tickets and found that doing so was a waste of time. Each time I was passed onto somebody else, a half-dozen or more times, each time getting a more stern response stating that my request was not possible for shared hosting and that I needed to upgrade to a Cloud VPS account. After a day or two I gave up on normal support channels and emailed the systems administrator who answered my question above, and he happily solved the issues in a matter of seconds. If it wasn't for him I would have again failed to deploy with shared hosting.

From here on out it's been smooth sailing with asmallorange.com, unfortunately winds change. The issue preventing '127.0.0.1' from resolving should no-longer be a problem, but compiler access will be. Compiler permissions are automatically reset by consistency checks, so I only have compiler access for 24-hours or so before having to again request access. Ouch. Do all module installs/updates require "gcc" and "as" compiler access? I dunno, I have yet to try.

Deploying yardbirdfanclub.org to a Shared Host

Resources

People on the #catalyst channel at irc.perl.org were perhaps my most valuable resource, pointing me in the right direction and helping me solve problems. They were extremely patient and generous with their time and skills.

Though I lacked basic system administration and other skills necessary to implement them, I found the Perl documentation to be 100% complete with all the Catalyst and server specific details I needed to deploy my Catalyst application:

  • Catalyst::Manual::Deployment
  • Catalyst::Manual::Deployment::SharedHosting
  • Catalyst::Manual::Deployment::FastCGI

Since I deployed to an Apache server I referred to the following documentation, but documentation for other servers exist as well:

  • Catalyst::Manual::Deployment::Apache::FastCGI

I also needed the local::lib documentation to bootstrap local::lib:

  • local::lib

I used the Internet to discover and learn how to use shell commands I had not used before:

  • ssh
  • wget
  • scp
  • tar
  • ln

Though it takes time and I sometimes rely on them too much, I use the vimwiki plugin with vim to take notes - they are a necessary resource for almost everything I do with a computer.

Hopefully your shared hosting provider provides good notes and support that you will need to deploy on their servers.

asmallorange.com

I signed-up for medium shared hosting at asmallorange.com.

They provide two resources that I frequently used:

Support and Account Center

  • View and Update Accounts
  • Manage Hosting Packages
  • Manage Domain Names
  • Order New Products
  • Submit, View, and Respond to Support Tickets
  • Access Knowledgebase and Tutorials

cPanel

  • Manage SSH Access
  • Manage FTP Accounts
  • Manage Domains
  • Manage Databases
  • Manage Email Accounts
  • Access Server Error Logs

I think some cPanel features may be broken on shared host accounts, for example the feature to install Perl modules - I got errors when attempting to do so.

Getting Started

After signing-up for medium shared hosting I received emails that got me started and were easy to follow. They included information about:

  • Server Names and IP addresses
  • Nameservers and Domains
  • Email Settings
  • Passwords

I needed to submit a support ticket to gain ssh access, and within 15 minutes or so the ticket was acted upon and I closed it.

I tried unsuccessfully to get ssh to connect to the server using a private key generated by cPanel, but I was able to do so with a public/private RSA key pair generated from my client.

Make Distribution, Copy to Server and Unpack Tarball

Make Distribution

[j0e@axe Yardbird]$ perl Makefile.PL
[j0e@axe Yardbird]$ make manifest
[j0e@axe Yardbird]$ make dist

Copy to Server

[j0e@axe ~]$ scp -p Yardbird.tar.gz accountname@servername.asmallorange.com:Yardbird.tar.gz

Unpack Tarball

I created the ~/lib directory on the server and moved the tarball there. I renamed the new unpacked directory Yardbird so that I would have ~/lib/Yardbird:

accountname@yardbirdfanclub.org [~/lib]# tar -xzf Yardbird.tar.gz

I renamed yardbird_fastcgi.pl to yardbird_fastcgi.fcgi.

Setup .htaccess and Symlink

Create the Symlink

accountname@yardbirdfanclub.org [~/public_html]# ln -s ~/lib/Yardbird/script script

Edit .htaccess

~/public_html/.htaccess:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/?script/yardbird_fastcgi.fcgi
RewriteRule ^(.*)$ script/yardbird_fastcgi.fcgi/$1 [PT,L]

See:

  • Catalyst::Manual::Deployment::SharedHosting

Setup the Database

I used my yardbird.sql and set_hashed_passwords.pl script we created and used in Notes from a Newbie 10: Authentication/Authorization to create a new database on my production machine, initialized with only a webmaster and no blog entries or comments.

Use yardbird.sql to create a new database:

[j0e@axe Yardbird]$  mysql -uusername -ppassword
mysql> create database yardbird;
mysql> quit;
[j0e@axe Yardbird]$  mysql -uusername -ppassword yardbird < yardbird.sql

Load hashed passwords into the database:

[j0e@axe Yardbird]$ perl -Ilib set_hashed_passwords.pl

Then I created a MySQL dump file of this new database and copied the dump file to the database server. Next I created a new database and users in cPanel, and initialized the new database on the server with the dump file. Finally, I configured my Yardbird application on the server by updating the connect_info in ~/lib/Yardbird/lib/Yardbird/Model/DB.pm.

Create a MySQL "Dump File" of the Database

[j0e@axe Yardbird]$ mysqldump -Qq -uusername -ppassword yardbird > yardbird_dump.sql

Copy Dump File to Database Server

[j0e@axe ~]$ scp -p yardbird_dump.sql accountname@databaseservername.asmallorange.com:yardbird_dump.sql

Create New Database and Users in cPanel

In cPanel go to MySQL Databases.

Create New Database: yardbird

Add New User: admin_user

Add User To Database: Add admin_user to the new yardbird database with all privileges. This user will initialize the database with the dump file, manage tables and do other database maintenance not done by the catalyst application, but I need another user with basic access for my Yardbird application:

Add New User: yardbird_user

Add User To Database: Add yardbird_user to the new yardbird database with limited privileges.

Initialize Database on Database Server

Use yardbird_dump.sql to create and initialize tables:

accountname@databaseservername [~]# mysql -uadmin_user -p yardbird < yardbird_dump.sql

Configure the Application

I configured my Yardbird application to connect to the yardbird database with yardbird_user, by updating the connect_info in:

~/lib/Yardbird/lib/Yardbird/Model/DB.pm

Install Local Perl

This is where the deployment began to get difficult.

The system Perl on the server is 5.10.1 and I had no luck installing modules with cPanel or local::lib using the system Perl. Besides, I like the idea of using a newer version of Perl so I installed it locally.

There are two things I needed asmallorange.com to do for me to install a local perl:

  • Enable "gcc" and "as" compiler access.
  • Resolve localhost in the /etc/hosts file, i.e. fix the issue that prevents '127.0.0.1' resolving.

Then installing a local perl should be this easy:

accountname@yardbirdfanclub.org [~]# mkdir perl5
accountname@yardbirdfanclub.org [~]# wget http://www.cpan.org/src/5.0/perl-5.16.2.tar.gz
accountname@yardbirdfanclub.org [~]# tar -xzf perl-5.16.2.tar.gz
accountname@yardbirdfanclub.org [~]# cd perl-5.16.2
accountname@yardbirdfanclub.org [~/perl-5.16.2]# ./Configure -des -Dprefix=$HOME/perl5
accountname@yardbirdfanclub.org [~/perl-5.16.2]# make
accountname@yardbirdfanclub.org [~/perl-5.16.2]# make test
accountname@yardbirdfanclub.org [~/perl-5.16.2]# make install

Without localhost resolved "make install" produces this error:

lib/Net/hostent.t Failed test 'gethostbyaddr('127.0.0.1')'

The compiler access problem was easier to detect, I got the following error when compiling modules:

cc: error trying to exec 'as': execvp: Permission denied

Install local::lib?

This is where things got strange.

After installing a bootstrapped local::lib and cpanm, modules installed where I intended but @INC did not contain the correct paths to them. Maybe I did something wrong, I dunno. My solution was to explicitly set @INC in:

~/lib/Yardbird/script/yardbird_fastcgi.fcgi

Reflecting back on this, I'm wondering if it was necessary to use local::lib since I successfully installed a local perl. I would research this before I would do it again.

See:

  • Catalyst::Manual::Deployment::SharedHosting
  • local::lib

Install App::cpanminus

accountname@yardbirdfanclub.org [~]# cpan App::cpanminus

Install Modules

I suppose this is where my lack of skills as a Perl Newbie continues to show.

First I used cpanm to install these modules:

  • Moose
  • Catalyst::Devel
  • DBIx::Class
  • HTML::FormHandler

After those installed I started going to yardbirdfanclub.org with my browser then looked at the server error log in cPanel to determine what needed to be installed next. If nothing shows up in the server error log, try running yardbird_fastcgi.pl from ssh.

These are the modules/distributions I continued to install with cpanm:

  • Catalyst::Plugin::Session::State::Cookie
  • Catalyst::Plugin::Session::Store::File
  • Catalyst::Authentication::Realm::SimpleDB
  • Catalyst::Plugin::Authorization::Roles
  • HTML::FormHandler::Model::DBIC
  • MooseX::MarkAsMethods
  • MooseX::NonMoose
  • DBIx::Class::TimeStamp
  • DBIx::Class::PassphraseColumn
  • FCGI
  • DBD::mysql

\o/

Finally, after installing DBD::mysql my Yardbird application appeared in my browser and I jumped for joy! I logged in as webmaster and everything worked, just like the Catalyst::Manual::Deployment::SharedHosting documentation said it would!

username: webmaster
password: password

Other Deployment Options

VPS

I have little knowledge about deploying to Virtual Private Servers, but it would be great to have root access and all resources on the VPS dedicated and available to me and my sites. The disadvantage is cost, but it seems cost has dropped at asmallorange.com from what I recall a few months ago. At the time I was told:

Most sites that run OK on a shared web hosting account will run OK on a 1024meg Cloud VPS.

Today they are advertising:

Plan reflects FREE 2x RAM upgrade. New services only. 

Cores: 1
RAM: 1536MB
Storage: 15GB
Bandwidth: 600GB
Price: $25 a month, 2 months free with annual plan

dotCloud

I know next to nothing about dotCloud, but after my first failed attempt to deploy yardbirdfanclub.org on shared hosting I had a conversation with folks at irc.perl.org that brought it to my attention. I was told:

  • It is where you push your code and let them deal with the web hosting details.
  • dotcloud is nice up to sandbox, go live and it's spendy.

See:

What's Next?

Putting myself out there to the Perl community is scary.

Though I'm a musician and I too studied but did not complete a music degree, I'm no Larry Wall - though I would like to play some music with him!

Though I too am thankful for the awesomeness of the Perl community - I am no Peter Rabbitson, but I do use DBIx::Class.

Though I go by j0e since receiving his "heavy tools" via irc.perl.org a year or so ago - I am no t0m. I am no mst, hobbs, joel, jnap, kd, castaway, dpetrov, gshank, or any of the others who have generously helped me at irc.perl.org.

I don't have anywhere near the brains or technical skill of any of those mentioned, or most others from what I see in the blogs and other things I read. How likely will it be to find people willing to pay me to use and develop my skills? How will I ever give back to the Perl community?

Though I contributed these beginner-level Notes from a Newbie tutorials, I have contributed nothing compared to what others do. How can I belong to this community without the skills, without doing the work and making the contributions I see others making around me? Yet I do feel welcome to try, and I do desire to be a contributing member of this community.

Apply for Jobs

My resume is weak and I'm a beginner, but I'm going to put myself out there for hire. This morning I read the job posting in Gabor's Perlweekly and would be thrilled to have the opportunity to contribute to an effort like this, but I am not an "exceptional developer". I'll put myself out there and see what happens, and in the meantime do the best I can do.

Notes from a Newbie: YAPC::NA 2013, Austin, Texas

When I registered for YAPC it was a big decision for me, for several reasons I won't bother to mention. I saw the call for speakers and punched in a proposal, with no illusions that I have knowledge any skilled Perl user would care about. But I figured few would be interested in giving a talk to beginners, so I went for it and my proposal was accepted. I know it is only a 20-minute talk, but I'm very pleased to be a speaker at this conference.

I hope some Newbies show up, they are who I want to address. My idea is to provide all attendees a very short survey consisting of only 4 or 5 questions, something like this:

(Yes/No) Have you created and used Perl scripts?
(Yes/No) Have you used perldoc::server?
(Yes/No) Have you used irc.perl.org?
(Yes/No) Have you published any entries to blogs.perl.org?
(Yes/No) If you have not connected with anybody in the Perl community, would you like to do so?

If you are a veteran Perl user and would be willing to connect with a Newbie, please provide the following:

Name:
Location:
Email:

If you are a Newbie who would like to connect with a veteran Perl user, please provide the following:

Name:
Location:
Email:

The purpose of this survey will be to determine if any Newbies are present, and which of the survey items I may be able to help them with.

I am thinking I'll ask one of the veterans to be our "connection" to hook Newbies up. This person will have the responsibility of handing out surveys and pencils, collecting them, quickly tallying the results, reporting back to the group and hooking Newbies up. How about it Peter Rabbitson? You do a lot already, will you help us out again?

Improve yardbirdfanclub.org?

I have no specific plans for yardbirdfanclub.org. It's purpose was for me to learn some basic skills and to share those skills with others, and I haven't given it much thought beyond that.

Perhaps I'll add a Flickr feed to the site, using AJAX and jQuery to display a photo album of Bird. I would like some video of Bird, his disc catching abilities and athleticism are incredible. But really, I may not do much of anything at all with the site. I think it mostly depends on how long it takes me to find a job using Perl. Once I am hired I will put everything I can into being successful at that job, and I imagine I won't have much time for yardbirdfanclub.org. In the meantime I have yardbirdfanclub.org to develop my skills when I can find time. Maybe I'll continue to share what I learn, and maybe that will be my contribution to the community. It all depends on how the future unfolds, I'll need to find my way as I go.

Where to Find the Yardbird Source Code

The Yardbird application, as I've developed it thus far in these tutorials, is available at GitHub:

3 Comments

Hi j0e,

While I am excited that you asked me to help reach out to the future members of our community, I feel the strong need to decline.

I am the kind of person who is driven by the negative side of his passions. I work on Perl projects not because I particularly love Perl, but because I hate it the least. Not because I find the CPAN offerings awesome, but because I can't stand the subpar quality of these offerings. And I am not shy to talk about all of this when asked.

Ergo, I am probably the last person you want greeting new blood ;) We can chat more at the pre-conf dinner.

Cheers and keep up the great work - you are doing awesome so far!

Also another note on your comment but I am no Peter Rabitson higher up. Newsflash - Peter Rabbitson wasn't always Peter Rabbitson either. Almost exactly 6 years ago I came to Catalyst (DBIC came later) just like you did. I did not know Perl, did not know anybody, and definitely did not know I actually can write couple lines worth something.

Persistence and time is the only thing differentiating us, and you seem to have plenty of the first ingredient. I suspect you will be just fine ;)

Leave a comment

About j0e

user-pic I am a Perl Catalyst Newbie who is documenting the creation and deployment of yardbirdfanclub.org.