Home  >  Article  >  Backend Development  >  Install Nginx, PHP, mysql on Windows

Install Nginx, PHP, mysql on Windows

WBOY
WBOYOriginal
2016-07-30 13:30:131105browse

Instructions

Since the machine itself is a Windows x64 system, all x64 software is selected; if you want to choose x86, it is also compatible; if the machine is x86, you can only choose x86 software

Download address

  • nginx
    • http://nginx.org/en/download.html
    • Select version herenginx/Windows-1.9.4
      • nginx-1.9.4.zip
  • php Non-thread safe version
    • http://windows.php.net/download
    • At the same time download the corresponding VC runtime on the left side of the page and install
    • Select herePHP 5.6 VC11 x64 Non Thread Safe
      • php-5.6.12-nts-Win32-VC11-x64.zip
    • Select hereVC11 x64 - Visual C++ Redistributable for Visual Studio 2012 Update 4
      • vcredist_x64.exe
  • RunHiddenConsole
    • http://redmine.lighttpd.net/attachments/660/RunHiddenConsole.zip
      • RunHiddenConsole.zip
  • mysql-installer-community
    • http ://www.mysql.com /downloads/installer/
    • Select here**
      • mysql-installer-community-5.6.26.0.msi
    • You need to install .net framework 4.0.30319, if it is already installed, skip this step) Download Address: http://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe
      And run
    • other components required in CheckRequirements. Manually install it according to the prompts. Double-click auto or wait for the software to download and install. (Tip: The mysql website is available for download) The root password is
    • a123456
    • - This setting can be modified, but the following test code for connecting to the database must also be modified accordinglyIn addition, the server is set to start automatically at boot
  • Installation configuration
nginx

, phpInstall

nginx

Select the software installation directory as
    c:zjc
  1. - This directory can be changed Unzip
  2. nginx-1.9.4.zip
  3. to c: zjcservernginx uses
  4. c:zjcwww
  5. as the website root directory
    modify the configuration file
      c:zjcservernginxconfnginx.conf
    1. location /
    2. under the node root is modified to root c:zjcwww at
    3. c:zjcwww
    4. Create a test webpage index.html
    Double-click to run
  6. :zjcservernginxnginx.exe
  7. , open http://127.0.0.1 in the browser, you can see the webpage just createdYou can stop it
  8. nginx
  9. cd c:zjcservernginx
    nginx.exe -s stop
  10. install
php

unzip
    php-5.6.12-nts-Win32-VC11-x64.zip
  1. to c :zjcserverphpRename
  2. c:zjcserverphpphp.ini-development
  3. to php.ini
  4. Install
vcredist_x64.exe

Just click to install

Install
RunHid denConsole

    RunHiddenConsole.exe
  1. in the RunHiddenConsole.zip package is extracted to the c:zjcserverutils directory
  2. Configuration
nginx

, phpModify

c:zjcserverginx confnginx.conf

modify

<code>    #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;
    #}
</code>

to

<code>    location ~ \.php$ {
    #    root           html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  c:/zjc/www$fastcgi_script_name;
        include        fastcgi_params;
    }
</code>

Start and stop script

    c:zjcsvr_start.bat
  • The content is
    <code>cd server<span>\php</span>
    ..<span>\utils</span><span>\RunHiddenConsole</span>.exe php-cgi.exe -b 127.0.0.1:9000 -c c:/zjc/server/php/php.ini
    cd ..<span>\.</span>.
    cd server<span>\nginx</span>
    ..<span>\utils</span><span>\RunHiddenConsole</span>.exe nginx.exe
    cd ..<span>\.</span>.</code>
    c:zjcsvr_stop.bat
  • The content is
    <code><span>taskkill</span> /F /IM nginx.exe > <span>nul</span><span>taskkill</span> /F /IM php-cgi.exe > <span>nul</span></code>
  • test
nginx

, php

Create file
c:zjcwwwindex.php

, the content is

<code><span><?php</span><span>echo</span> phpinfo();
<span>?></span></code>
Visit
http://127.0.0.1/index.php

, OK Just see the php related information

Installation configuration
mysql

Run
    dotNetFx40_Full_x86_x64.exe
  1. Run
  2. mysql-installer-community-5.6.26.0.msi

  3. Choose
      Server Only
    Modify
  4. c:zjcserverphpphp.ini
  5. to enable php support for mysqlextension_dir = "ext"
    extension=php_mysqli.dll
  6. test
nginx

, php , mysqlNew webpage

c:zjcwwwcheck_mysql.php The content is

<code><span><?php</span><span>$con</span> = mysqli_connect(<span>"localhost"</span>, <span>"root"</span>, <span>"a123456"</span>);
<span>if</span>(!<span>$con</span>) {
    <span>die</span>(<span>'Could not connect: '</span> . mysqli_error());
} <span>else</span> {
    <span>echo</span><span>"Database connected successfully"</span>;
}
mysqli_close(<span>$con</span>);</code>

Restart the server
<code><span>$ </span><span>c:</span><span>$ </span>cd <span>c:</span>\zjc
<span>$ </span>svr_stop.bat
<span>$ </span>svr_start.bat</code>

Visit the webpage

http://127.0.0.1/check_mysql.php

You can see the message of successful connection

Copyright statement: This article is an original article by the blogger , may not be reproduced without the permission of the blogger.

The above introduces the installation of Nginx, PHP, and mysql on Windows, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

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