nginx配置,配置nginx+apache 其中动态由apache处理,...

--prefix=/usr/local/nginx --sbin-path=/usr/local/sbin/nginx --with-http_gzip_static_module --with-http_stub_status_module --with-md5-asm --with-sha1-asm --with-zlib-asm=pentiumpro --with-http_addition_module --error-log-path=/var/log/nginx/error.log --conf-path=/usr/local/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi
把apache+php+mysql+nginx配置完后,在nginx.conf配额文件server 的下面加上
location ~ (/$|.php|.cgi|.pl) {
proxy_pass http://127.0.0.1:8000;
proxy_read_timeout 600;
proxy_redirect off;
proxy_buffer_size 32k;
proxy_buffers 4 32k;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_set_header Host $host;
proxy_set_header Accept-Encoding none;
proxy_set_header X-Forwarded-For $remote_addr;
}
if (-f $request_filename/index.htm)
{
rewrite (.*) $1/index.htm break;
} 说明:if后面是表示次级域名目录下的index.htm都能正常访问,如果不加的话,次级目录下的index.htm有可能出现403,当然其他的也可以照写,如index.html , index.php 等等
if (-d $request_filename) {
rewrite ^/(.*)([^/])$ $scheme://$host/$1$2/ redirect;
}
就可以了
apache监听的端口是8000 nginx监听的端口是80 其中if后是nginx 目录自动加斜线”/”的语句。如果不加将会出现下列情况
输入 http://192.168.1.16/uc 提示网页载入出错 但是输入 http://192.168.1.16/uc/就能正常访问
Tags:  nginx配置

延伸阅读

最新评论

发表评论