接下來這篇就會比較偏 server 設定了! nginx 是一套伺服器軟體,和 apache 並駕齊驅 (其實我覺得 nginx >>> apache XD) 主要是 nginx 清量快速 我們要拿他幫 nodejs 處理接收 request 的部分,再將 request 導往 nodejs 所以感覺就會如下圖: 可以讓 nginx 當作是 load balancer, 透過 reverse proxy 的方式轉發 request 給 nodejs, 讓 nginx 承受流量 這就是我們今天要做的事情, 所以首先,我們就要先裝 nginx,因此就先進虛擬機吧! $ sudo apt-get update && sudo apt-get upgrade -y $ sudo apt-get install nginx 這樣就會安裝一個 nginx 了! Nginx 的設定檔都是放在 /etc/nginx/ 底下 個別網站的設定放在 /etc/nginx/sites-available 如果要讓該網站上線,則會將 /etc/nginx/sites-available 的設定檔 link 到 /etc/nginx/sites-enable

Continue reading

I use Ubuntu 14.04, Nginx 1.4.6, php5-fpm, Codeigniter 2.2.0 It will remove index.php, and access Codeigniter site normally. Clean configuration “/etc/nginx/site-enabled/default”: server { #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> START listen 80; listen [::]:80 default_server ipv6only=on; root /YOUR/PROJECT/ROOT; index index.html index.htm index.php; # Make site accessible from http://localhost/ server_name localhost; #location ~* .(ico|css|js|gif|jpe?g|png)(?[0-9]+)?$ { # expires max; # log_not_found off; #} location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404.

Continue reading

Install choose the latest version of Openresty I used ngx_openresty-1.7.2.1.tar.gz # install packages sudo apt-get install libreadline-dev libpcre3-dev libssl-dev perl # get openresty package wget http://openresty.org/download/ngx_openresty-1.7.2.1.tar.gz # unzip tar xzvf ngx_openresty-1.7.2.1.tar.gz # install cd ngx_openresty-1.7.2.1/ # You can setup with ./configure --prefix="the folder you want to install", default is '/usr/local/openresty' ./configure make sudo make install # need permission to copy file to target folder Default folder: /usr/local/openresty Setup create work folder in ~

Continue reading

nodejs v0.10.25 (for rails javascript engine) rbenv 0.4.0-98-g13a474c ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux] Rails 4.1.4 nginx version: nginx/1.6.0 Phusion Passenger version 4.0.48 mysql Ver 14.14 Distrib 5.5.38, for debian-linux-gnu (x86_64) using readline 6.3 Installing Ruby & Rails sudo apt-get update && sudo apt-get upgrade sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties nodejs npm Use rbenv cd git clone git://github.

Continue reading

RVM with Ruby2.0.0-p353 + Rails4.0.2 + Ubuntu12.04(precise64) + php-fpm by Vagrant(clean install) p.s. If you don’t use RVM, you can just follow the instruction from Passenger offcial website. It will be easier. Plus, I installed all these things by Vagrant. First thing to do $ sudo apt-get update $ sudo apt-get upgrade Pre-setup: install necessary packages $ sudo apt-get update $ sudo apt-get install build-essential libssl-dev libpcre3-dev libncurses5-dev libreadline6-dev git vim curl libcurl4-openssl-dev libreadline6 autoconf openssl git-core zlib1g zlib1g-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev autoconf libc6-dev libgdbm-dev libncurses5-dev automake libtool bison subversion pkg-config libffi-dev Get .

Continue reading

Vagrant - Development environments made easy. 就是這個軟體的宗旨,把它想做是 ghost 吧!我們開發網站或是測試一些多機器架構時,常不小心就把自己的電腦或是測試主機搞到爛掉,租機器又慢又花錢,搞到爛重灌更麻煩。因此這個軟體基於 VirtualBox 做出了令人方便設定的功能,讓我們可以快速架設安裝環境並測試,尤其是以多機器架構而言更是方便!例如從最簡單的 Web server + DB server,或是 Web Load Balancer + Application Server * 5 等等的架構,一台電腦就能達成囉! 今天主要是以安裝 Vagrant 及架設出 Nginx + php5-fpm 的架構,下一篇打算另外建構一台 mongodb server,達到 Vagrant 最主要的多機器設定功能~ Vagrant 基本設定 先下載 VirtualBox 吧! 下載 Vagarnt 套件 http://downloads.vagrantup.com/ 安裝好後,可能會需要加 path,至少 1.3.0 當時我是自己加的,現在 1.3.5 就不清楚了~ 接下來就可以開始加入 box (可以把它想為 ghost 檔),並開始設定 Vagrant。 vagrant box add {你想要的Box名稱} {下載網址} 輸入後就會開始下載該 box 了! 範例:

Continue reading

Author's picture

kerkerj

Cat lover <3

Backend Engineer

Taiwan