YiiSES Setup guide
By Tom In AWSWe 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
- Create the Apache document root:
sudo mkdir /var/www/yiises;cd /var/www/yiises - Clone the yiiboilerplate repository: sudo git clone git://github.com/clevertech/YiiBoilerplate.git /var/www/yiises
- Edit the config files to set Yii up with a mysql connection:
- 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]',
- sudo vim console/config/main.php – uncomment db section.
- sudo vim backend/config/main.php – uncomment frontend alias line, and db section.
- sudo vim frontend/config/main.php – uncomment db section.
- sudo vim common/config/params-local.php
- Run the script that “deploys” the environment that we call “local”: sudo ./runpostdeploy local no-migrate
- Run the yii migrations to create the users table: sudo ./yiic migrate
- Setup 2 DNS rules (e.g. using AWS Route53) for this app:
- Make “yiises.yourdomain.com” a DNS Alias for the instance IP. Test it with by browsing to http://yiises.yourdomain.com/
- Make “admin.yiises.yourdomain.com” a DNS Alias for the instance IP. Test it with by browsing to http://admin.yiises.yourdomain.com/
- Set up Apache:
- 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>
- sudo vim /etc/apache2/sites-available/yiises:
- Enable the rewrite module and the new vhost:
sudo a2enmod rewrite
sudo a2ensite yiises
sudo service apache2 reload
- Check it works: http://yiises.yourdomain.com/ you should see:
This is index view file…
- A less boring page should be the admin backend: http://admin.yiises.yourdomain.com/
- Install the yiises module:
- cd /var/www/yiises/backend/modules
sudo wget https://github.com/clevertech/YiiSES/archive/master.zip
sudo unzip master.zip
sudo rm master.zip
- Rename to “ses”: sudo mv YiiSES-master ses
- Move a command from the module into the correct place: sudo cp ses/commands/CampaignCommand.php ../../console/commands/
- Declare the module in the backend config
sudo vim backend/config/main-local.php
Add:
'modules' => array(
'ses'=>array('password'=>'clevertech',),
),
- cd /var/www/yiises/backend/modules
- Set the SES params that the module needs:
- In the AWS SES console, Verify a email address.
- Setup a IAM user called “MailChap-app” and give it access to SES. Note down the creds for the next step.
- 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',
- Run the migrations for yiises:
- Move the migration from the module into the correct place: sudo cp ses/migrations/m120809_075915_ses_initial_migration.php ../../console/migrations/
- Edit the migration file so the subscribed field is added to the users table (because this is not in the default from the yiiboilerplate).
- Run the migration: sudo ./yiic migrate
- Hit http://admin.yiises.yourdomain.com/ses – The password is as above “clevertech”
- 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).
to setup yiises | jpdave
[…] to setup yiises […]