Wednesday, June 3, 2015

Elastic Beanstalk with Git

In your git project directory, run

eb init

It will ask for your security access keys, you can get it here:

https://console.aws.amazon.com/iam/home?#security_credential

When asking for solution stack, use the following (if you are using docker)

50) 64bit Amazon Linux 2015.03 v1.4.1 running Docker 1.6.0

After it's done, it will show you the location with your auth info:

/Users/{username}/.elasticbeanstalk/aws_credential_file

Deploy the application by:

eb start

If you see the following boto error, install it:

ImportError: No module named boto

Instruction: https://github.com/boto/boto

Saturday, May 30, 2015

Set up MAMP with Nginx, php-fpm and symfony on MacOSX

To make this work, you will need to have MAMP installed.

The steps are as follows: install php-fpm, add your symfony config to nginx.conf, start the server.

Install php5-fpm

You can use macport or brew to install php5-fpm

After it's install, search php5-fpm by doing "which-fpm". Note that it may be called "php-fpm" in some installations.

php5-fpm requires two configurations to be set up: /etc/php-fpm.conf and /etc/php-fpm/pool.d/{whatever}.conf

Sample php-fpm.conf:

https://github.com/perusio/php-fpm-example-config/blob/tcp/fpm/php5-fpm.conf

Sample pool.d/{whatever}.conf

http://www.if-not-true-then-false.com/2011/nginx-and-php-fpm-configuration-and-optimizing-tips-and-tricks/

Start php5-fpm by

> sudo php5-fpm

In your MAMP config - /conf/nginx/nginx.conf, put in the relevant http and https server settings:

server {
listen 80;
   server_name localhost_moonlight;
   root /Users/rei999/Documents/symfony_workspace/moonlight/web;

   location / {
       try_files $uri /app_dev.php$is_args$args;
   }
   # DEV
   # This rule should only be placed on your development environment
   # In production, don't include this and don't deploy app_dev.php or config.php
   location ~ ^/(app_dev|config)\.php(/|$) {
       fastcgi_pass 127.0.0.1:9000;
       fastcgi_split_path_info ^(.+\.php)(/.*)$;
       include fastcgi_params;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       fastcgi_param HTTPS off;
       }

   error_log /Applications/MAMP/logs/nginx/moonlight_error.log;
   access_log /Applications/MAMP/logs/nginx/moonlight_access.log;
}

server {
listen 443 ssl;
   server_name localhost_moonlight;

   ssl_certificate      /Applications/MAMP/conf/ssl/server.crt;
        ssl_certificate_key  /Applications/MAMP/conf/ssl/server.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

   root /Users/rei999/Documents/symfony_workspace/moonlight/web;

   location / {
       try_files $uri /app_dev.php$is_args$args;
   }
   # DEV
   # This rule should only be placed on your development environment
   # In production, don't include this and don't deploy app_dev.php or config.php
   location ~ ^/(app_dev|config)\.php(/|$) {
       fastcgi_pass 127.0.0.1:9000;
       fastcgi_split_path_info ^(.+\.php)(/.*)$;
       include fastcgi_params;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       fastcgi_param HTTPS off;
       }

   error_log /Applications/MAMP/logs/nginx/moonlight_error.log;
   access_log /Applications/MAMP/logs/nginx/moonlight_access.log;
}



Depending on your PHP-FPM config, the fastcgi_pass can also be fastcgi_pass 127.0.0.1:9000.

Start MAMP Nginx.

Wednesday, May 13, 2015

Handy RabbitMQ commands

Running rabbitmq in background:

rabbitmq-server -detached

Checking status:

rabbitmqctl status

Stopping:

rabbitmqctl stop

Show queues:

rabbitmqctl list_queues

Show queues with message status

rabbitmqctl list_queues name messages_ready messages_unacknowledged

Installing pip and supervisor on mac

Start by getting installing pip from the following link:

https://pip.pypa.io/en/stable/installing.html

Insall supervisor (there's no stable release of supervisor at the time of this writing, use the --pre flag):

> pip install supervisor --pre

Supervisor should be running already.

Copy the config to /etc

> echo_supervisord_conf > /etc/supervisord.conf

If supervisord is not already started, run supervisord in the directory your desired config is located. If you don't want to use the /etc/supervisord.conf and you have it somewhere else, run it there.

Start supervisord

> supervisord

Restart all supervisor processes.

> sudo supervisorctl restart all

If you want to start a program, you need to use :*, as supervisord names each program along with it's process name. Assume you defined your program as [program:hello]:

> supervisorctl
> start hello:*

Stop supervisor:

> ps -ef | grep supervisord

This should show the process id running supervisord. Terminate it by issuing a kill command.

501 95787     1   0 Fri07pm ??         0:02.92 /usr/bin/python /usr/local/bin/supervisord

> kill -s SIGTERM 95787

For a sample supervisord config, check here.

Thursday, April 9, 2015

phpstorm xdebug php.ini settings

Put the following into your php.ini

[xdebug]
zend_extension="/Applications/MAMP/bin/php/php5.5.22/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so"
xdebug.profiler_enable=1
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM

Friday, March 13, 2015

Bee run failed for Golang and Beego

If you are using beego and bee in your Golang project, you may run into an issue that says "Run failed" when you started "bee run"

Assuming you cd into your folder and the error still persists, try running "bee version".

bee   :1.2.4
beego :1.4.3

exec: "go": executable file not found in $PATH

If you see the above message, you may find that the newest Golang SDK from google is naming "go" command as "goapp".

What you need to do is to rename "go_appengine/goapp" to "go_appengine/go".

And rename "go_appengine/goroot/goapp" to "go_appengine/goroot/go".