SDpower

FreeBSD

gitolite 安裝

by on 十一月.01, 2011, under FreeBSD, Git

FreeBSD gitolite 安裝
安裝:

1
# cd /usr/ports/devel/gitolite ; make install clean;

安裝結束最後面會看到以下提示:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
==============================================================================
 
Final gitolite installation instructions:
 
Any ssh user can be a gitolite provider. Simply run the following command as
the user:
 
/usr/local/bin/gl-setup /path/to/admin.ssh.key.pub
 
This will setup up the configuration files for gitolite, designating where the
repositories are located and other options.
 
The admin ssh key allows full access to the gitolite-admin repository where
additional users and repositories can be configured.
 
By default, the git user is created for use by gitolite.
 
==============================================================================
===> Correct pkg-plist sequence to create group(s) and user(s)
===>   Registering installation for gitolite-2.1
===>  Cleaning for gitolite-2.1

(continue reading…)

Fork me on GitHub
Leave a Comment more...

Lua for PHP 安裝

by on 七月.20, 2011, under FreeBSD, Lua, PHP & MYSQL

主要安裝擴充套件資訊 LUA for PHP
使用 Plua 為安裝源.

Linux 安裝方式:
先安裝好 lua:

1
$apt-get install lua5.1 liblua5.1-0-dev

先下載並解開:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ cd /tmp
$ wget http://plua.googlecode.com/files/plua-1.0.0.zip
$ tar zxvf plua-1.0.0.zip
$ cd plua
$ phpize
$ whereis php-config
php-config: /usr/bin/php-config /usr/share/man/man1/php-config.1.gz
$ rm -f include
$ ln -s /usr/include/lua5.1 include
$ ln -s /usr/lib lib
$ cd lib
$ ln -s /usr/lib/liblua5.1.a liblua.a
$ ln -s /usr/lib/liblua5.1.so liblua.so
$ cd ..
$ make
$ make install
Installing shared extensions:     /usr/lib/php5/20090626/
$

自行編輯php 設定 增加extension=plua.so

FreeBSD 安裝方式:
先安裝好 lua:

1
$cd /usr/port/lang/lua ; make install clean ;

先下載並解開:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ cd /tmp
$ wget http://plua.googlecode.com/files/plua-1.0.0.zip
$ tar zxvf plua-1.0.0.zip
$ cd plua
$ phpize
$ whereis php-config
php-config: /usr/bin/php-config /usr/share/man/man1/php-config.1.gz
$ rm -f include
$ ln -s /usr/local/include/lua51 include
$ ln -s /usr/local/lib/lua51 lib
$ cd ..
$ make
$ make install
Installing shared extensions:     /usr/lib/php5/20090626/
$

自行編輯/usr/local/etc/php/extension.ini 設定 增加extension=plua.so

1 Comment more...

FreeBSD 架設 git Server

by on 四月.11, 2011, under FreeBSD

安裝:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#cd /usr/ports/devel/git; make install clean
------------------------------------------------------------------------
*************************** GITWEB *************************************
If you installed the GITWEB option please follow these instructions:
 
In the directory /usr/local/share/examples/git/gitweb you can find all files to
make gitweb work as a public repository on the web.
 
All you have to do to make gitweb work is:
1) Copy the files /usr/local/share/examples/git/gitweb/* to a directory on
   your web server (e.g. Apache2) in which you are able to execute
   CGI-scripts.
2) In gitweb.cgi, adjust the variable $projectroot to point to
   your git repository (that is where you have your *.git project
   directories).
*************************** GITWEB *************************************
 
*************************** CONTRIB ************************************
If you installed the CONTRIB option please note that the scripts are
installed in /usr/local/share/git-core/contrib. Some of them require
other ports to be installed (perl, python, etc), which you may need to
install manually.
*************************** CONTRIB ************************************
------------------------------------------------------------------------
 
===> Installing rc.d startup script(s)
===>   Compressing manual pages for git-1.7.4.1
===>   Registering installation for git-1.7.4.1
===> SECURITY REPORT:
      This port has installed the following files which may act as network
      servers and may therefore pose a remote security risk to the system.
/usr/local/libexec/git-core/git-daemon
 
      This port has installed the following startup scripts which may cause
      these network services to be started at boot time.
/usr/local/etc/rc.d/git_daemon
 
      If there are vulnerabilities in these programs there may be a security
      risk to the system. FreeBSD makes no guarantee about the security of
      ports included in the Ports Collection. Please type 'make deinstall'
      to deinstall the port if this is a concern.

For more information, and contact details about the security
status of this software, see the following webpage:

http://git-scm.org/

===> Cleaning for p5-subversion-1.6.15
===> Cleaning for cvsps-2.1
===> Cleaning for git-1.7.4.1

更改設定檔:

1
2
3
git_daemon_enable="YES"
git_daemon_directory="/git"
git_daemon_flags="--export-all --syslog --enable=receive-pack"

新增使用者 git:

1
2
#pw groupadd -n git -g 9418
#pw useradd -n git -u 9418 -g git -c git -d /git -s /usr/local/libexec/git-core/git-shell -h -

更改屬性:

1
2
3
4
5
# chown git:git /git/
# chmod 755 /git
# mkdir /git/repo/
# chown git:git /git/repo/
# chmod 775 /git/repo/

現在要設定哪些使用者有權限在 /git/cnmc/ 底下建立新的 repo。若使用者只需要 commit,不需要加進來:

1
2
3
# vi /etc/group
...
git:*:9418:steve

因為 git 要用 SSH keys(SSH 金鑰)認證,要先收集所有需要 commit 權限的使用者的 SSH keys。然後放到正確的檔案:

1
2
3
4
5
6
# mkdir /git/.ssh/
# chmod 700 /git/.ssh/
# touch /git/.ssh/authorized_keys
# chmod 600 /git/.ssh/authorized_keys
(把公鑰放進 authorized_keys,一行一個)
# chown -R git:git /git/.ssh/
Leave a Comment more...

FreeBSD 8.2-RELEASE

by on 二月.25, 2011, under FreeBSD

Release Highlights

The highlights in the 8.2-RELEASE are the following:

  • [amd64] FreeBSD/amd64 now always sets the KVA space as equal to or larger than physical memory size. This change would help to prevent a “kmem_map too small” panic which often occurs when using ZFS.[r214620]
  • The FreeBSD GENERIC kernel is now compiled with KDB and KDB_TRACE options. From 8.2-RELEASE the kernel supports displaying a stack trace on panic by using stack(9) facility with no debugger backend like ddb(8). Note that this does not change the default behaviors of the GENERIC kernel on panic.[r214326]
  • The FreeBSD crypto(4) framework (opencrypto) now supports XTS-AES (XEX-TCB-CTS, or XEX-based Tweaked Code Book mode with CipherText Stealing), which is defined in IEEE Std. 1619-2007.[r214254]
  • [amd64] Xen HVM support in FreeBSD/amd64 kernel has been improved. For more details, see xen(4) manual page.[r215788]
  • FreeBSD now fully supports GPT (GUID Partition Table). Checksums of primary header and primary partition table are verified properly now.[r213994]
  • [amd64, i386] The aesni(4) driver has been added. This supports AES accelerator on Intel CPUs and accelerates AES operations for crypto(4).[r215633]
  • [amd64, i386] The aibs(4) driver has been added. This supports the hardware sensors in ASUS motherboards and replaces the acpi_aiboost(4) driver.[r210476]
  • The tpm(4) driver, which supports Trusted Platform Module has been added.[r215036]
  • The xhci(4) driver, which supports Extensible Host Controller Interface (xHCI) and USB 3.0, has been added.[r215944]
  • The FreeBSD Linux emulation subsystem now supports the video4linux API. This requires native video4linux hardware drivers such as the ones provided by multimedia/pwcbsd and multimedia/webcamd.
  • The miibus(4) has been rewritten for the generic IEEE 802.3 annex 31B full duplex flow control support. The alc(4), bge(4), bce(4), cas(4), fxp(4), gem(4), jme(4), msk(4), nfe(4), re(4), stge(4), and xl(4) drivers along with atphy(4), bmtphy(4), brgphy(4), e1000phy(4), gentbi(4), inphy(4), ip1000phy(4), jmphy(4), nsgphy(4), nsphyter(4), and rgephy(4) have been updated to support flow control via this facility.[r211379, r215881, r215890, r2105894, r216002, r216023, r216029, r216031, r216033]
  • A new netgraph(4) node ng_patch(4) has been added. This performs data modification of packets passing through. Modifications are restricted to a subset of C language operations on unsigned integers of 8, 16, 32 or 64-bit size.[r209843]
  • The FreeBSD TCP reassembly implementation has been improved. A long-standing accounting bug affecting SMP systems has been fixed and the net.inet.tcp.reass.maxqlen sysctl(8) variable has been retired in favor of a per-connection dynamic limit based on the receive socket buffer size. FreeBSD receivers now handle packet loss (particularly losses caused by queue overflows) significantly better than before which improves connection throughput.[r214865, r214866]
  • The siftr(4), Statistical Information For TCP Research (SIFTR) kernel module has been added. This is a facility that logs a range of statistics on active TCP connections to a log file. It provides the ability to make highly granular measurements of TCP connection state, aimed at system administrators, developers and researchers.[r214859]
  • The geli(8) GEOM class now uses XTS-AES mode by default.[r214405]
  • The ZFS on-disk format has been updated to version 15 and various performance improvements for the ZFS have been imported from OpenSolaris.
  • Userland support for the dtrace(1) subsystem has been added. This allows inspection of userland software itself and its correlation with the kernel, thus allowing a much better picture of what exactly is going on behind the scenes. The dtruss(1) utility has been added and libproc has been updated to support the facility.[r214983]
  • The gpart(8) utility now supports a recover subcommand for GPT partition tables.
  • The gpart(8) utility now supports GPT_ENT_ATTR_BOOTME, GPT_ENT_ATTR_BOOTONCE, and GPT_ENT_ATTR_BOOTFAILED attributes in GPT. The attribute keywords in the command line are bootme, bootonce, and bootfailed respectively.[r213994]
  • The libarchive library and tar(1) utility now support LZMA (Lempel-Ziv-Markov chain-Algorithm) compression format.[r213667]
  • The newsyslog(8) utility now supports an -S pidfile option to override the default syslogd(8) PID file.[r211699]
  • The newsyslog(8) utility now supports a special log file name <include> for processing file inclusion. Globbing in the file name and circular dependency detection are supported. For more details, see the newsyslog.conf(5) manual page.[r215622]
  • The pmcstat(8) utility now supports a file and a network socket as a top source. This allows top monitoring over TCP on a system with no local symbols, for example.[r211098]
  • The tftp(1) and tftpd(8) utilities have been improved for better interoperability and they now support RFC 1350, 2347, 2348, 2349, and 3617.[r213036, r213038]
  • A periodic script for zfs scrub has been added. For more details, see the periodic.conf(5) manual page.
  • A periodic script which can be used to find installed ports’ files with mismatched checksum has been added. For more details, see the periodic.conf(5) manual page.
  • The sysinstall(8) utility now uses the following numbers for default and minimum partition sizes: 1GB for /, 4GB for /var, and 1GB for /tmp.[r211007]
  • The ACPI-CA has been updated to 20101013.
  • The ee(1) program has been updated to version 1.5.2.[r214287]
  • ISC BIND has been updated to version 9.6-ESV-R3.
  • netcat has been updated to version 4.8.
  • OpenSSL has been updated to version 0.9.8q.
  • The timezone database has been updated to the tzdata2010o release.
  • The xz has been updated from snapshot as of 12 April 2010 to 5.0.0 release
  • The supported version of the GNOME desktop environment (x11/gnome2) has been updated to 2.32.1.
  • The supported version of the KDE desktop environment (x11/kde4) has been updated to 4.5.5.

FreeBSD 8.2-RELEASE Release Notes

Leave a Comment more...

Ntop FreeBSD

by on 二月.22, 2011, under FreeBSD

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#cd /usr/ports/net/ntop/
#make install clean
...
************************************************************
************************************************************
 
  WARNING: This install created a directory for the ntop
           files and databases:
 
             //usr/local/share/ntop
 
           This directory MUST be owned by the user
           which you are going to use to run ntop.
 
           The command you must issue is something like:
 
           chown -R ntop.ntop //usr/local/share/ntop
     or    chown -R ntop:users //usr/local/share/ntop
 
           man chown to check the syntax for YOUR system
 
************************************************************
************************************************************
# ntop -A
Wed Feb  9 16:55:29 2011  NOTE: Interface merge enabled by default
Wed Feb  9 16:55:29 2011  Initializing gdbm databases
 
 
ntop startup - waiting for user response!
 
 
Please enter the password for the admin user:
Please enter the password again:
Wed Feb  9 16:55:43 2011  Admin user password has been set
#
Leave a Comment more...

VirtualBox-OSE on FrreeBSD 免x11

by on 十二月.29, 2010, under FreeBSD, 未分類

參考 http://d.hatena.ne.jp/wittro/20100617/1276782079

cd /usr/src
make build32 install32;
ldconfig -v -m -R /usr/lib32
cd /usr/ports/emulators/virtualbox-ose
make install clean
=============================================================================
 
VirtualBox was installed.
 
You need to load the vboxdrv kernel module via /boot/loader.conf:
 
vboxdrv_load="YES"
 
For bridged networking please add the following line to your /etc/rc.conf:
 
vboxnet_enable="YES"
 
Reboot the machine to load the needed kernel modules.
 
You also have to add all users to your vboxusers group in order to use vbox.
 
% pw groupmod vboxusers -m jerry
 
Running VirtualBox as non-root user may fail with a fatal error
NS_ERROR_FACTORY_NOT_REGISTERED. In this case delete /tmp/.vbox-*-ipc file.
 
Check wiki page for known issues and troubleshooting:
http://wiki.freebsd.org/VirtualBox
 
Please report any problems to emulation@. Thanks!
 
=============================================================================

弄個shell-script 來產生 虛擬機器設定

#!/bin/csh -f
set vm=winxp
set mem=1024
set cpu=1
#HD
set size=10000
#set dvdiso=`pwd`/windows7.iso
set dvdiso=/raid5/virtualbox/windowsXPSP3r.iso
# /root/.VirtualBox/Machines/
VBoxManage createvm -name $vm -register
VBoxManage modifyvm $vm --memory $mem --cpus $cpu --vram 32
VBoxManage modifyvm $vm --acpi on --ioapic on
VBoxManage modifyvm $vm --nic1 bridged --bridgeadapter1 bge0
VBoxManage modifyvm $vm --nictype1 82540EM
VBoxManage modifyvm $vm --vrdp on --cableconnected1 on --boot1 dvd
 
VBoxManage createvdi --filename ${vm}.vdi --size $size --format VDI --variant Standard
VBoxManage storagectl $vm --name ide --add ide --controller PIIX4
VBoxManage storageattach $vm --storagectl ide --port 0 --device 0 --type hdd --medium ${vm}.vdi
VBoxManage storageattach $vm --storagectl ide --port 1 --device 0 --type dvddrive --medium $dvdiso
#VBoxVRDP  --startvm $vm
#VBoxManage storageattach $vm --storagectl ide --port 1 --device 0 --type dvddrive --medium /usr/local/lib/virtualbox/additions/VBoxGuestAdditions.iso
#VBoxVRDP  --startvm $vm

執行 5900 vnc的port vnc的密碼123456

VBoxHeadless -n -m 5900 -o 123456 -s winxp -w 1024 -h 768

很方便 還可搞個私人雲端XDDD (其實只是lab)
效能上比之前用QEMU好上太多太多~~


2011-02-14補充:
在安裝virtualbox-ose的時候一定要選上WEBSERVICE選項,後面安裝的phpvirtualbox的時候需要用到。

啟動vboxwebsrv
$ vboxwebsrv
安裝phpvirtualbox
$ cd /usr/ports/www/phpvirtualbox && make install clean
$ VBoxManage setproperty websrvauthlibrary null
然後在Nginx或Apache中配置站點,目錄指向/usr/local/www/phpvirtualbox目錄
在瀏覽器中輸入http://localhost/phpvirtualbox就可以開始安裝配置Virtualbox了。

Clone VM export

1
2
3
$ VBoxManage export winxp -o winxp.ovf                                                                   (08-02 08:10)  
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Successfully exported 1 machine(s).
1
$  VBoxManage import winxp.ovf --vsys 0 --vmname winxp2
Leave a Comment more...

PHP 5.3.3 FreeBSD 安裝調整.

by on 八月.10, 2010, under FreeBSD, PHP & MYSQL

php 5.3.3之後整合了php-fpm進去對於使用輕量化web server的使用者不再麻煩了.
以下是安裝畫面,安裝選項.

# cd /usr/ports/lang/php5; make install clean;


(continue reading…)

Leave a Comment more...

FreeBSD 上使用 wkhtmltopdf 做網頁擷取

by on 八月.04, 2010, under FreeBSD, PHP & MYSQL

以往要用程式控制將網頁輸出pdf或擷取網頁,都是件浩大工程.
這次介紹如何在FreeBSD 命令列模式下即可輕易辦到,並且不需龐大的X Windows 圖形系統適合在server上跑.

以下是軟體原文介紹.

wkhtmltopdf

Convert html to pdf using webkit (qtwebkit)

Description

Simple shell utility to convert html to pdf using the webkit rendering engine, and qt.

Introduction

Searching the web, I have found several command line tools that allow you to convert a HTML-document to a PDF-document, however they all seem to use their own, and rather incomplete rendering engine, resulting in poor quality. Recently QT 4.4 was released with a WebKit widget (WebKit is the engine of Apples Safari, which is a fork of the KDE KHtml), and making a good tool became very easy.
此軟體使用WebKit開發完成,除了flash以外其他接可正常顯示!!(包含js)
在安裝前請先確定你的FreeBSD已安裝 linux-base 套件並正常使用,並且將port tree更新.
(continue reading…)

2 Comments more...

筆記 Haproxy 設定

by on 四月.07, 2010, under FreeBSD

Haproxy 設定筆記

global
        log 127.0.0.1   local0
        log 127.0.0.1   local1 notice
        #log loghost    local0 info
        maxconn 4096
        #chroot /var/chroot/haproxy
        user haproxy
        group haproxy
        daemon
        #debug
        #quiet
                                nbproc      2 # Number of processes
 
defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        option redispatch
        maxconn 2000
        contimeout      5000
        clitimeout      30000
        srvtimeout      50000
        monitor-uri /ok.html
        stats uri /stats
        stats auth admin:admin
 
listen  load_balanced_http      :80
    mode http
    option httpchk
    option httplog
    option forwardfor
    option httpclose               # disable keep-alive
    option checkcache              # block response if set-cookie & cacheable
    option redispatch
    option persist
    cookie SERVERID insert nocache indirect
    balance roundrobin
    server shop1 192.168.0.1:80 cookie server01 weight 49 maxconn 400 check inter 40000
    server shop2 192.168.0.2:80 cookie server02 weight 51 maxconn 500 check inter 40000
 
listen  load_balanced_https     :443
    mode tcp
    balance roundrobin
    option  ssl-hello-chk
    option  forwardfor
    server shop1 192.168.0.1:443 check inter 30000 rise 1 fall 2
    server shop2 192.168.0.2:443 check backup
Leave a Comment more...

FreeBSD NGINX + PHP5

by on 三月.30, 2010, under FreeBSD, PHP & MYSQL

先去官網找到freebsd專用的port

http://php-fpm.org/downloads/freebsd-port/

# fetch http://php-fpm.org/downloads/php-5.2.10-fpm-0.5.13.diff.gz
# mv php-5.2.10-fpm-0.5.13.diff.gz /usr/ports/distfiles/
# fetch http://files.directadmin.com/services/custombuild/php-5.2.9-mail-header.patch
# mv php-5.2.9-mail-header.patch /usr/ports/distfiles/
# fetch http://php-fpm.org/downloads/freebsd-port/php-5.2.10-fpm-0.5.13.tar.gz
php-5.2.10-fpm-0.5.13.tar.gz                  100% of 9503  B   45 kBps
# tar zxvf php-5.2.10-fpm-0.5.13.tar.gz -C /usr/ports/lang
x php5-fpm/
x php5-fpm/files/
x php5-fpm/Makefile
x php5-fpm/distinfo
x php5-fpm/pkg-descr
x php5-fpm/pkg-plist
x php5-fpm/files/php-fpm.sh.in
x php5-fpm/files/patch-scripts::phpize.in
x php5-fpm/files/patch-TSRM_threads.m4
x php5-fpm/files/patch-Zend::zend.h
x php5-fpm/files/patch-Zend_zend_list.c
x php5-fpm/files/patch-Zend_zend_list.h
x php5-fpm/files/patch-ext_standard_array.c
x php5-fpm/files/patch-ext_standard_basic_functions.c
x php5-fpm/files/patch-ext_standard_dns.h
x php5-fpm/files/patch-ext_standard_image.c
x php5-fpm/files/patch-php.ini-dist
x php5-fpm/files/patch-php.ini-recommended
x php5-fpm/files/patch-main::php_config.h.in
x php5-fpm/files/patch-main_SAPI.c
x php5-fpm/files/patch-acinclude.m4
x php5-fpm/files/patch-configure.in
 
# cd /usr/ports/lang/php5-fpm/
# make install clean
# fetch http://www.grid.net.ru/nginx/download/nginx_upload_module-2.0.12.tar.gz
# mv nginx_upload_module-2.0.12.tar.gz /usr/ports/distfiles/
# fetch http://mod-zip.googlecode.com/files/mod_zip-1.1.5.tar.gz
# mv mod_zip-1.1.5.tar.gz /usr/ports/distfiles/
# cd /usr/ports/www/nginx-devel
# make install clean

編輯/usr/local/etc/php-fpm.conf
nobody改成www

Unix user of processes
nobody
Unix group of processes
nobody

編輯/usr/local/etc/nginx/nginx.conf

#user  nobody;
worker_processes  2;
 
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
 
#pid        logs/nginx.pid;
 
events {
    worker_connections  1024;
}
 
http {
    include       mime.types;
    default_type  application/octet-stream;
 
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';
 
    #access_log  logs/access.log  main;
 
    server_names_hash_bucket_size 128;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    client_max_body_size 8m;
 
    sendfile        on;
    #tcp_nopush     on;
    server_tokens  off;
    tcp_nopush     on;
 
    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;
 
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
    fastcgi_buffer_size 64k;
    fastcgi_buffers 4 64k;
    fastcgi_busy_buffers_size 128k;
    fastcgi_temp_file_write_size 128k;
 
    gzip_static on;
    gzip  on;
    gzip_min_length  1k;
    gzip_proxied     expired no-cache no-store private auth;
    gzip_buffers 4 16k;
    gzip_comp_level   5;
    gzip_types       text/plain application/x-javascript text/css application/xml;
    gzip_disable     "MSIE [1-6]\.";
    gzip_vary on;
 
    server {
        listen       80;
        server_name  localhost;
	autoindex  on;
 
        #charset koi8-r;
 
        #access_log  logs/host.access.log  main;
 
        location / {
            root   /www;
            index  index.php index.html index.htm;
        }
 
        #error_page  404              /404.html;
 
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/local/www/nginx-dist;
        }
 
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}
 
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           /www;
     	    fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /www$fastcgi_script_name;
            include        fastcgi_params;
        }
 
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
            deny  all;
        }
 
    }
  server {
    listen       80;
    server_name  test2.localhost www.test2.localhost;
    access_log  /var/log/test2.access.log;
    error_log  /var/log/test2.error.log;
    location ~* ^.+\.(jpg|jpeg|gif)$ {
     root   /www/test2/pub;
     expires 30d;
    }
    location ~* ^.+\.(js|css)$ {
     root   /www/test2/pub;
     expires 1h;
    }
    location / {
        root   /www/test2/pub;
        index  index.php index.html index.htm;
    }
    location ~ \.php$ {
      root           /www/test2/pub;
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME  /www/test2/pub$fastcgi_script_name;
      include        fastcgi_params;
    }
    location ~ /\.ht {
            deny  all;
    }
  }
 
    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;
 
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
 
    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;
 
    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;
 
    #    ssl_session_timeout  5m;
 
    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    #    ssl_prefer_server_ciphers   on;
 
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
}

編輯/etc/rc.conf

php_fpm_enable="YES"
nginx_enable="YES"

http://www.anilcetin.com/convert-apache-htaccess-to-nginx/

http://wiki.nginx.org/Main

3 Comments more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!