Install Laravel with nginx

August 3, 2014

Install Nginx

安裝nginx指令

sudo apt-get install nginx

Configuring Nginx

sudo nano /etc/nginx/sites-available/default

內容如下:


Your HTML code/snippet goes here
p { color: red }
server {
    listen   80 default_server;

    root /var/www/laravel/public/;
    index index.php index.html index.htm;

    location / {
         try_files $uri $uri/ /index.php$is_args$args;
    }

    # pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
    location ~ \.php$ {
            try_files $uri /index.php =404;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
    }
}

Configuring PHP

nano /etc/php5/fpm/php.ini

找到 cgi.fix_pathinfo=1 參數 將其1改變為0

cgi.fix_pathinfo=0

Configuration php5-fpm

nano /etc/php5/fpm/pool.d/www.conf

在設定檔案中找到"listen = /var/run/php5-fpm.sock"並修改為 "listen = 127.0.0.1:9000"

listen = 127.0.0.1:9000

重新啟動Nginx及php-fpm

service php5-fpm restart
service nginx restart

Install Laravel

安裝composer

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

利用composer安裝laravel

composer create-project laravel/laravel /var/www/laravel/ 4.1

修改權限問題

chgrp -R www-data /website/laravel
chmod -R 775 /website/laravel/app/storage

參考資源

Install LEMP Server

Laravel 4 學習足跡

How To Install Laravel with Nginx on an Ubuntu 12.04 LTS VPS

Git 版本控制系統

解決 nginx 使用 php-fpm 時 502 Bad Gateway 問題

microsoft

前端教學網站分享

微軟教學系列

Microsoft Virtual Academy
-HTML5 & CSS3 Fundamentals: Development for Absolute Beginners
-Developing in HTML5 with JavaScript and CSS3 Jump Start
-Building Web Apps with ASP.NET Jump Start
陸續更新~[MVA]微軟虛擬學院,從零開始的課程,HTML5 & CSS3](http://www.dotblogs.com.tw/mis2000lab/archive/2014/01/09/mvahtml5beginner_20140107.aspx)

QuickCast on OS X

QuickCast是一個最近發現的好玩工具,在它簡單的操作下能夠錄製螢幕畫面但是只有三分鐘,不過它不同於一般的螢幕錄製QuickCast在錄製完成後會直接上傳到QuickCast伺服器上同時也提供了方便的社群分享功能,在這分享給大家囉!!

QuickCast圖片來源

大家可以到App Store or QuickCast官方下載

QuickCast 可支援Windows 7 & Mac OS X


安裝完成後可以看見在系統上方狀態列會有快捷按鈕可使用

image

點選Record進行錄製

image

簡單設置錄製細節

Example

錄製完的影片會用信箱通知您

MongoDB

Install MongoDB on OS X

MongoDB安裝方法

目前安裝MongoDB方法有兩種

Example1:


透過Howebrew來進行安裝

$ brew update
$ brew install mongodb

若你已經安裝過MongoDB想要更新的話也可以透過指令更新

$ brew update
$ brew upgrade mongodb

另外你可以選擇在安裝時加上SSL支援功能

$ brew install mongodb --with-openssl

建立dbpath在您自行定義的目錄

切換置root身份

$ sudo tcsh 
root# whoami
root
# mkdir -p /data/db
# chmod 777 /data/db

啓動mongod服務

切換置一般身份

$ sudo mongod

Example2:


手動安裝

先下載您所選擇的版本

官方下載

$ curl -O http://fastdl.mongodb.org/osx/mongodb-osx-x86_64-2.4.9.tgz

解壓縮MongoDB

$ tar -zxvf mongodb-osx-x86_64-2.4.9.tgz

建立連結到/usr/loacl讓指令方便存取

$ sudo mv -n mongodb-osx-x86_64-2.4.9 /usr/local
$ sudo ln -s /usr/local/mongodb-osx-x86_64-2.4.9/bin/* /usr/local/bin/.

建立dbpath在您自行定義的目錄

切換置root身份

$ sudo tcsh 
root# whoami
root
# mkdir -p /data/db
# chmod 777 /data/db

啓動mongod服務

切換置一般身份

$ sudo mongod

安裝完成後簡單測試

Sat Jan 18 11:33:08.143 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
> db.people.insert({'name':'Bruce'})
> db.people.find()
{ "_id" : ObjectId("52d9f783487f6e71cfe1cd2f"), "name" : "Bruce" }
node.js

Node.js Create Simpleness Blog


I follow this example to implemented blog.

Refer to Creating simple blog with Node.js (express and mongodb)

1.Create Express


First let's install express

If you don't have install 'express' you must setinng on this step.

npm install -g express

The -g flag means is your express will be installing globally on your system

Useing commamd to create blog project
$ express blog-express

  create : blog-express
  create : blog-express/package.json
  create : blog-express/app.js
  create : blog-express/public
  create : blog-express/public/javascripts
  create : blog-express/public/images
  create : blog-express/public/stylesheets
  create : blog-express/public/stylesheets/style.css
  create : blog-express/routes
  create : blog-express/routes/index.js
  create : blog-express/routes/user.js
  create : blog-express/views
  create : blog-express/views/layout.jade
  create : blog-express/views/index.jade
Command is auto create package.json so we will just following command execution:
  install dependencies:
  $ cd blog-express && npm install
Then we can test whether the installation is successful
  run the app:
  $ node app

Opne browser and link to localhost:3000 test your app is work!

If the app is Correct Work you will see the following picture

Imgur

node.js

Express install Guide and Use


Refer to Express Guide

Getting Started


Install express

npm install -g express

After the installation is complete you can use the npm info express version to confirm express.

Example1:

The sample was install for individual project under express

Create a project folder
$ mkdir helloworld
You will need a "package.json" file in the project folder, this file contains "project name" "description" "project version" and "project dependencies conten".
$ vim package.json
 {
  "name": "helloworld",
  "description": "helloworld",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
   "express": "3.x"
  }
 }
Save package.json and starting install express from the project
$ npm install

After the installation is complete the following information will be shown

express@3.4.8 node_modules/express
├── merge-descriptors@0.0.1
├── methods@0.1.0
├── cookie-signature@1.0.1
├── range-parser@0.0.4
├── fresh@0.2.0
├── debug@0.7.4
├── buffer-crc32@0.2.1
├── cookie@0.1.0
├── mkdirp@0.3.5
├── commander@1.3.2 (keypress@0.1.0)

├── send@0.1.4 (mime@1.2.11)
└── connect@2.12.0 (uid2@0.0.3, pause@0.0.1, bytes@0.2.1,     raw-body@1.1.2, qs@0.6.6, batch@0.5.0, negotiator@0.3.0,    multiparty@2.2.0)

Example2:

The sample was install express on Global system

$ npm install -g express

1.Install Homebrew


First open a terminal,enter the following command

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

brew is a similar Ubuntu apt-get to use

2.Instructions


Update Package List

brew update

Search Software

brew search `package-name`

Install Software

brew install `package-name`

Remove Package

brew uninstall `package-name`