nginx实例配置过程:
直接从网络上下载rpm安装包:nginx-0.6.39-4.el4.i386.rpm
直接安装 rpm -ivh nginx-0.6.39-4.el4.i386.rpm 在RHEL4.0可以直接安装,无需其他安装包依赖
然后是配置/etc/nginx/nginx.conf
具体配置内容:
user www www; #用户 用户组
worker_processes 2; #这里根据CPU个数设置,但是可以实际的多一些
error_log /var/log/nginx/error.log; #这个是日志的位置
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid; #这个默认就可以
events {
worker_connections 2048; #可以设置稍微大一些 1024的倍数
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main ''$remote_addr - $remote_user [$time_local] $request ''
''"$status" $body_bytes_sent "$http_referer" ''
''"$http_user_agent" "$http_x_forwarded_for"'';
access_log /var/log/nginx/logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 8080; #这里是监听端口
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /var/www/html/; #这里是网站服务器的根目录,记得如果测试,请在该目录下面touch index.html 生成一个index.html 文件
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ .php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .php$ { #这里是通过fastcgi来为NGINX开始php服务功能
root /var/www/html/; #设置目录
fastcgi_pass 127.0.0.1:9000; #设置监听端口
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache''s document root
# concurs with nginx''s one
#
#location ~ /.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
|