- 論壇徽章:
- 0
|
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
log_format wwwlogs '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
access_log /var/nginx/logs/wwwlogs.log wwwlogs;
}
server
{
listen 82;
server_name 192.168.6.253;
location / {
stub_status on;
access_log off;
}
}
}
②、在/usr/local/nginx/conf/目錄中創(chuàng)建fcgi.conf文件:
vi /usr/local/nginx/conf/fcgi.conf
輸入以下內(nèi)容:
引用
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;
5、啟動(dòng)Nginx
ulimit -SHn 51200
/usr/local/nginx/sbin/nginx
ZendOptimizer]
tar zxvf ZendOptimizer-3.3.0a-linux-glibc21-i386.tar.gz
cd ZendOptimizer-3.3.0a-linux-glibc21-i386
./install.sh
文字圖形界面-同意安裝協(xié)議-選擇Zend安裝目錄-選擇php.ini所在目錄-不使用apache web server-installing-finished
四、配置開(kāi)機(jī)自動(dòng)啟動(dòng)Nginx + PHP
vi /etc/rc.local
在末尾增加以下內(nèi)容:
引用
ulimit -SHn 51200
/usr/local/webserver/php/sbin/php-fpm start
/usr/local/nginx/sbin/nginx
--------------------------------------------------------------------------------
五、優(yōu)化Linux內(nèi)核參數(shù)
vi /etc/sysctl.conf
在末尾增加以下內(nèi)容:
引用
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 5000 65000
使配置立即生效:
/sbin/sysctl -p
六、在不停止Nginx服務(wù)的情況下平滑變更Nginx配置
1、修改/usr/local/nginx/conf/nginx.conf配置文件后,請(qǐng)執(zhí)行以下命令檢查配置文件是否正確:
/usr/local/nginx/sbin/nginx -t
如果屏幕顯示以下兩行信息,說(shuō)明配置文件正確:
the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
the configuration file /usr/local/nginx/conf/nginx.conf was tested successfully
2、這時(shí),輸入以下命令查看Nginx主進(jìn)程號(hào):
ps -ef | grep "nginx: master process" | grep -v "grep" | awk -F ' ' '{print $2}'
屏幕顯示的即為Nginx主進(jìn)程號(hào),例如:
6302
這時(shí),執(zhí)行以下命令即可使修改過(guò)的Nginx配置文件生效:
kill -HUP 6302
或者無(wú)需這么麻煩,找到Nginx的Pid文件:
kill -HUP `cat /usr/local/nginx/nginx.pid`
七、編寫(xiě)每天定時(shí)切割Nginx日志的腳本
1、創(chuàng)建腳本/usr/local/nginx/sbin/cut_nginx_log.sh
vi /usr/local/nginx/sbin/cut_nginx_log.sh
輸入以下內(nèi)容:
引用
#!/bin/bash
# This script run at 00:00
# The Nginx logs path
logs_path="/usr/local/nginx/logs/"
mkdir -p ${logs_path}$(date -d "yesterday" +"%Y" /$(date -d "yesterday" +"%m" /
mv ${logs_path}access.log ${logs_path}$(date -d "yesterday" +"%Y" /$(date -d "yesterday" +"%m" /access_$(date -d "yesterday" +"%Y%m%d" .log
kill -USR1 `cat /usr/local/nginx/nginx.pid`
2、設(shè)置crontab,每天凌晨00:00切割nginx訪問(wèn)日志
crontab -e
輸入以下內(nèi)容:
引用
00 00 * * * /bin/bash /usr/local/nginx/sbin/cut_nginx_log.sh
pureftp 安裝調(diào)試
(建立pureftp的配置文件目錄)
mkdir /etc/pureftpd
tar xvf pure-ftpd-1.0.21.tar.bz2
cd pure-ftpd-1.0.21
./configure --prefix=/usr/local/pureftpd \
--with-mysql=/usr/local/mysql \
--with-quotas \
--with-cookie \
--with-virtualhosts \
--with-virtualroot \
--with-diraliases \
--with-sysquotas \
--with-ratios \
--with-ftpwho \
--with-altlog \
--with-paranoidmsg \
--with-shadow \
--with-welcomemsg \
--with-throttling \
--with-uploadscript \
--with-pam \
--with-largefile \
--with-peruserlimits \
--without-bonjour \
--with-cork \
--with-sendfile \
--with-privsep \
--with-capabilities \
--with-language=simplified-chinese \
make
make install
cd configuration-file/
chmod u+x pure-config.pl
cp pure-config.pl /usr/local/pureftpd/sbin/
cp pure-ftpd.conf /etc/pureftpd/
從網(wǎng)上下載pureftpd_php_manage,如果找不到,單擊可以加我QQ,問(wèn)我要,注明“龍族”
上傳到/var/www/blog/
編輯pureftp.config.php
設(shè)置$PUREFTP_CONFIG_FILE = '/etc/pure-ftpd/db/pureftpd.conf';
為 $PUREFTP_CONFIG_FILE = '/etc/pureftpd/pure-ftpd.conf';
設(shè)置$FTP_WHO = "/usr/local/sbin/pure-ftpwho";
為$FTP_WHO = "/usr/local/pureftpd/sbin/pure-ftpwho";
設(shè)置 $DefaultUid = "ftpd"; 為你要存放用戶的目錄的所有者的ID或者用戶名
$DefaultGid = "ftpd"; 為你要存放用戶的目錄的組的GID或者組名
這里主要的主要的是,這個(gè)UID和GID必須為發(fā)布apache或者nginix的后臺(tái)運(yùn)行的擁有者
我為這個(gè)問(wèn)題查詢了2天2夜,自己琢磨出來(lái)的,例如上面我設(shè)置的是www賬號(hào)運(yùn)行nginix
我們這樣設(shè)置
usermod -g ftp www
這句話的意思是把WWW放到ftp組里面去
同時(shí)要這樣設(shè)置 chmod 775 /要設(shè)置的FTP目錄
否則會(huì)出現(xiàn)建立賬號(hào),需要手工建立目錄
附mysql的配置文件
DROP TABLE IF EXISTS ftpd;
CREATE TABLE ftpd (
User varchar(16) NOT NULL default '',
status enum('0','1') NOT NULL default '0',
Password varchar(64) NOT NULL default '',
Uid varchar(11) NOT NULL default '-1',
Gid varchar(11) NOT NULL default '-1',
Dir varchar(12 NOT NULL default '',
ULBandwidth smallint(5) NOT NULL default '0',
DLBandwidth smallint(5) NOT NULL default '0',
comment tinytext NOT NULL,
ipaccess varchar(15) NOT NULL default '*',
QuotaSize smallint(5) NOT NULL default '0',
QuotaFiles int(11) NOT NULL default 0,
PRIMARY KEY (User),
UNIQUE KEY User (User)
) TYPE=MyISAM;
本人的QQ:105348557,歡迎大家互相交流!
[ 本帖最后由 zhy1899 于 2009-9-24 12:35 編輯 ] |
|