Blog

YiiSES Setup guide

We wanted to build a marketing email application (which we are calling “MailChap”) and since we are a Yii shop I figured before we started, we should try the YiiSES module. Setup was a little tricky so I documented it here in case it’s useful to someone else.

These instructions apply to a Ubuntu machine with a LAMP stack installed. For reference, we’re using a “m1.small” EC2 instance.

Set up YiiSES

  1. Create the Apache document root:
    sudo mkdir /var/www/yiises;cd /var/www/yiises
  2. Clone the yiiboilerplate repository: sudo git clone git://github.com/clevertech/YiiBoilerplate.git /var/www/yiises
  3. Edit the config files to set Yii up with a mysql connection:
    1. sudo vim common/config/params-local.php
      'db.name' => 'mailchap',
      'db.connectionString' => 'mysql:host=[your_db_url];dbname=yiises',
      'db.username' => 'mailchap_webapp',
      'db.password' => '[your_password]',
    2. sudo vim console/config/main.php – uncomment db section.
    3. sudo vim backend/config/main.php – uncomment frontend alias line, and db section.
    4. sudo vim frontend/config/main.php – uncomment db section.
  4. Run the script that “deploys” the environment that we call “local”: sudo ./runpostdeploy local no-migrate
  5. Run the yii migrations to create the users table: sudo ./yiic migrate
  6. Setup 2 DNS rules (e.g. using AWS Route53) for this app:
    1. Make “yiises.yourdomain.com” a DNS Alias for the instance IP. Test it with by browsing to http://yiises.yourdomain.com/
    2. Make “admin.yiises.yourdomain.com” a DNS Alias for the instance IP. Test it with by browsing to http://admin.yiises.yourdomain.com/
  7. Set up Apache:
    1. sudo vim /etc/apache2/sites-available/yiises:
      <VirtualHost *:80>

      ServerName yiises.yourdomain.com
      DocumentRoot /var/www/yiises/frontend/www
      AddDefaultCharset UTF-8

      <Directory /var/www/yiises/frontend/www>
      Options FollowSymLinks
      </Directory>

      ErrorLog /var/log/apache2/yiises-error.log
      CustomLog /var/log/apache2/yiises-access.log combined
      </VirtualHost>
      <VirtualHost *:80>

      ServerName admin.yiises.yourdomain.com
      DocumentRoot /var/www/yiises/backend/www
      AddDefaultCharset UTF-8

      <Directory /var/www/yiises/backend/www>
      Options FollowSymLinks
      </Directory>

      ErrorLog /var/log/apache2/yiises-error.log
      CustomLog /var/log/apache2/yiises-access.log combined
      </VirtualHost>

  8. Enable the rewrite module and the new vhost:
    sudo a2enmod rewrite
    sudo a2ensite yiises
    sudo service apache2 reload
  9. Check it works: http://yiises.yourdomain.com/ you should see:

    This is index view file…

  10. A less boring page should be the admin backend: http://admin.yiises.yourdomain.com/
  11. Install the yiises module:
    1. cd /var/www/yiises/backend/modules
      sudo wget https://github.com/clevertech/YiiSES/archive/master.zip
      sudo unzip master.zip
      sudo rm master.zip
    2. Rename to “ses”: sudo mv YiiSES-master ses
    3. Move a command from the module into the correct place: sudo cp ses/commands/CampaignCommand.php ../../console/commands/
    4. Declare the module in the backend config
      sudo vim backend/config/main-local.php
      Add:
      'modules' => array(
      'ses'=>array('password'=>'clevertech',),
      ),
  12. Set the SES params that the module needs:
    1. In the AWS SES console, Verify a email address.
    2. Setup a IAM user called “MailChap-app” and give it access to SES. Note down the creds for the next step.
    3. Add the creds to the config: sudo vim common/config/params-local.php:
      'ses.aws.key' =>'[your-key]',
      'ses.aws.secret' =>'[your-secret]',
      'ses.aws.verifiedEmail'=>'[your-email]',
      'ses.aws.test.email' =>'[your-email]',
      'ses.from.name' =>'MailChap App',
  13. Run the migrations for yiises:
    1. Move the migration from the module into the correct place: sudo cp ses/migrations/m120809_075915_ses_initial_migration.php ../../console/migrations/
    2. Edit the migration file so the subscribed field is added to the users table (because this is not in the default from the yiiboilerplate).
    3. Run the migration: sudo ./yiic migrate
  14. Hit http://admin.yiises.yourdomain.com/ses – The password is as above “clevertech”
  15. Once you send some emails, you can view the sending stats at http://admin.yiises.yourdomain.com/ses/amazon/manage/

Phew! It’s not too hard, unless you never used yiiboilerplate before (like me).

Tags > ,

1 Comment

Post A Reply to to setup yiises | jpdave Cancel Reply