在RHEL5.3上安装基于postfix的extmail邮件系统
extmail官方网站上的安装指南是针对4.x系统的,网上找了一个5.x的安装。
参考在centos/redhat 5.x 上安装邮件系统postfix+extmail+courier-imap
安装步骤.
1.系统准备
使用默认方式安装系统后,从RHEL安装盘上拷贝一些下面安装步骤需要的rpm包先安装上。
-
rpm -ivh postgresql-devel-8.1.11-1.el5_1.1.i386.rpm
-
rpm -ivh expect-5.43.0-5.1.i386.rpm
-
rpm -ivh libtool-ltdl-devel-1.5.22-6.1.i386.rpm
-
-
rpm -ivh mysql-devel-5.0.45-7.el5.i386.rpm
-
rpm -ivh openldap-servers-2.3.43-3.el5.i386.rpm
-
rpm -ivh openldap-servers-sql-2.3.43-3.el5.i386.rpm
-
-
rpm -ivh pcre-6.6-2.el5_1.7.i386.rpm
-
rpm -ivh pcre-devel-6.6-2.el5_1.7.i386.rpm
再从 www.extmail.org 网站上下载最新的 extmail 相关包
extmail-1.1.0.tar.gz extman-1.0.0.tar.gz slockd-0.99.tar.gz
2.导入extman后台数据库数据
-
tar -xzvf extman-1.0.0.tar.gz
-
cd extman-1.0.0/docs
-
mysql -u root -p
-
mysql> source extmail.sql
-
mysql> source init.sql
-
mysql> exit
Popularity: 13% [?]
Related
nginx中的多条件rewrite解决方案
前两天在搞 nginx 的rewrite, 其中有个地址需要用到多条件判断,结果试了好久,没有办法在nginx中写出复合方式的条件判断,比如
if ($request_method !~ ^post$ && $request_filename !~ ^/file/a.* ) {
rewrite …
}
网上参照了一篇,可以通过nginx的set命令,来设置变量进行前置判断,从而达到多条件的rewrite实现。
# 先定义两变量备用
set $my_file ”;
set $my_uri $request_uri;if ($request_method = POST) {
set $my_uri ”;
}# 使用友好的地址方式
if ($query_string) {
set $my_uri ”;
}…
# 判断$my_uri是否为空,不为空,则设置要rewrite到的文件,再在下面用rewrite转
if ($my_uri ~ ^(.+)$) {
set $my_file /cache/myfile/$http_host/$1index.html;
}if (-f $document_root$my_file) {
rewrite ^(.*)$ $my_file break;
}
将名为$my_uri的变量作为标志位,如果不满足一些前置条件时,将标志位置空;
在最后只要判断标志位是否为空,如果不为空,再进行rewrite
Popularity: 6% [?]
Related
Nginx常见应用技术指南(Nginx Tips) – 转
Nginx 常见应用技术指南(Nginx Tips)[定期更新]
作者:NetSeek http://www.linuxtone.org(IT运维专家网|集群架构|性能调优)
欢迎转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本声明.
更新时间:[2008-12-4] 第一版:[2008-11-25]
目录:
一. Nginx基础知识
二. Nginx安装配置
三. Nginx Rewrite
四. Nginx Redirect
五. Nginx 目录自动加斜线
六. Nginx 防盗链
七. Nginx expires
八. Nginx 访问控制
九. Nginx Location
十. Nginx 日志处理
十一. Nginx Cache服务配置
十二. Nginx 负载均衡
十三. Nginx 优化
十四. Nginx 相关参考文档
Read more
Popularity: 6% [?]
Related
Nginx服务器的upload上传模块
在Nginx网站的模块列表页中发现一个Nginx服务器的上传模块http://www.grid.net.ru/nginx/upload.en.html
该模块通过Nginx服务器来接受用户上传的文件,在Nginx接受完文件以后再转给后端的程序做处理。
它自动分析客户端的上传请求,将上传的文件保存到 upload_store 所指向的目录位置. 然后这些文件信息将被从原始的请求中剔除,重新组装好上传参数后转到后端由 upload_pass 指定的位置去处理,这样就可以任意处理上传的文件。
每一个上传的 file 字段值将可以由upload_set_form_field 指定的值替换. 文件的内容可以由$upload_tmp_path 变量读到或简单的移到其他位置. 将文件删除由 upload_cleanup 指定控制。
upload_set_form_field可以使用的几个变量
- $upload_field_name
- $upload_content_type
- $upload_file_name
- $upload_tmp_path
原始的文件字段
上传文件的类型
客户端上传的原始文件名称
上传的文件保存在服务端的位置
upload_aggregate_form_field 可以多使用的几个变量,文件接收完毕后生成的
- $upload_file_md5
- $upload_file_md5_uc
- $upload_file_sha1
- $upload_file_sha1_uc
- $upload_file_crc32
- $upload_file_size
文件的MD5校验值
大写字母表示的MD5校验值
文件的SHA1校验值
大写字母表示的SHA1校验值
16进制表示的文件CRC32值
文件大小
官方的设置举例
-
# 上传表单应该提交到这个地址
-
location /upload {
-
# 将请求体转到这个位置
-
upload_pass /test;
-
-
# 将上传的文件保存到这个目录下
-
# 目录是被散列化的,应该存在子目录 0 1 2 3 4 5 6 7 8 9
-
upload_store /tmp 1;
-
-
# 允许上传的文件被用户 user 只读
-
upload_store_access user:r;
-
-
# 设置请求体的字段(添加自己后端处理的信息)
-
upload_set_form_field "${upload_field_name}_name" $upload_file_name;
-
upload_set_form_field "${upload_field_name}_content_type" $upload_content_type;
-
upload_set_form_field "${upload_field_name}_path" $upload_tmp_path;
-
-
# 指示后端关于上传文件的md5值和文件大小
-
upload_aggregate_form_field "${upload_field_name}_md5" $upload_file_md5;
-
upload_aggregate_form_field "${upload_field_name}_size" $upload_file_size;
-
-
# 指示原样转到后端的参数,可以正则表达式表示
-
upload_pass_form_field "^submit$|^description$";
-
}
-
-
# 将请求转到后端的地址处理
-
location /test {
-
proxy_pass http://localhost:8080;
-
}
-
}
将模块添加到Nginx中的方法
下载源代码解压后
为nginx配置额外模块(需要重新编译):
-
tar xvzf nginx_upload_module-2.0.7.tar.gz
-
cd nginx631
-
./configure –add-module=/usr/local/nginx_upload_module-2.0.7
-
make
-
make install
Popularity: 6% [?]
Related
November 25, 2008 | Filed Under LAMP, My Projects, Productivity, WebServer | Comments Off
为了Awstats给Nginx添加FastCGI方式的Perl支持
有个应用(awstats)需要Perl脚本支持,但是用的Nginx服务器,对Perl支持不好,于是通过FastCGI方式来使用Perl。
首先安装Perl的FCGI模块
-
wget http://www.cpan.org/modules/by-module/FCGI/FCGI-0.67.tar.gz
-
tar -zxvf FCGI-0.67.tar.gz
-
cd FCGI-0.67
-
perl Makefile.PL
-
make && make install
还可以使用如下方法安装:
perl -MCPAN -e 'install FCGI'
安装FCGI-ProcManager
-
wget http://search.cpan.org/CPAN/authors/id/G/GB/GBJK/FCGI-ProcManager-0.18.tar.gz
-
tar -xzxf FCGI-ProcManager-0.18.tar.gz
-
cd FCGI-ProcManager-0.18
-
perl Makefile.PL
-
make
-
make install
Perl的FastCGI启动脚本
参考这篇文章 http://bbs.chinaunix.net/archiver/?tid-1224968.html
vi fcgi_perl
-
#!/usr/bin/perl -w
-
use FCGI;
-
use Socket;
-
use FCGI::ProcManager;
-
sub shutdown { FCGI::CloseSocket($socket); exit; }
-
sub restart { FCGI::CloseSocket($socket); &main; }
-
use sigtrap 'handler', \&shutdown, 'normal-signals';
-
use sigtrap 'handler', \&restart, 'HUP';
-
require 'syscall.ph';
-
use POSIX qw(setsid);
-
-
#&daemonize; we don't daemonize when running under runsv
-
#this keeps the program alive or something after exec'ing perl scripts
-
END() { }
-
BEGIN() { }
-
{
-
no warnings;
-
*CORE::GLOBAL::exit = sub { die "fakeexit\nrc=" . shift() . "\n"; };
-
};
-
eval q{exit};
-
if ($@) {
-
exit unless $@ =~ /^fakeexit/;
-
}
-
&main;
-
-
sub daemonize() {
-
chdir '/' or die "Can't chdir to /: $!";
-
defined( my $pid = fork ) or die "Can't fork: $!";
-
exit if $pid;
-
setsid() or die "Can't start a new session: $!";
-
umask 0;
-
}
-
-
sub main {
-
#如果使用 IP sockets
-
#$socket = FCGI::OpenSocket( "127.0.0.1:8999", 10 );
-
#如果使用 UNIX sockets
-
#$socket = FCGI::OpenSocket( "/var/run/perl_cgi-dispatch.sock", 10 );
-
-
#foreach $item (keys %ENV) { delete $ENV{$item}; }
-
#设置fastcgi进程数,默认四个
-
my $n_processes = $ENV{FCGI_NPROCESSES} || 4;
-
$proc_manager = FCGI::ProcManager->new( {n_processes => $n_processes} );
-
#使用unix socket
-
$socket = FCGI::OpenSocket( "$ENV{FCGI_SOCKET_PATH}", 10 );
-
#设置Socket权限
-
chmod 0777, $ENV{FCGI_SOCKET_PATH};
-
-
; #use UNIX sockets – user running this script must have w access to the 'nginx' folder!!
-
$request =
-
FCGI::Request( \*STDIN, \*STDOUT, \*STDERR, \%req_params, $socket,
-
&FCGI::FAIL_ACCEPT_ON_INTR );
-
$proc_manager->pm_manage();
-
if ($request) { request_loop() }
-
FCGI::CloseSocket($socket);
-
}
-
-
sub request_loop {
-
while ( $request->Accept() >= 0 ) {
-
$proc_manager->pm_pre_dispatch();
-
-
#processing any STDIN input from WebServer (for CGI-POST actions)
-
$stdin_passthrough = '';
-
{ no warnings; $req_len = 0 + $req_params{'CONTENT_LENGTH'}; };
-
if ( ( $req_params{'REQUEST_METHOD'} eq 'POST' ) && ( $req_len != 0 ) )
-
{
-
my $bytes_read = 0;
-
while ( $bytes_read < $req_len ) {
-
my $data = '';
-
my $bytes = read( STDIN, $data, ( $req_len – $bytes_read ) );
-
last if ( $bytes == 0 || !defined($bytes) );
-
$stdin_passthrough .= $data;
-
$bytes_read += $bytes;
-
}
-
}
-
-
#running the cgi app
-
if (
-
( -x $req_params{SCRIPT_FILENAME} ) && #can I execute this?
-
( -s $req_params{SCRIPT_FILENAME} ) && #Is this file empty?
-
( -r $req_params{SCRIPT_FILENAME} ) #can I read this file?
-
)
-
{
-
pipe( CHILD_RD, PARENT_WR );
-
pipe( PARENT_ERR, CHILD_ERR );
-
my $pid = open( CHILD_O, "-|" );
-
unless ( defined($pid) ) {
-
print("Content-type: text/plain\r\n\r\n");
-
print
-
"Error: CGI app returned no output – Executing $req_params{SCRIPT_FILENAME} failed !\n";
-
next;
-
}
-
$oldfh = select(PARENT_ERR);
-
$| = 1;
-
select(CHILD_O);
-
$| = 1;
-
select($oldfh);
-
if ( $pid > 0 ) {
-
close(CHILD_RD);
-
close(CHILD_ERR);
-
print PARENT_WR $stdin_passthrough;
-
close(PARENT_WR);
-
$rin = $rout = $ein = $eout = '';
-
vec( $rin, fileno(CHILD_O), 1 ) = 1;
-
vec( $rin, fileno(PARENT_ERR), 1 ) = 1;
-
$ein = $rin;
-
$nfound = 0;
-
-
while ( $nfound =
-
select( $rout = $rin, undef, $ein = $eout, 10 ) )
-
{
-
die "$!" unless $nfound != -1;
-
$r1 = vec( $rout, fileno(PARENT_ERR), 1 ) == 1;
-
$r2 = vec( $rout, fileno(CHILD_O), 1 ) == 1;
-
$e1 = vec( $eout, fileno(PARENT_ERR), 1 ) == 1;
-
$e2 = vec( $eout, fileno(CHILD_O), 1 ) == 1;
-
-
if ($r1) {
-
while ( $bytes = read( PARENT_ERR, $errbytes, 4096 ) ) {
-
print STDERR $errbytes;
-
}
-
-
if ($!) {
-
$err = $!;
-
die $!;
-
vec( $rin, fileno(PARENT_ERR), 1 ) = 0
-
unless ( $err == EINTR or $err == EAGAIN );
-
}
-
}
-
if ($r2) {
-
while ( $bytes = read( CHILD_O, $s, 4096 ) ) {
-
print $s;
-
}
-
if ( !defined($bytes) ) {
-
$err = $!;
-
die $!;
-
vec( $rin, fileno(CHILD_O), 1 ) = 0
-
unless ( $err == EINTR or $err == EAGAIN );
-
}
-
}
-
last if ( $e1 || $e2 );
-
}
-
close CHILD_RD;
-
close PARENT_ERR;
-
waitpid( $pid, 0 );
-
} else {
-
foreach $key ( keys %req_params ) {
-
$ENV{$key} = $req_params{$key};
-
}
-
-
# cd to the script's local directory
-
if ( $req_params{SCRIPT_FILENAME} =~ /^(.*)\/[^\/]+$/ ) {
-
chdir $1;
-
}
-
close(PARENT_WR);
-
-
#close(PARENT_ERR);
-
close(STDIN);
-
close(STDERR);
-
-
#fcntl(CHILD_RD, F_DUPFD, 0);
-
syscall( &SYS_dup2, fileno(CHILD_RD), 0 );
-
syscall( &SYS_dup2, fileno(CHILD_ERR), 2 );
-
-
#open(STDIN, "<&CHILD_RD");
-
exec( $req_params{SCRIPT_FILENAME} );
-
die("exec failed");
-
}
-
} else {
-
print("Content-type: text/plain\r\n\r\n");
-
print
-
"Error: No such CGI app – $req_params{SCRIPT_FILENAME} may not exist or is not executable by this process.\n";
-
}
-
}
-
}
再设置启动的脚本
vi startfcgiperl
-
export FCGI_SOCKET_PATH="/tmp/perl_fcgi.socket"
-
export FCGI_NPROCESSES=4
-
./fcgi_perl &
为Nginx添加FastCGI的Perl支持
编辑 nginx.conf 脚本,添加如下内容
location ~* .*\.pl$ { include awstats.conf; } location /awstatsicon/ { alias /var/www/awstats-6.8/wwwroot/icon/; }
vi awstats.conf
fastcgi_pass unix:/tmp/perl_fcgi.socket; fastcgi_index awstats.pl; #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #fastcgi_param SCRIPT_FILENAME /var/www/awstats-6.8/wwwroot/cgi-bin$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME /var/www/awstats-6.8/wwwroot/cgi-bin/awstats.pl; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; fastcgi_read_timeout 60;
配置Awstats
运行 /var/www/awstats-6.8/tools/awstats_configure.pl 设置好一些变量
mkdir -p /etc/awstats cp /var/www/awstats-6.8/wwwroot/awstats.model.conf /etc/awstats/awstats.my.site.com.conf
使用 vi /etc/awstats.my.site.com.conf 进行一些参数修改,设置icon目录,DirData数据存放目录,来源log日志文件路径等
使用 /var/www/awstats-6.8/tool/awstats_updateall.pl now -awstatsprog=/var/www/awstats-6.8/wwwroot/cgi-bin/awstats.pl 命令进行初始数据更新
使用 http://my.site.com/awstats.pl 查看数据
后续
将 ./awstats_updateall.pl now -awstatsprog=/var/www/awstats-6.8/wwwroot/cgi-bin/awstats.pl 放到crontab 中做定时更新,可以做一个脚本和日志文件的处理一起做。
碰到问题
在使用unix socket时,碰到两个问题
1.写socket的目录没有写权限,添加上解决
2.nginx连不上socket, 看日志提示没有权限,在创建了socket后添加一句
chmod 0777, $ENV{FCGI_SOCKET_PATH};
问题解决。
遗留对awstats.pl访问密码限制问题尚未解决好。
解决 在 nginx 中按如下配置方式
location /awstats { root /var/www/awstats-6.8/; include awstats.conf; auth_basic "awstats"; auth_basic_user_file /var/www/.passwd; }
其中 将 awstats-6.8 目录下的 wwwroot 修改为 awstats, /var/www/.passwd 为访问目录要用来验证的账号密码文件,用apache的提供的工具htpasswd制作而成
Popularity: 8% [?]
Related
安装配置Nginx 0.6.32 +php 5.2.6(fastcgi) + Mysql 5.0.51
安装过程参考: http://blog.s135.com/read.php/314.htm
安装 mysql 5.0.51
- 首先下载必须资源
-
wget http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.51b.tar.gz/from/ftp://ftp.iij.ad.jp/pub/db/mysql/
- 添加mysql 用户组和账号
-
/usr/sbin/groupadd mysql
-
/usr/sbin/useradd -d /var/lib/mysql -s /sbin/nologin -g mysql mysql
- 用源码包编译安装
-
tar zxvf mysql-5.0.51b.tar.gz
-
cd mysql-5.0.51b/
-
./configure –prefix=/usr/local/mysql5051 –without-debug –with-unix-socket-path=/usr/local/mysql5051/mysql.sock –with-client-ldflags=-all-static –with-mysqld-ldflags=-all-static –enable-assembler –with-extra-charsets=gbk,gb2312,utf8 –with-pthread –enable-thread-safe-client
-
make
-
make install
- 修改目录的权限
-
chmod +w /usr/local/mysql5051
-
chown -R mysql:mysql /usr/local/mysql5051
- 复制默认配置文件
-
cp support-files/my-medium.cnf /usr/local/mysql5051/my.cnf
-
cp support-files/mysql.server /etc/init.d/mysqld
-
chmod +x /etc/init.d/mysqld
-
cd ../
- 初始化mysql库
-
/usr/local/mysql5051/bin/mysql_install_db –defaults-file=/usr/local/mysql5051/my.cnf –basedir=/usr/local/mysql5051 –datadir=/usr/local/mysql5051/data –user=mysql –pid-file=/usr/local/mysql5051/mysql.pid –skip-locking –port=3306 –socket=/tmp/mysql.sock
- 开启MySQL数据库服务
-
/bin/sh /usr/local/mysql5051/bin/mysqld_safe –defaults-file=/usr/local/mysql5051/my.cnf &
-
chkconfig –add mysqld
-
chkconfig –level 3456 mysqld on
-
/sbin/service mysqld start
-
/sbin/service mysqld stop
- 验证MySQL服务器运行情况
mysql 5.0.51 源码包获取。
设定安装路径到 /usr/local/mysql5051
建立初始化的数据库表,数据库数据存放在 /usr/local/mysql5051/data目录下
直接的命令行方式开启
或通过服务控制方式开启关闭服务
1.ps -fe |grep mysql 查看运行的进程
2.netstat -na |grep mysql 查看开放的端口
3./usr/local/mysql5051/bin/mysql -u root -p 登陆mysql看一下,同时可以修改一下root密码。
安装 php 5.2.6
- 下载源码包
-
wget http://cn2.php.net/get/php-5.2.6.tar.gz/from/cn.php.net/mirror
-
wget "http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0"
- 安装依赖包
-
rpm -ivh libjpeg-devel-6b-33.i386.rpm
-
rpm -ivh libpng-devel-1.2.7-1.i386.rpm
-
rpm -ivh freetype-devel-2.1.9-1.i386.rpm
-
rpm -ivh gd-devel-2.0.28-4.i386.rpm
-
tar -xzvf libmcrypt-2.5.8.tar.gz
-
cd libmcrypt-2.5.8/
-
./configure
-
make
-
make install
-
/sbin/ldconfig
-
cd libltdl/
-
./configure –enable-ltdl-install
-
make
-
make install
-
cd ../../
- 编译安装源码包
-
tar -xzvf php-5.2.6.tar.gz
-
cd php-5.2.6
-
./configure –prefix=/usr/local/php526 –with-config-file-path=/usr/local/php526/etc –with-gd=/usr/ –enable-gd-native-ttf –with-ttf –with-freetype-dir –with-jpeg-dir=/usr/ –with-png-dir=/usr/ –with-zlib=/usr/ –with-mysql=/usr/local/mysql5051 –with-openssl=/usr/local/ssl –enable-mbstring –with-curl –with-curlwrappers –with-iconv-dir=/usr/local –with-libxml-dir –enable-xml –disable-debug –disable-rpath –enable-discard-path –enable-safe-mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –enable-mbregex –enable-fastcgi –enable-force-cgi-redirect –with-mcrypt
-
make
-
make install
-
cd ..
- 启动php的fast-cg进程
-
ulimit -SHn 51200
-
/usr/local/php526/spawn-fcgi -a 127.0.0.1 -p 10080 -C 30 -u www -f /usr/local/php526/bin/php-cgi
php 5.2.6
php 安装需要的一些配置包。
libmcrypt
先从RHEL安装盘上拷贝出如下一些rpm包用 rpm -ivh xxx.rpm 方式安装上。
在用源码方式安装下载下来的源码包
使用lighttpd带的 spwan-fcgi, 如下以www身份开启30个fast-cgi进程
安装 nginx
nginx的中文Wiki站点 http://wiki.codemongers.com/NginxChs
niginx的英文站点 http://nginx.net
- 下载需要的资源
-
wget http://sysoev.ru/nginx/nginx-0.6.32.tar.gz
-
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.7.tar.gz
- 安装需要的库
-
tar -xzvf pcre-7.7.tar.gz
-
cd pcre-7.7/
-
./configure
-
make
-
make install
-
cd ../
- 从源码包编译安装Nginx
-
tar -xzvf nginx-0.6.32.tar.gz
-
cd nginx-0.6.32/
-
./configure –user=www –group=www –prefix=/usr/local/nginx632 –with-http_stub_status_module
-
make
-
make install
-
cd ../
- 建立WEB账号以及组
-
/usr/sbin/groupadd www -g 48
-
/usr/sbin/useradd -u 48 -g www www
- 建立相关网站目录
-
mkdir -p /var/www/xxt.igrow.cn
-
chmod +w /var/www/xxt.igrow.cn
-
chown -R www:www /var/www/xxt.igrow.cn
-
mkdir -p /var/www/logs
-
chmod +w /var/www/logs
-
chown -R www:www /var/www/logs
- 做Nginx参数配置
-
user www www;
-
-
worker_processes 8;
-
-
error_log /var/www/logs/nginx_error.log crit;
-
pid /usr/local/nginx632/nginx.pid;
-
-
worker_rlimit_nofile 51200;
-
-
events
-
{
-
use epoll;
-
worker_connections 51200;
-
}
-
-
http
-
{
-
include mime.types;
-
default_type application/octet-stream;
-
-
charset utf-8;
-
-
server_names_hash_bucket_size 128;
-
-
sendfile on;
-
tcp_nopush on;
-
-
keepalive_timeout 60;
-
tcp_nodelay on;
-
-
fastcgi_connect_timeout 60;
-
fastcgi_send_timeout 180;
-
fastcgi_read_timeout 180;
-
fastcgi_buffer_size 128k;
-
fastcgi_buffers 4 128k;
-
fastcgi_busy_buffers_size 128k;
-
fastcgi_temp_file_write_size 128k;
-
fastcgi_temp_path /dev/shm;
-
-
gzip on;
-
gzip_min_length 1k;
-
gzip_buffers 4 8k;
-
gzip_http_version 1.1;
-
gzip_types text/plain application/x-javascript text/css text/html application/xml;
-
-
server
-
{
-
listen 80;
-
server_name xxt.igrow.cn;
-
index index.html index.htm index.php;
-
root /var/www/xxt.igrow.cn;
-
-
if (-d $request_filename)
-
{
-
rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
-
}
-
-
location ~ .*\.php?$
-
{
-
include fcgi.conf;
-
fastcgi_pass 127.0.0.1:10080;
-
fastcgi_index index.php;
-
}
-
-
log_format access '$remote_addr – $remote_user [$time_local] "$request" '
-
'$status $body_bytes_sent "$http_referer" '
-
'"$http_user_agent" $http_x_forwarded_for';
-
access_log /var/www/logs/access.log access;
-
}
-
-
server
-
{
-
listen 80;
-
server_name status.xxt.igrow.cn;
-
-
location / {
-
stub_status on;
-
access_log off;
-
}
-
}
-
}
-
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
-
fastcgi_param SERVER_SOFTWARE nginx;
-
-
fastcgi_param QUERY_STRING $query_string;
-
fastcgi_param REQUEST_METHOD $request_method;
-
fastcgi_param CONTENT_TYPE $content_type;
-
fastcgi_param CONTENT_LENGTH $content_length;
-
-
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
-
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
-
fastcgi_param REQUEST_URI $request_uri;
-
fastcgi_param DOCUMENT_URI $document_uri;
-
fastcgi_param DOCUMENT_ROOT $document_root;
-
fastcgi_param SERVER_PROTOCOL $server_protocol;
-
-
fastcgi_param REMOTE_ADDR $remote_addr;
-
fastcgi_param REMOTE_PORT $remote_port;
-
fastcgi_param SERVER_ADDR $server_addr;
-
fastcgi_param SERVER_PORT $server_port;
-
fastcgi_param SERVER_NAME $server_name;
-
-
# PHP only, required if PHP was built with –enable-force-cgi-redirect
-
#fastcgi_param REDIRECT_STATUS 200;
- 启动Nginx
-
ulimit -SHn 51200
-
/usr/local/nginx632/sbin/nginx
-
the configuration file /usr/local/nginx632/conf/nginx.conf syntax is ok
-
the configuration file /usr/local/nginx632/conf/nginx.conf was tested successfully
获取nginx 0.6.32 源码包和所依赖的 pcre 源码包
设定安装目录到 /usr/local/nginx632
建立以 www:www 的账号和组用来运行网站服务。
存放网站的路径
日志路径
建nginx.conf文件
cat /usr/local/nginx632/conf/nginx.conf:
建fcgi.conf文件
cat /usr/local/nginx632/conf/fcgi.conf
在运行前可以通过 /usr/local/nginx632/sbin/nginx -t 检查一下看nginx的参数是否配置正确。
如果屏幕显示以下两行信息,说明配置文件正确:
配置开机启动Mysql+Phpcgi+Nginx
因为没有安装服务,需要添加一些命令到 /etc/rc.local 中用来开机启动
-
ulimit -SHn 51200
-
/bin/sh /usr/local/mysql5051/bin/mysqld_safe –defaults-file=/usr/local/mysql5051/my.cnf &
-
/usr/local/php526/spawn-fcgi -a 127.0.0.1 -p 10080 -C 30 -u www -f /usr/local/php526/bin/php-cgi
-
/usr/local/nginx632/sbin/nginx
设置iptables
在防火墙中放开相关服务端口。
-
#web port
-
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
-
#fastcgi port
-
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 10080 -s 127.0.0.1 -j ACCEPT
-
#mysql 本地通过unix socket访问, 不用设置
-
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp -s 127.0.0.1 –dport 3306 -j ACCEPT
使用 /sbin/service iptables restart 重新应用防火墙规则
验证服务状态
验证 nginx + php 运行是否正常。
在 /var/www/xxt.igrow.cn 目录下建一个test.php,里面存放内容
-
<?
-
echo phpinfo();
-
?>
通过 curl http://127.0.0.1/test.php 可以看到输出的php信息,表示 nginx + php 运行正常。
Popularity: 4% [?]
Related
July 11, 2008 | Filed Under LAMP, MySQL, WebServer | 4 Comments
Nignx配合Memcached提升400%性能(阅读笔记)
原始文章: http://www.igvita.com/2008/02/11/nginx-and-memcached-a-400-boost/
原文引用了 http://nubyonrails.com/articles/about-this-blog-memcached
和 http://blog.leetsoft.com/2007/5/22/the-secret-to-memcached
都是讲述怎样在Rails中使用memcached的(主要是key的设定方式和怎样对memcached的使用做类的包装)
文章在两篇引用文章的基础上直接将memcached的使用提升到url层,通过nginx对memcached的原生支持,讲述了一种利用url rewrite机制来直接将url请求地址作为key给memcached做处理,用以提升访问速度。
首先在编译 nginx 时要添加 memcached 模块编译,nginx 的 memcached 模块配置参数说明见 http://wiki.codemongers.com/NginxHttpMemcachedModule
文章讲述利用 url rewrite 机制来做key validate 的自动化处理,主要讲了一下url rewrite和mime type的配合问题。
本文启发
1.网站url地址要好规划,这样可以将不同类别的资源做分组,方便以后的统一处理,添加缓冲之类的。
2.怎样确定内容的修改频度,自动话的处理?如果是动态的对数据敏感新强的页面。
3.有没有方法可以在url层做validate time 的规范话处理(资源的更新频度,每小时,每天等等)。
Popularity: 3% [?]