nginx 使用 logrotate 回滚日志

2009-09-04 15:28  |  分类:应用技术

vi /usr/local/nginx/conf/logrotate.conf

/var/log/nginx/*.log {
    daily
    missingok
    rotate 7
    compress
    delaycompress
    notifempty
    create 640 www-data adm
    sharedscripts
    prerotate
    sleep 59
    endscript
    postrotate
        if [ -f /var/run/nginx.pid ]; then
          kill -USR1 `cat /var/run/nginx.pid`
        fi
    endscript
}

调试:
logrotate -d /usr/local/nginx/conf/logrotate.conf

执行:
logrotate -f /usr/local/nginx/conf/logrotate.conf

定期执行:
vi /etc/crontab
59 23 * * * root logrotate -f /usr/local/nginx/conf/logrotate.conf

在 Debian Nginx 上安装 Nagios 3.2

2009-08-23 22:01  |  分类:应用技术

下载所需软件:
http://www.nagios.org/download/
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.0.tar.gz

创建 nagios 用户和组:
groupadd nagios
useradd -g nagios -d /usr/local/nagios -s /bin/bash nagios

创建一个 nagcmd 组用于从 Web 接口执行外部命令,并将 nagios 用户和 Web 用户都加到这个组中:
groupadd nagcmd
usermod -G nagcmd nagios
usermod -G nagcmd www-data

安装 Nagios:
apt-get install libgd2-xpm-dev
The following NEW packages will be installed:
defoma fontconfig-config libfontconfig1 libfreetype6 libgd2-xpm libjpeg62 libxpm4 ttf-dejavu ttf-dejavu-core ttf-dejavu-extra

tar zxvf nagios-3.2.0.tar.gz
cd nagios-3.2.0
./configure \
--prefix=/usr/local/nagios \
--with-command-group=nagcmd

make all

make install
make install-init
make install-config
make install-commandmode

配置 Nginx 支持 CGI ,然后在 Nginx 添加 Nagios 的配置如下:
全文阅读 »

配置 Nginx 支持 CGI

2009-08-21 18:19  |  分类:应用技术, 程序设计

安装所需的 perl fcgi 模块:
apt-get install libfcgi-perl libfcgi-procmanager-perl

用 perl 写一个 daemon 程序来处理 cgi 文件:
全文阅读 »

在 Debian 上安装 Nginx

2009-08-11 21:35  |  分类:应用技术

安装依赖的包:
apt-get install libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev

下载最新稳定版安装:

wget http://sysoev.ru/nginx/nginx-0.7.61.tar.gz
tar zxvf nginx-0.7.61.tar.gz
cd nginx-0.7.61
./configure \
--user=www-data \
--group=www-data \
--prefix=/usr/local/nginx \
--with-http_stub_status_module

make
make install

全文阅读 »

Nginx PHP FastCGI 安装配置记录

2008-04-18 18:26  |  分类:应用技术

安装 PHP
下载:http://www.php.net/downloads.php
因需要兼容老程序,这里用的还是 PHP4 ,可根据自己的需要更改编译选项。
tar jxvf php-4.4.8.tar.bz2
cd php-4.4.8
./configure \
--prefix=/usr/local/php-fcgi \
--enable-fastcgi \
--enable-discard-path \
--enable-force-cgi-redirect \
--enable-mbstring=all \
--enable-memcache \
--with-config-file-path=/usr/local/php-fcgi/etc \
--with-gd=/usr/local/gd \
--with-zlib \
--with-png \
--with-jpeg \
--with-freetype \
--with-mysql=/usr/local/mysql \
--with-dom
make
make install
cp -f php.ini-dist /usr/local/php-fcgi/etc/php.ini

安装 ZendOptimizer
Zend 的优化器,免费使用,如果加密了 PHP 程序文件,这是必须的。
如果没有使用 Zend 优化器,PHP 进程的内存会难以释放。
下载:http://www.zend.com/en/products/guard/downloads
tar zxvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
cd ZendOptimizer-3.3.3-linux-glibc23-i386
./install
cd ..

安装 eAccelerator
PHP scripts 的缓存,对于提高 PHP 程序执行速度很有帮助。
下载:http://eaccelerator.net/
tar jxvf eaccelerator-0.9.5.2.tar.bz2
cd eaccelerator-0.9.5.2
/usr/local/php-fcgi/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php-fcgi/bin/php-config
make
make install
cd ..

安装 memcache
用于缓存 sql 查询,对于降低数据库压力,提升查询速度有很大好处。
下载:http://pecl.php.net/package/memcache
tar zxvf memcache-2.2.3.tgz
cd memcache-2.2.3
/usr/local/php-fcgi/bin/phpize
./configure --with-php-config=/usr/local/php-fcgi/bin/php-config
make
make install

安装 Linghttpd's spawn-fcgi
用 Lighttpd 的 spawn-fcgi 来管理 PHP FastCGI 进程。
下载 Lighttpd: http://www.lighttpd.net/download
yum -y install pcre-devel
(debian: apt-get -y install libpcre3-dev)
tar zxvf lighttpd-1.4.19.tar.bz2
cd lighttpd-1.4.19
./configure --without-bzip2
make
cp -a src/spawn-fcgi /usr/local/php-fcgi/bin/
全文阅读 »