天天看點

windows下nginx+php配置

版本 nginx0.8.20    php5.2.10

解壓nginx到C:/web/nginx

解壓php 到C:/web/php

修改配置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;

    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  main;

    sendfile        on;

    #tcp_nopush     on;

    #keepalive_timeout  0;

    keepalive_timeout  65;

    #gzip  on;

    server {

        listen       8080;

        server_name  localhost;

        #charset utf-8;

        #access_log  logs/host.access.log  main;

       location / {

            #root   html;       

            #index  index.html index.htm;

        root    D:/web/www;

        index   index.html index.htm index.php;

        autoindex on; #充許清單目錄

        }

        #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;

        root   D:/web/www/;

           fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            fastcgi_param  SCRIPT_FILENAME  /web/www$fastcgi_script_name;

         include        fastcgi_params;

        index   index.html index.htm index.php;

        }

        # 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;

    #    server_name  localhost;

    #    ssl                  on;

    #    ssl_certificate      cert.pem;

    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;

    #    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;

    #    ssl_prefer_server_ciphers   on;

    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}

}

修改配置php.ini

 enable_dl = On

cgi.force_redirect = 0

cgi.fix_pathinfo=1

fastcgi.impersonate = 1

cgi.rfc2616_headers = 1

extension_dir = "D:/web/php/ext/"

extension=php_gd2.dll

extension=php_mbstring.dll

extension=php_mcrypt.dll

extension=php_msql.dll

extension=php_mysql.dll

extension=php_mysqli.dll

 [Zend]

zend_Optimizer.Optimizerimization_level=1023 ;優化程度,這裡定義啟動多少個優化過程

zend_Optimizer.encoder_loader=0  ;是否允許處理由Zend Encoder加密的PHP檔案;

zend_extension_manager.optimizer_ts="D:/web/ZendOptimizer/Optimizer-3.3.0" ;優化器所在目錄

zend_extension_ts="D:/web/ZendOptimizer/ZendExtensionManager.dll" ;Zend Oprimizer子產品在硬碟上的安裝路徑。

stall.bat:

SET NGINX_PATH=D:

SET NGINX_DIR=D:/web/nginx/

SET PHP_DIR=D:/web/php/

++++++++++++++++++代碼開始++++++++++++++++

cls

@ECHO OFF

SET NGINX_PATH=D:

SET NGINX_DIR=D:/web/nginx/

SET PHP_DIR=D:/web/php/

color 0a

TITLE Nginx+PHP 管理程式

GOTO MENU

:MENU

CLS

ECHO.

ECHO. * * * * * * * Nginx+PHP 管理程式 * * * * * *

ECHO. * *

ECHO. * 1 啟動Nginx *

ECHO. * *

ECHO. * 2 關閉Nginx *

ECHO. * *

ECHO. * 3 重新開機Nginx *

ECHO. * *

ECHO. * 4 啟動php-cgi *

ECHO. * *

ECHO. * 5 關閉php-cgi *

ECHO. * *

ECHO. * 6 重新開機php-cgi *

ECHO. * *

ECHO. * 7 退 出 *

ECHO. * *

ECHO. * * * * * * * * * * * * * * * * * * * * * * * *

ECHO.

ECHO.請輸入選擇項目的序号:

set /p ID=

IF "%id%"=="1" GOTO cmd1

IF "%id%"=="2" GOTO cmd2

IF "%id%"=="3" GOTO cmd3

IF "%id%"=="4" GOTO cmd4

IF "%id%"=="5" GOTO cmd5

IF "%id%"=="6" GOTO cmd6

IF "%id%"=="7" EXIT

PAUSE

:cmd1

ECHO.

ECHO.啟動Nginx......

IF NOT EXIST %NGINX_DIR%nginx.exe ECHO %NGINX_DIR%nginx.exe不存在

%NGINX_PATH%

cd %NGINX_DIR%

IF EXIST %NGINX_DIR%nginx.exe

nginx.exe -c conf/nginx.conf

ECHO.OK

PAUSE

GOTO MENU

:cmd2

ECHO.

ECHO.關閉Nginx......

taskkill /F /IM nginx.exe > nul

ECHO.OK

PAUSE

GOTO MENU

:cmd3

ECHO.

ECHO.關閉Nginx......

taskkill /F /IM nginx.exe > nul

ECHO.OK

GOTO cmd1

GOTO MENU

:cmd4

ECHO.

ECHO.啟動php-cgi......

IF NOT EXIST %PHP_DIR%php-cgi.exe ECHO %PHP_DIR%php-cgi.exe不存在

echo set wscriptObj = CreateObject("Wscript.Shell") >start_fastcgi.vbs

echo wscriptObj.run "%PHP_DIR%php-cgi.exe -b 127.0.0.1:9000",0 >>start_fastcgi.vbs

start_fastcgi.vbs

del start_fastcgi.vbs

ECHO.OK

PAUSE

GOTO MENU

:cmd5

ECHO.

ECHO.關閉php-cgi......

taskkill /F /IM php-cgi.exe > nul

ECHO.OK

PAUSE

GOTO MENU

:cmd6

ECHO.

ECHO.關閉php-cgi......

taskkill /F /IM php-cgi.exe > nul

ECHO.OK

GOTO cmd4

GOTO MENU

一定要開啟 啟動php-cgi

在/var/www的底下建立一個連接配接

通路位址:http://localhost/phpmyadmin/ 出現登入頁面,輸入mysql的使用者名和密碼就可以登陸了

繼續閱讀