Ubuntu 8.04快速搭建nginx+php(fastcgi)系统

Posted in PHP, Unix Like by neemem on 08-12-2008.

昨天在FreeBSD下玩了+,今天到Ubuntu下 来玩玩了,首先要感谢“过够了”的文章以下是按他的文章修改而来。在下搭建比freebsd下速度要快得多,因为在Freebsd我是用 ports方式安装,需要编译,下直接apt-get install 的方式安装,速度很快,下面就来开始安装吧!

1,安装,执行以下命令,很快完成,不过目前apg-get方式安装默认是0.5.33的版本

sudo apt-get install

配置文件默认安装位置:

conf: /etc//.conf
bin:/usr/sbin/
vhost: /etc//sites-enable/default
-params: /etc//-params
例:建一个虚拟

{
listen 80;
server_name www.23day.com;
access_log /var/log//home.ucenter.access.log;

location / {
root /var/www/23day.com;
index index.;

location ~ \.$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.;
fastcgi_param SCRIPT_FILENAME /var/www/23day.com$fastcgi_script_name;
include /etc//fastcgi_params;
}
}
2,安装-模块

执行sudo apt-get install php5-

配置文件默认安装位置:

QUOTE:
-: /usr/bin/-
php5-: /usr/bin/php5-
config: /usr/bin//.ini

修改.ini文件的.fix_pathinfo数据为1,默认为0

.fix_pathinfo=1; 这样-方能正常使用SCRIPT_FILENAME这个变量

3,安装spawn-fcgi spawn-fcgi是的一个用来控制-的工具.

如果系统没有安装GCC编译环境,刚需要在安装之前要安装build-essential工具包,执行以下命令

sudo apt-get install build-essential
wget http://www..net/download/-1.4.19.tar.gz
tar -xvf -1.4.19.tar.gz
cd -1.4.19/
sudo apt-get install libpcre3-dev
./configure –without-zlib –without-bzip2
make
sudo cp src/spawn-fcgi /usr/local/bin/spawn-fcgi
这样控制器就安装完成.

4.启动测试系统.启动fast_cgi:

spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/-

注意:ip,端口与服务器中的-pass要对应. -C表示打开几个进程

启动

sudo /etc/init.d/ start

好了,如果没有出错信息,则说明配置成功了,现在写个phpinfo测试下吧!

最后,附上我的/etc//sites-enable/default的配置文件,此配置文件启用了rewrite功能

{
listen 80;
server_name localhost;

access_log /var/log//localhost.access.log;

location / {
root /var/www/-default;
index index.;

if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.){
rewrite (.*) $1/index.;
}
if (!-f $request_filename){
rewrite (.*) /index.;
}

}

#error_page 404 /404.html;

# redirect error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/-default;
}

# proxy the scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.$ {
#proxy_pass http://127.0.0.1;
#}

# pass the scripts to listening on 127.0.0.1:9000
#
location ~ \.$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.;
fastcgi_param SCRIPT_FILENAME /var/www/-default$fastcgi_script_name;
include /etc//fastcgi_params;
}

# deny access to .htaccess files, if Apache’s document root
# concurs with ’s one
#
#location ~ /\.ht {
#deny all;
#}
}

# another virtual host using mix of IP-, name-, and port-based configuration
#
# {
#listen 8000;
#listen somename:8080;
#server_name somename alias another.alias;

#location / {
#root html;
#index index.html index.htm;
#}
#}

# HTTPS
#
# {
#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;
#}
#}

Related posts:
不需要cydia,installer和winscp了,用破解MobileInstallation安装程序 Ubuntu 飞信安装、调试、下载 Fetion

Leave a Reply