windows下nginx+php配置

本文介绍如何配置Nginx 0.8.20与PHP 5.2.10进行集成部署,包括设置Nginx监听端口、指定网站根目录、启用PHP FastCGI等关键步骤。

版本 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的底下新建一个连接

sudo ln -s /usr/share/phpmyadmin

访问地址:http://localhost/phpmyadmin/ 出现登录页面,输入mysql的用户名和密码就可以登陆了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值