搜索
首页php教程php手册Windows下安装Nginx+php+mysql环境

系统:Windows 7 64位系统

安装之前,首先下载软件:

Nginx: http://nginx.org/en/download.html

PHP Stable PHP 5.6.26: http://php.net/downloads.php

mysql: http://dev.mysql.com/downloads/utilities/

 

第一步:在D盘建立文件夹Nginx+php+Mysql,路径为:D:\Nginx+php+Mysql

 

第二步:安装Nginx,安装目录为:D:\Nginx+php+Mysql\nginx

  1.打开D:\Nginx+php+Mysql\nginx目录,运行该文件夹下的nginx.exe

  2.测试是否启动nginx。打开浏览器访问http://localhost 或 http://127.0.0.1,看看是否出现“Welcome to nginx!”,出现的证明已经启动成功了。

若启动不成功,查看是否端口被占用。

    安装PHP,安装目录为:D:\Nginx+php+Mysql\php

    安装mySQL,安装目录为: D:\Nginx+php+Mysql\mysql

 

第三步:修改Nginx的conf文件:目录为D:\Nginx+php+Mysql\nginx\conf

文件名为:nginx.conf 

1. 去掉worker_processes前的#号,开启一个进程

2. 添加events

3. 设置http->设置server->支持php

<span style="color: #000000;">#user  nobody;
worker_processes  </span><span style="color: #800080;">1</span><span style="color: #000000;">;
#error_log  logs</span>/<span style="color: #000000;">error.log;
#error_log  logs</span>/<span style="color: #000000;">error.log  notice;
#error_log  logs</span>/<span style="color: #000000;">error.log  info;
#pid        logs</span>/<span style="color: #000000;">nginx.pid;
events {
    worker_connections  </span><span style="color: #800080;">1024</span><span style="color: #000000;">;
}
http {
    include       mime.types;
    default_type  application</span>/octet-<span style="color: #000000;">stream;
    #log_format  main  </span><span style="color: #800000;">'</span><span style="color: #800000;">$remote_addr - $remote_user [$time_local] "$request" </span><span style="color: #800000;">'</span><span style="color: #000000;">
    #                  </span><span style="color: #800000;">'</span><span style="color: #800000;">$status $body_bytes_sent "$http_referer" </span><span style="color: #800000;">'</span><span style="color: #000000;">
    #                  </span><span style="color: #800000;">'</span><span style="color: #800000;">"$http_user_agent" "$http_x_forwarded_for"</span><span style="color: #800000;">'</span><span style="color: #000000;">;
    #access_log  logs</span>/<span style="color: #000000;">access.log  main;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  </span><span style="color: #800080;">0</span><span style="color: #000000;">;
    keepalive_timeout  </span><span style="color: #800080;">65</span><span style="color: #000000;">;
    #gzip  on;
    server {
        listen       </span><span style="color: #800080;">80</span><span style="color: #000000;">;
        server_name  localhost;
        #charset koi8</span>-<span style="color: #000000;">r;
        #access_log  logs</span>/<span style="color: #000000;">host.access.log  main;
        location </span>/<span style="color: #000000;"> {
            root d:</span>/Nginx+php+Mysql/nginx/<span style="color: #000000;">html;
            index  index.html index.htm;
        }</span><span style="color: #000000;">
        error_page   </span><span style="color: #800080;">500</span> <span style="color: #800080;">502</span> <span style="color: #800080;">503</span> <span style="color: #800080;">504</span>  /<span style="color: #000000;">50x.html;
        location </span>= /<span style="color: #000000;">50x.html {
            root   html;
        }</span><span style="color: #000000;">
        # pass the PHP scripts to FastCGI server listening on </span><span style="color: #800080;">127.0</span>.<span style="color: #800080;">0.1</span>:<span style="color: #800080;">9000</span><span style="color: #000000;">
        #
        location </span>~<span style="color: #000000;"> \.php$ {
            root           html;
            fastcgi_pass   </span><span style="color: #800080;">127.0</span>.<span style="color: #800080;">0.1</span>:<span style="color: #800080;">9000</span><span style="color: #000000;">;
            fastcgi_index  index.php;
            fastcgi_param     SCRIPT_FILENAME    $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }</span><span style="color: #000000;">
    }
}</span>

  测试nginx是否安装成功

第四步:修改php下php.ini-development文件,将文件名修改为php.ini,找开php.ini:

  搜索“extension_dir”,找到extension_dir = "ext" 先去前面的分号再改为 extension_dir = "./ext"

   搜索“php_mysql”,找到:”extension=php_mysql.dll和extension=php_mysqli.dll  去掉前面的“;”extension=php_mysql.dll和extension=php_mysqli.dll   (支持MYSQL数据库)

  查看php是否安装成功:

第四步:在php目录下新建文件php-cgi.vbs,用php-cgi.vbs文件启动php-cgi:

打开php-cgi.vbs,写入启动编码:

<span style="color: #0000ff;">set</span> wscriptObj = CreateObject(<span style="color: #800000;">"</span><span style="color: #800000;">Wscript.Shell</span><span style="color: #800000;">"</span><span style="color: #000000;">)
wscriptObj.run </span><span style="color: #800000;">"</span><span style="color: #800000;">php-cgi -b 127.0.0.1:9000</span><span style="color: #800000;">"</span>,<span style="color: #800080;">0</span>

第五步:在D:\Nginx+php+Mysql目录下新建启动项:runServer.bat和停止项stopServer.bat

  在启动项runServer.bat中输入:

<span style="color: #000000;">@echo off
echo Starting nginx...
cd </span>%~<span style="color: #000000;">dp0nginx
start </span><span style="color: #800000;">""</span> <span style="color: #800000;">"</span><span style="color: #800000;">./nginx.exe</span><span style="color: #800000;">"</span><span style="color: #000000;">

echo Starting mysql...
net start mysql

echo Starting PHP FastCGI...
cd </span>%~<span style="color: #000000;">dp0PHP
start </span><span style="color: #800000;">""</span> <span style="color: #800000;">"</span><span style="color: #800000;">php-cgi.vbs</span><span style="color: #800000;">"</span><span style="color: #000000;">

pause

Exit</span>

  在停止项中输入:

<span style="color: #000000;">@echo off
echo Stopping nginx...
taskkill </span>/F /IM nginx.exe ><span style="color: #000000;"> nul
echo Stopping PHP FastCGI...
taskkill </span>/F /IM php-cgi.exe ><span style="color: #000000;"> nul
echo Stopping mysql...
net stop mysql
pause
exit</span>

最后,查看是否启动成功:

  在nginx的html目录下D:\Nginx+php+Mysql\nginx\html,新建phpinfo.php

写入:

<span style="color: #000000;">php
phpinfo();
</span>?> 

在浏览器中输入phpinfo.php的路径,查看是否配置成功:

 

 

 

 

    

 

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
2 周前By尊渡假赌尊渡假赌尊渡假赌
仓库:如何复兴队友
4 周前By尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒险:如何获得巨型种子
4 周前By尊渡假赌尊渡假赌尊渡假赌

热工具

mPDF

mPDF

mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

SublimeText3 英文版

SublimeText3 英文版

推荐:为Win版本,支持代码提示!

Dreamweaver Mac版

Dreamweaver Mac版

视觉化网页开发工具

Atom编辑器mac版下载

Atom编辑器mac版下载

最流行的的开源编辑器

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境