用的是Nginx0.8.8 windows版本,PHP用的是5.2.10,Mysql用的是5.1.36.
配置时尽量不要用太复杂的目录结构,我把PHP和Mysql都放在Nginx目录下,将Nginx放在D盘根目录,形成
D:Nginx
|----php
|----mysql
|----conf
|----www
|----logs
|----tmp
|----nginx.exe
修改conf下的nginx.conf文件进行配置:
worker_processes 1;
error_log /nginx/logs/error.log crit;
pid /nginx/logs/nginx.pid;
events {
worker_connections 64;
}
http {
include /nginx/conf/mime.types;
default_type application/octet-stream;
#charset gb2312;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
keepalive_timeout 60;
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 on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
server {
listen 81;
server_name localhost;
index index.html index.htm index.php;
root www;
autoindex on;
location ~ .*.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
include /nginx/conf/fastcgi_params;
}
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 /nginx/logs/access.log access;
}
}
为了方便启动服务,又拷贝了RunHiddenConsole.exe(后台运行控制台程序)和Process.exe(杀进程)文件在Nginx目录下,再编两个批处理文件:
start.cmd
@echo off
ecaho Start Nginx...
RunHiddenConsole.exe nginx.exe -c confnginx.conf
echo Start PHP-Cgi(Fastcgi)...
RunHiddenConsole.exe phpphp-cgi.exe -b 127.0.0.1:9000 -c phpphp.ini
echo Start MySQL...
mysqlbinmysqld.exe --install MySQL_Oscar --defaults-file="mysqlbinmy.ini"
net start MySQL_Oscar
exit
stop.cmd
@echo off
echo stop Nginx......
process.exe -k nginx.exe>nul
process.exe -k nginx.exe>nul
echo Stop PHP(FastCGI)......
process.exe -k php-cgi.exe>nul
net stop MySQL_OSCAR
mysqlbinmysqld.exe --remove MySQL_OSCAR
process.exe -k mysqld.exe>nul
echo Nginx+PHP+MySQL stopped.
pause
exit
这里用process两次次杀nginx.exe进程(因为它会建立两个进程)。注意这两个批处理文件和nginx.exe最好放在同一个目录下,否则指定复杂目录时会碰到一些问题,也不是特别清楚原因,但肯定是路径引起的,因为nginx0.8.8版本是一定使用logs文件的,路径不对就会报无法找到logs.err之类的错误而无法启动服务。
好了,运行调试程序开始,对它的使用经历也展开喽~~
日新月异的技术,日渐苍老的岁月啊!唉