windows系统服务器配置NGINX+PHP+MYSQL环境

 2022-03-05    581  

windows下配置NGINX+PHP+MYSQL环境

一、准备工作

nginx官网下载http://nginx.org/en/download.html

php官网下载https://windows.php.net/downloads/releases/archives/

Mysql官网下载https://downloads.mysql.com/archives/installer/

这里我准备的是nginx1.18+php5.5+mysql5.6

二、安装nginx+php+mysql

1.安装nginx(参考http://www.77isp.com/post/15.html)

解压nginx-1.18.0.zip到C盘下如:c:/nginx

1.png

打开c:/nginx目录,双击运行nginx.exe

测试nginx是否正常,浏览器访问http://localhost 或 http://127.0.0.1看是不是显示出nginx默认页

2.png

配置nginx启动php

打开nginx配置文件,默认为:C:\nginx\conf\nginx.conf文件

第一处修改大概在43-46行左右

4.png

     location / {
            root   html;
            index  index.html index.htm;
        }

修改为:

     location / {
            root   c:/web;   
            index  index.html index.htm index.php;
        }

注:c:/web即网站目录;添加index.php的默认页。

设置php的支持

第二处修改大概在65-71行左右

5.png

        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

修改为

        location ~ \.php$ {
            root           c:/web;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  c:/web/$fastcgi_script_name;
            include        fastcgi_params;
        }

2.解压php到C盘下如:c:/php(参考1-4部分http://www.77isp.com/post/219.html)

3.png

安装并配置php

C:/php下复制php.ini-development文件,并将文件名改为php.ini,修改php配置文件php.ini,保存即可。

第718行 ; extension_dir = "ext" 先去前面的分号再改为 extension_dir = "D:\php\ext"

p1.png

第910行 ;date.timezone = 先去前面的分号再改为 date.timezone = Asia/Shanghai

p2.png

第728行enable_dl = Off 改为 enable_dl = On

p3.png

第735行 ;cgi.force_redirect = 1 先去前面的分号再改为 cgi.force_redirect = 0

p4.png

第763行 ;fastcgi.impersonate = 1 去掉前面的分号

p5.png

第775行 ;cgi.rfc2616_headers = 0 先去前面的分号再改为 cgi.rfc2616_headers = 1

p6.png

需要什么扩展对应的分号去掉即可

p7.png

注:每个版本的行数基本上都不一致,如对应行数找不到可以直接搜索关键字来修改

运行php

c:\php\php-cgi.exe -b 127.0.0.1:9000 -c c:\php\php.ini

在我们网站目录下新建一个index.php,内容如下

<?php phpinfo();?>

然后访问:http://127.0.0.1/index.php

显示如下页面则配置正常

p8成功.png

3.安装MySQL参考(http://124.222.111.252:8885/post/86.html)http://www.77isp.com/post/222.html

原文链接:http://www.77isp.com/post/223.html

=========================================

http://www.77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。