Table of Contents
windows下配置wnmp,windows配置wnmp
Home php教程 php手册 windows下配置wnmp,windows配置wnmp

windows下配置wnmp,windows配置wnmp

Jun 13, 2016 am 08:39 AM
windows Down try Configuration

windows下配置wnmp,windows配置wnmp

最近尝试windows下配置nginx+php+mysql,在这里总结一下。

1、下载windows版本的nginx,官网​下载地址:http://nginx.org/en/download.htm,下载好后解压到D:\wnmp

​2、配置php

​下载windows版本的php,官网下载地址:http://windows.php.net/download/,php将会以cgi的方式运行,解压下载好的php包,到D盘wnmp目录(D:\wnmp),这里把解压出来的文件夹重命名成php5。

进入文件夹修改php.ini-development文件为php.ini​。

打开php.ini,找到以下代码

extension_dir =<span>"</span><span>./ext</span><span>"</span>更改为extension_dir =<span>"</span><span>D:/wnmp/php5/ext</span><span>"</span>。  <br />;extension=php_mysql.dll 去掉分号<br />;extension=php_mysqli.dll 去掉分号(打开数据库动态链接库)
Copy after login

然后把php5目录下的libmysql.dll文件复制到C:\Windows目录下,或者设置环境变量路径也可以,然后找到以下代码

;cgi.fix_pathinfo=0 去掉分号并改为 cgi.fix_pathinfo=<span>1</span>
Copy after login

3、配置nginx

解压后打开conf目录下的nginx.conf文件,找到

        location /<span> {
            root   html;
            index  index.html index.htm;
        }
        #error_page  </span><span>404</span>              /<span>404</span><span>.html;
        # redirect server error pages to the </span><span>static</span> page /<span>50x.html
        #
        error_page   </span><span>500</span> <span>502</span> <span>503</span> <span>504</span>  /<span>50x.html;
        location </span>= /<span>50x.html {
            root   html;
        }
        # proxy the PHP scripts to Apache listening on </span><span>127.0</span>.<span>0.1</span>:<span>80</span><span>
        #
        #location </span>~<span> \.php$ {
        #    proxy_pass   http:</span><span>//</span><span>127.0.0.1;</span>
<span>        #}
        # pass the PHP scripts to FastCGI server listening on </span><span>127.0</span>.<span>0.1</span>:<span>9000</span><span>
        #
        #location </span>~<span> \.php$ {
        #    root           html;
        #    fastcgi_pass   </span><span>127.0</span>.<span>0.1</span>:<span>9000</span><span>;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  </span>/<span>scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}</span>
Copy after login

改为:

        location /<span> {
            root   <span>d:/www</span>;  //自行设置目录
            index  index.html index.htm;
        }
        error_page  </span><span>404</span>              /<span>404</span><span>.html;
         redirect server error pages to the </span><span>static</span> page /<span>50x.html
        #
        error_page   </span><span>500</span> <span>502</span> <span>503</span> <span>504</span>  /<span>50x.html;
        location </span>= /<span>50x.html {
            root   <span>d:/www</span>;
        }
         proxy the PHP scripts to Apache listening on </span><span>127.0</span>.<span>0.1</span>:<span>80</span><span>
        
        location </span>~<span> \.php$ {
            proxy_pass   http:</span><span>//</span><span>127.0.0.1;</span>
<span>        }
         pass the PHP scripts to FastCGI server listening on </span><span>127.0</span>.<span>0.1</span>:<span>9000</span><span>
        
        location </span>~<span> \.php$ {
            root           <span>d:/www</span>;
            fastcgi_pass   </span><span>127.0</span>.<span>0.1</span>:<span>9000</span><span>;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  <span>$document_root</span></span><span>$fastcgi_script_name;
            include        fastcgi_params;
        }</span>
Copy after login

保存配置文件。

4、运行nginx和php

输入命令:

D:\wnmp\php5>php-cgi.exe -b <span>127.0</span>.<span>0.1</span>:<span>9000</span> -c D:/wnmp/php5/php.ini
Copy after login

以cgi的方式运行php,监听nginx从9000端口发来的数据。双击nginx.exe运行nginx。

快捷启动设置:先下载RunHiddenConsole.exe这个文件放入nginx目录中,然后将以下代码保存为start_nginx.bat

<span>@echo off  
</span><span>set</span> php_home=../php5/
<span>set</span> nginx_home=./<span>
echo Starting PHP FastCGI...  
RunHiddenConsole </span>%php_home%/php-cgi.exe -b <span>127.0</span>.<span>0.1</span>:<span>9000</span> -c %php_home%/<span>php.ini  
echo Starting nginx...  
RunHiddenConsole </span>%nginx_home%/nginx.exe -p %nginx_home%<span>
exit</span>
Copy after login

将以下代码保存为stop_nginx.bat

<span>@echo off  
echo Stopping nginx...    
taskkill </span>/F /IM nginx.exe ><span> nul  
echo Stopping PHP FastCGI...  
taskkill </span>/F /IM php-cgi.exe ><span> nul  
exit</span>
Copy after login

最后文件是这样的,双击start_nginx.bat就可以启动nginx和php了。

5、安装配置mysql 下载mysql:http://dev.mysql.com/downloads/mysql/,然后解压到D:/mnmp目录下 在my-default.ini中找到
basedir=<span>C:\Program Files\MySQL\ </span>去掉#<span>(mysql所在目录)<br />datadir</span>=C:\Program Files\MySQL\data 去掉#(mysql所在目录\data)
Copy after login

命令行进入目录:cd C:\Program Files\MySQL\bin,输入以下命令安装mysql:mysqld -install  (安装后可以在服务中找到)

启动服务:net start mysql,关闭服务:net stop mysql 。也可以在服务中启动或者关闭。

添加path变量:在计算机>属性>高级系统中设置>环境变量中添加:F:\phpenv\mysql\bin 登录命令:mysql -h 主机ip -u 用户名 -p 用户密码    
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1268
29
C# Tutorial
1248
24
How to copy and paste mysql How to copy and paste mysql Apr 08, 2025 pm 07:18 PM

Copy and paste in MySQL includes the following steps: select the data, copy with Ctrl C (Windows) or Cmd C (Mac); right-click at the target location, select Paste or use Ctrl V (Windows) or Cmd V (Mac); the copied data is inserted into the target location, or replace existing data (depending on whether the data already exists at the target location).

Can vs code run in Windows 8 Can vs code run in Windows 8 Apr 15, 2025 pm 07:24 PM

VS Code can run on Windows 8, but the experience may not be great. First make sure the system has been updated to the latest patch, then download the VS Code installation package that matches the system architecture and install it as prompted. After installation, be aware that some extensions may be incompatible with Windows 8 and need to look for alternative extensions or use newer Windows systems in a virtual machine. Install the necessary extensions to check whether they work properly. Although VS Code is feasible on Windows 8, it is recommended to upgrade to a newer Windows system for a better development experience and security.

How to run sublime after writing the code How to run sublime after writing the code Apr 16, 2025 am 08:51 AM

There are six ways to run code in Sublime: through hotkeys, menus, build systems, command lines, set default build systems, and custom build commands, and run individual files/projects by right-clicking on projects/files. The build system availability depends on the installation of Sublime Text.

How to solve complex BelongsToThrough relationship problem in Laravel? Use Composer! How to solve complex BelongsToThrough relationship problem in Laravel? Use Composer! Apr 17, 2025 pm 09:54 PM

In Laravel development, dealing with complex model relationships has always been a challenge, especially when it comes to multi-level BelongsToThrough relationships. Recently, I encountered this problem in a project dealing with a multi-level model relationship, where traditional HasManyThrough relationships fail to meet the needs, resulting in data queries becoming complex and inefficient. After some exploration, I found the library staudenmeir/belongs-to-through, which easily installed and solved my troubles through Composer.

Recommended system maintenance and optimization tools in Mac system Recommended system maintenance and optimization tools in Mac system Apr 12, 2025 pm 04:45 PM

Mac system maintenance includes: disk management (use OmniDiskSweeper to clean disk space, use disk tools to check disk errors) memory management (use Activity Monitor to monitor memory usage, end over-occupying processes) startup item management (use Linc or LaunchControl to manage startup items, disable unnecessary startup items) system cache cleaning (use CleanMyMac X or manually clean system cache) software update (timely update system and applications) regular backup (use Time Machine to backup data regularly) good usage habits (not installing applications excessively, cleaning files regularly, and monitoring system logs)

laravel installation code laravel installation code Apr 18, 2025 pm 12:30 PM

To install Laravel, follow these steps in sequence: Install Composer (for macOS/Linux and Windows) Install Laravel Installer Create a new project Start Service Access Application (URL: http://127.0.0.1:8000) Set up the database connection (if required)

vscode cannot install extension vscode cannot install extension Apr 15, 2025 pm 07:18 PM

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

git software installation git software installation Apr 17, 2025 am 11:57 AM

Installing Git software includes the following steps: Download the installation package and run the installation package to verify the installation configuration Git installation Git Bash (Windows only)

See all articles