windows安装nginx+php(多版本)

目录如下:

windows安装nginx+php(多版本)_第1张图片

windows安装nginx+php(多版本)_第2张图片

windows安装nginx+php(多版本)_第3张图片

windows安装nginx+php(多版本)_第4张图片

start_nginx.bat的内容是:

@echo off
REM Windows 下无效
REM set PHP_FCGI_CHILDREN=9

REM 每个进程处理的最大请求数,或设置为 Windows 环境变量
set PHP_FCGI_MAX_REQUESTS=1000

echo Starting PHP FastCGI...
RunHiddenConsole D:/wnmp/php7.1/php-cgi.exe -b 127.0.0.1:9000 -c D:/wnmp/php7.1/php.ini
echo Starting PHP FastCGI...
RunHiddenConsole D:/wnmp/php7.1/php-cgi.exe -b 127.0.0.1:9001 -c D:/wnmp/php7.1/php.ini
echo Starting PHP FastCGI...
RunHiddenConsole D:/wnmp/php7.1/php-cgi.exe -b 127.0.0.1:9002 -c D:/wnmp/php7.1/php.ini
echo Starting PHP FastCGI...
RunHiddenConsole D:/wnmp/php7.1/php-cgi.exe -b 127.0.0.1:9003 -c D:/wnmp/php7.1/php.ini

echo Starting PHP FastCGI...
RunHiddenConsole D:/wnmp/php7.1/php-cgi.exe -b 127.0.0.1:9004 -c D:/wnmp/php7.1/php.ini

echo Starting PHP FastCGI...
RunHiddenConsole D:/wnmp/php7.1/php-cgi.exe -b 127.0.0.1:9005 -c D:/wnmp/php7.1/php.ini

echo Starting PHP FastCGI...
RunHiddenConsole D:/wnmp/php7.1/php-cgi.exe -b 127.0.0.1:9006 -c D:/wnmp/php7.1/php.ini

echo Starting PHP FastCGI...
RunHiddenConsole D:/wnmp/php7.1/php-cgi.exe -b 127.0.0.1:9007 -c D:/wnmp/php7.1/php.ini

echo Starting nginx...
RunHiddenConsole D:/wnmp/nginx/nginx.exe -p D:/wnmp/nginx

 

start_nginx_5.6.bat的内容是:

@echo off
REM Windows 下无效
REM set PHP_FCGI_CHILDREN=9

REM 每个进程处理的最大请求数,或设置为 Windows 环境变量
set PHP_FCGI_MAX_REQUESTS=1000
 
echo Starting PHP FastCGI...
RunHiddenConsole D:/wnmp/php5.6/php-cgi.exe -b 127.0.0.1:9000 -c D:/wnmp/php5.6/php.ini
echo Starting PHP FastCGI...
RunHiddenConsole D:/wnmp/php5.6/php-cgi.exe -b 127.0.0.1:9001 -c D:/wnmp/php5.6/php.ini
echo Starting PHP FastCGI...
RunHiddenConsole D:/wnmp/php5.6/php-cgi.exe -b 127.0.0.1:9002 -c D:/wnmp/php5.6/php.ini
echo Starting PHP FastCGI...
RunHiddenConsole D:/wnmp/php5.6/php-cgi.exe -b 127.0.0.1:9003 -c D:/wnmp/php5.6/php.ini

echo Starting PHP FastCGI...
RunHiddenConsole D:/wnmp/php5.6/php-cgi.exe -b 127.0.0.1:9004 -c D:/wnmp/php5.6/php.ini

echo Starting PHP FastCGI...
RunHiddenConsole D:/wnmp/php5.6/php-cgi.exe -b 127.0.0.1:9005 -c D:/wnmp/php5.6/php.ini

echo Starting PHP FastCGI...
RunHiddenConsole D:/wnmp/php5.6/php-cgi.exe -b 127.0.0.1:9006 -c D:/wnmp/php5.6/php.ini

echo Starting PHP FastCGI...
RunHiddenConsole D:/wnmp/php5.6/php-cgi.exe -b 127.0.0.1:9007 -c D:/wnmp/php5.6/php.ini

echo Starting nginx...
RunHiddenConsole D:/wnmp/nginx/nginx.exe -p D:/wnmp/nginx

stop_nginx.bat内容如下:

@echo off
echo Stopping nginx...  
taskkill /F /IM nginx.exe > nul
echo Stopping PHP FastCGI...
taskkill /F /IM php-cgi.exe > nul
exit

D:/wnmp/nginx/conf下面的nginx.conf的内容是:


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    client_max_body_size 20m;
    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  logs/access.log  ;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #添加这行的原因是如果每次只能访问一个文件,比如在vv.juhe.cn下面访问了test.php
    #就不能再访问test2.php,可以在test.php文件里面sleep(10)就可以知道访问test2.php
    #必须在test.php访问结束了才能进行,在网上找到了这段描述,加在http模块里面,同时将
    #fastcgi_pass   127.0.0.1:9000;改为了fastcgi_pass phpfastcgi_proxy;


    upstream phpfastcgi_proxy {
        server 127.0.0.1:9000;
        server 127.0.0.1:9001;
        server 127.0.0.1:9002;
        server 127.0.0.1:9003;
        server 127.0.0.1:9004;
        server 127.0.0.1:9005;
        server 127.0.0.1:9006;
        server 127.0.0.1:9007;

            # 或更多……
    }
    server {
        listen       80;
        server_name  localhost;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        root   D:/wnmp/www;
        location / {

            index  index.php 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$ {
            #root           html;
            #fastcgi_pass   127.0.0.1:9000;
            fastcgi_pass phpfastcgi_proxy;

            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$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
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
    include vhost/*.conf; #配置虚拟主机
}

vhost下面的(可以有多个,每个虚拟域名下面配置一个文件)某个虚拟主机的配置如下:

server {

        listen       80;
        server_name  mac.czt.baidu.com; #可添加多个,多个之间“空格”分开
        root           D:/wnmp/www/czt.baidu.cn/public;


        location / {
            index  index.html index.php index.htm;
             if (!-e $request_filename) {
                         rewrite ^/(.+)$ /index.php?s=$1 last;
                    }

        }
        #autoindex on;#打开目录浏览,这样当没有找到index文件,就也已浏览目录中的文件
        location ~ \.php$ {
            #fastcgi_pass   127.0.0.1:9003;
            fastcgi_pass phpfastcgi_proxy;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }

可以根据需要启动不同的php版本

你可能感兴趣的:(php,nginx)