search
HomeBackend DevelopmentPHP Tutorialphp环境搭建-WNMP(Win7+NGINX+MYSQL+PHP)

【引言】


    php开发环境对于每个phper来说,应该像呼吸一样,不应该是很困难的事。下面我教大家怎么搭建php环境,也是我自己的一个总结,希望能和大家一起提高。(希望大家不吝分享,不要藏私哦)


【准备工作】


    准备工作开始,首先查看自己电脑是多少位的操作系统(不会问度娘),我的电脑是64位Win7操作系统,我就以64位为例

    php版本:php-5.6.15-Win32-VC11-x64.zip   php下载地址

    nginx版 :nginx-1.8.0.zip                               nginx1.80下载地址

    mysql版:mysql-5.6.27-winx64.zip                mysql下载地址

    建立环境目录,个人喜欢把环境的东西放在D盘,所以在D盘目录下建立"wnmp",目录里面分别建四个文件夹 1.mysql  2.nginx3.web  4.php


【安装环境】


    1.nginx

        把下载好的nginx-1.8.0.zip,解压缩到 D:\wamp\nginx

    2.php

         下载好的php-5.6.15-Win32-VC11-x64.zip,解压缩到 D:\wamp\php

    3.mysql

        把下载好的php-5.6.15-Win32-VC11-x64.zip解压缩到 D:\wamp\mysql

【配置环境】

    1.php配置

        改天再整理

    2.nginx配置

          改天再整理

    3.mysql免安装版配置

        解压缩php-5.6.15-Win32-VC11-x64.zip到d:/wamp/mysql

        将解压目录下默认文件 my-default.ini 拷贝一份,改名 my.ini 并复制下面的信息到my.ini

****************************************************************************************************************************************

        [client]
        port=3306
        default-character-set=utf8
        [mysqld]
        port=3306
        character_set_server=utf8
        basedir=D:\wamp\mysql
        #解压目录
        datadir=D:\wamp\mysql\data
        #解压目录下data目录
        sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
        [WinMySQLAdmin]
        D:\wamp\mysql\bin\mysqld.exe        

*****************************************************************************************************************************************

    4. 添加环境变量

        操作如下:
        1)右键单击我的电脑->属性->高级系统设置(高级)->环境变量
          点击系统变量下的新建按钮
          输入变量名:MYSQL_HOME
          输入变量值:D:\wnmp\mysql
          #即为mysql的自定义解压目录。
        2)选择系统变量中的Path
          点击编辑按钮
          在变量值中添加变量值:%MYSQL_HOME%\bin
          注意是在原有变量值后面加上这个变量,用;隔开,不能删除原来的变量值,

    5.  运行cmd进入D:/wamp/mysql/bin  安装mysql系统服务,安装成功后会提示服务安装成功。

         安装服务命令:mysqld install MySQL --defaults-file="D:\wnmp\mysql\my.ini" 

         #移除服务命令为:mysqld remove

【启动环境】

      1.创建文件 start_gbk_server.bat

        @echo off & title 启动Nginx服务器
        color 0A
        REM Windows 下无效
        REM set PHP_FCGI_CHILDREN=5
        call stop_server.bat
        REM 每个进程处理的最大请求数,或设置为 Windows 环境变量
        set PHP_FCGI_MAX_REQUESTS=1000
        echo 启动 php-5.4.19 FastCGI ...
        RunHiddenConsole.exe D:/wnmp/php/php-cgi.exe -b 127.0.0.1:9000 -c "D:/wnmp/php/php.ini"
        echo 启动 Nginx 1.6.3
        RunHiddenConsole.exe  D:/wnmp/nginx/nginx.exe -p D:/wnmp/nginx
        echo 启动 Mysql 5.6
        RunHiddenConsole.exe  net start mysql
        echo 启动完成... 

    2.创建文件stop_bgk_server.bat

        @echo off & title Nginx
        color 0A
        echo Stopping Nginx...  
        taskkill /F /IM nginx.exe > nul
        echo Stopping PHP FastCGI...
        taskkill /F /IM php-cgi.exe > nul
        echo Stopping Mysql
        net stop mysql

【测试环境】

    在D:/wnmp/web目录下建index.php  内容如下:

    

            phpinfo();

     ?>

    在C:\Windows\System32\drivers\etc 西面找到hosts文件用记事本打开 然后写上如下hosts:
    # localhost name resolution is handled within DNS itself.
    127.0.0.1       localhost
    #    ::1             localhost
    127.0.0.1     www.example.com

    在浏览器中打开 www.example.com如果出现如下图证明php环境搭建成功,如果不成功再调试

   


Statement
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
PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

How to make PHP applications fasterHow to make PHP applications fasterMay 12, 2025 am 12:12 AM

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

PHP Performance Optimization Checklist: Improve Speed NowPHP Performance Optimization Checklist: Improve Speed NowMay 12, 2025 am 12:07 AM

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

PHP Dependency Injection: Improve Code TestabilityPHP Dependency Injection: Improve Code TestabilityMay 12, 2025 am 12:03 AM

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

PHP Performance Optimization: Database Query OptimizationPHP Performance Optimization: Database Query OptimizationMay 12, 2025 am 12:02 AM

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi

See all articles

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 Article

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft