Showing posts with label Setup. Show all posts
Showing posts with label Setup. Show all posts

Friday, December 7, 2012

Apache add virtual host on a new port

1. Create a site

$> cp /etc/apache2/sites-available/default /etc/apache2/sites-available/newsite

edit /etc/apache2/sites-available/newsite:

<VirtualHost *:8082>
        ServerAdmin ops@example.com

        DocumentRoot /home/yourname/www
...

2. Enable a site


$> ln -s /etc/apache2/sites-available/newsite /etc/apache2/site-enabled/newsite
or
$> sudo a2ensite newsite


3. Listen to the port

edit /etc/apache2/ports.conf

Listen 80
Listen 8082
NameVirtualHost *:80
NameVirtualHost *:8082

Thursday, December 6, 2012

Setup Ubuntu for Modx Evolution - Part 3

http://wiki.modxcms.com/index.php/Installation_Guide

Ensure https supports:

sudo a2ensite default-ssl
sudo a2enmod ssl

Note: if site copied from original, make sure it's hosted on the same /home/cms/public_html or change paths accordingly.

Switch to utf8 in mysql on ubuntu - Update

[mysqld]
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_general_ci

[mysqld] default-character-set=utf8 (This line bugged and mysqld couldn't start!) [client] default-character-set=utf8

https://bugs.launchpad.net/ubuntu/+source/mysql-5.5/+bug/958120



Restart:

$> sudo service mysql restart

Setup Ubuntu for Modx Evolution - Part 2

Configurations:

Create user account:
$> sudo useradd -m  -s /bin/bash cms
$> sudo passwd cms

The user created will not be in the sudoers file.
-s : for setting the bash be the default shell.
-m: create /home/cms as user's home directory.
($> sudo userdel -r cms) to rollback


Migrate contents from current Modx CMS hosting on another server.
1. GZip tar and download the entire /public_html directory for old server.
2. Upload to /home/cms.
3. $> tar -zxvf public_html.tar.gz
4. Set apache document root to /home/cms/public_html
5. Restart apache: sudo service apache2 restart

6. Locate database config file: search database name within the files under /public_html
7. Config file: /manager/includes/config.inc.php

8. On the old server, export database by phpmyadmin>Export databases. -> localhost.sql
9. Copy localhost.sql to /home/cms
10. Restore database: $> mysql - u user_name -p database_name < file_name.sql




Wednesday, December 5, 2012

Setup Ubuntu for Modx Evolution - Part 1

Procedures for setup Ubuntu and Modx Revolution:

Install Ubuntu Server 12.04

SSH: 
    Installation: sudo apt-get install openssh-server openssh-client
    Verify: ssh localhost

Apache2:
    Installation: sudo apt-get install apache2
    Verify: http://localhost or the IP
    Verify: sudo netstat -tap | grep mysql
    Location: /etc/apache2/

Mysql:
    Installation:
sudo apt-get install mysql-server
sudo apt-get install php5-mysql

    Verify: sudo netstat -tap | grep mysql

PHP5:
    Installation: sudo apt-get install php5 libapache2-mod-php5
    Restart Apache: sudo service apache2 restart
    Verify: <?php
                    phpinfo();
                ?>

Configurations:
edit /etc/apache2/sites-available/default, set the DocumentRoot there to /home/your_name/www

References:
http://www.cyberciti.biz/faq/ubuntu-linux-openssh-server-installation-and-configuration/
https://help.ubuntu.com/12.04/serverguide/index.html


Tuesday, November 13, 2012

Jenkins, Rails - Run rails test directly on Jenkins workspace

$ cd /var/lib/jenkins/jobs/[Jenkins_project_name]/workspace/
$ RAILS_ENV=test bundle exec rake test:units

Friday, November 2, 2012

SSH tunnel vs VPN in short

Both: Encrypted data for secure connection.

VPN: Operating System level security
SSH: Application level security

VPN: Share intranet resource such as file shares, network printer, etc
SSH: Setup per individual resources.

VPN: Easy for client usage. More to do on server setup.
SSH: Not easy for novice user. Easy for SSH server setup.

VPN: More secure for business use. You can force all network traffic on
system through VPN.
SSH: Good for single purpose connection. e.g. remote access intranet
server.

Sunday, October 14, 2012

Setup ctags on Mac for Rails development

The original ctags comes with Mac OS may say something like this when you run ctags -R:


$ctags -R
ctags: illegal option -- R
usage: ctags [-BFadtuwvx] [-f tagsfile] file ...

To solve the problem, install a new version and disable the original one:

$ brew install ctags
$ cd /usr/bin/
$ sudo mv ctags ctags.orig

Then $which ctags will give you the new installed ctags in /usr/local/bin/ctags.

Friday, October 12, 2012

Run multiple Jenkins Rails test simultaneously

Under the continuous integration platform Jenkins, there can be multiple build projects that may run at the same time.  For example, unit tests, functional tests and integration tests. 

By default, all projects may have database.yml configurations that points to the same test database.  This may lead to failure like this:

...

DETAIL:  There are 1 other session(s) using the database.  : DROP DATABASE IF EXISTS "test_db">  test_db already exists
...

To allow simultaneously tests, database yml should be modified to use different database:
/var/lib/jenkins/jobs/[Project Name]/workspace/config/database.yml


* Set the max number jobs to be run concurrently on Jenkins' settings.


Monday, October 8, 2012

Auto switch ruby version on project directory

Create a .rvmrc file under the project directory, with rvm startup script.  e..g

rvm use ruby-1.9.3

Friday, September 21, 2012

Monday, September 17, 2012

bash customization

$PS1="\h:\W \u~[\A]\$"         #prompt
alias ll='ls -alG'

(in .bash_login)

Sunday, September 16, 2012

General steps to setup an existing Ruby on Rails project from Git repository

1. Git clone the source
2. Update configuration files, such as config/database.yml and/or config/config.yml
3. Create database accordingly.
4. Install project gems: $ bundle install
5. Install dependency packages.  e.g. ImageMagick for paperclip gem.
    $ brew install imagemagick
6. Prepare database: $ rake db:migrate
7. Prepare test: $ rake db:test:prepare
8. Run test: $ rake test

Customize macvim/gvim for Ruby on Rails development

1. Install Janus - https://github.com/carlhuda/janus

2. Get color scheme. e.g. http://www.vim.org/scripts/script.php?script_id=1891
    Copy vividchalk.vim to ~/.vim/colors

3. ~/.gvimrc.after
set guifont=Monaco:h13
set stal=2 " turn on tabs by default
set noanti

colorscheme vividchalk


4. ~/.vimrc.before
nmap <F3> :vimgrep /<C-R><C-W>/ ./**/*.rb ./**/*.erb

Setup or update postgresql on Mac

Remove any previous version:
brew rm postgresql --force

Installation
brew update
brew install postgresql

Initialise a database.
initdb /usr/local/var/postgres

Set to start at login with (in one line below)
mkdir -p ~/Library/LaunchAgents
 


cp /usr/local/Cellar/postgresql/[x.x.x]/[....].postgres.plist ~/Library/LaunchAgents/


launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist

OR

Add aliases to .bashrc to start and stop the server:
alias pgs='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start'

alias pgq='pg_ctl -D /usr/local/var/postgres stop -s -m fast'


Postgresql client verification:
$which psql
$ls -al /usr/local/bin/psql 
/usr/local/bin/psql -> ../Cellar/postgresql/.../bin/psql

(Edit ~/.bash_profile : PATH=/usr/local/bin:$PATH)


Update postgresql tools versions
Tools like psql or pg_dump may not be update by the installations.
Just remove old version pg_* in /usr/bin, and create symbolic link to new ones in /usr/local/bin.

Saturday, September 15, 2012

bash config startup sequence

For Login shells (subject to the -noprofile option):

On logging in:
If `/etc/profile' exists, then source it.

If `~/.bash_profile' exists, then source it,
else if `~/.bash_login' exists, then source it,
else if `~/.profile' exists, then source it.

On logging out:
If `~/.bash_logout' exists, source it.

For non-login interactive shells (subject to the -norc and -rcfile options):
On starting up:
If `~/.bashrc' exists, then source it.

For non-interactive shells:
On starting up:
If the environment variable `ENV' is non-null, expand the variable and source the file named by the value. If Bash is not started in Posix mode, it looks for `BASH_ENV' before `ENV'.

So, typically, your `~/.bash_profile' contains the line
`if [ -f `~/.bashrc' ]; then source `~/.bashrc'; fi' after (or before) any login specific initializations.

If Bash is invoked as `sh', it tries to mimic the behavior of `sh' as closely as possible. For a login shell, it attempts to source only `/etc/profile' and `~/.profile', in that order. The `-noprofile' option may still be used to disable this behavior. A shell invoked as `sh' does not attempt to source any other startup files.

When Bash is started in POSIX mode, as with the `-posix' command line option, it follows the Posix 1003.2 standard for startup files. In this mode, the `ENV' variable is expanded and that file sourced; no other startup files are read.

Friday, September 14, 2012

Clean setup ruby ree on Mountain Lion

http://blog.teamtreehouse.com/installing-ruby-rails-and-mysql-on-os-x-lion

http://ryanbigg.com/2011/06/mac-os-x-ruby-rvm-rails-and-you/

http://coderwall.com/p/fywjrw

xcode - app store
(need to install after download completed: open xcode in application, ...)
xocde - go to preference -> download -> command line tools
(try $gcc -v to ensure it works.)

Install the followings using su login:
homebrew - http://mxcl.github.com/homebrew/

gcc (non-LLVM) -
brew tap homebrew/dupes
brew install apple-gcc42

xquartz - apple's X11
http://xquartz.macosforge.org/landing/

git - brew install git

Install the followings using local login:
rvm - $ curl -L https://get.rvm.io | bash -s stable --ruby

CPPFLAGS=-I/opt/X11/include CC=/usr/local/bin/gcc-4.2 rvm install --force ree

Install the followings using su login:
postgresql - brew install postgresql

or
mysql - brew install mysql