win下nginx+php7+mysql配置

#下载安装包
#Nginx
1、网址:http://nginx.org/en/download.html
2、下载Stable version下面的:nginx/Windows-1.14.0
win下nginx+php7+mysql配置

#php
1、网址:https://windows.php.net/download#php-7.2
2、下载VC15 x64 Non Thread Safe下面的:Zip[24.31MB]
win下nginx+php7+mysql配置

#mysql
1、网址:https://dev.mysql.com/downloads/mysql/5.7.html#downloads
2、下载Windows (x86, 64-bit), ZIP Archive
3、安装过程教程:https://www.cnblogs.com/chenyucong/p/5712755.html
win下nginx+php7+mysql配置

#把下载好的安装包,全部放到同一个文件夹里面并解压,并且改名;同时创建www文件夹,里面写一个index.php文件;内容为:

<?php phpinfo(); ?>

win下nginx+php7+mysql配置
#nginx安装和配置
1、我在这里创建 D:/wnmp/www 作为我服务器的根目录
2、用文本编辑器打开:D:\xnmp\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;
    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       80;
        #这里!!
        server_name  127.0.0.1;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
           #这里!!
            root   D:/xnmp/www;
            index  index.html index.htm index.php;
        }

        #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           D:/xnmp/www;
            fastcgi_pass   127.0.0.1:9000;
            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;
    #    }
    #}

}

3、保存配置文件

#php安装与配置
1、将D:\xnmp\php7下的php.ini-recommended文件复制一份并改名为php.ini
2、用文本编辑器将它打开php.ini
3、将;extension_dir = "ext"改为extension_dir = “D:\wnmp\php7\ext”
4、添加这两行
extension=php_mysqli.dll
extension=php_pdo_mysql.dll
win下nginx+php7+mysql配置
5、将;cgi.fix_pathinfo=1去掉前面“;”:cgi.fix_pathinfo=1

#运行
1、命令行php目录下键入 php-cgi.exe -b 127.0.0.1:9000 -c D:/wnmp/php7/php.ini;然后不要关闭窗口
2、命令行nginx目录下键入start nginx
3、打开浏览器输入:127.0.0.1
win下nginx+php7+mysql配置
4、安装成功