search
Homephp教程php手册Install Nginx+php+mysql environment under Windows

System: Windows 7 64-bit system

Before installation, download the software first:

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/

Step one: Create the folder Nginx+php+Mysql on the D drive, the path is: D:Nginx+php+Mysql

Step 2: Install Nginx, the installation directory is: D:Nginx+php+Mysqlnginx

 1. Open the D:Nginx+php+Mysqlnginx directory and run nginx.exe in this folder

 2. Test whether nginx is started. Open the browser and visit http://localhost or http://127.0.0.1 and see if "Welcome to nginx!" appears. The appearance proves that the startup has been successful.

If the startup fails, check whether the port is occupied.

  Install PHP, the installation directory is: D:Nginx+php+Mysqlphp

  Install mySQL, the installation directory is: D:Nginx+php+Mysqlmysql

Step 3: Modify Nginx’s conf file: the directory is D:Nginx+php+Mysqlnginxconf

File name: nginx.conf 

1. Remove the # before worker_processes and start a process

2. Add events

3. Set http->set server->support 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>

Test whether nginx is installed successfully

Step 4: Modify the php.ini-development file under php, change the file name to php.ini, and find php.ini:

 Search for "extension_dir" and find extension_dir = "ext". First remove the semicolon in front and change it to extension_dir = "./ext"

Search for "php_mysql" and find: "extension=php_mysql.dll and extension=php_mysqli.dll. Remove the ";" extension=php_mysql.dll and extension=php_mysqli.dll (supports MYSQL database)

Check whether php is installed successfully:

Step 4: Create a new file php-cgi.vbs in the php directory and start php-cgi with the php-cgi.vbs file:

Open php-cgi.vbs and write the startup code:

<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>

Step 5: Create new startup items in the D:Nginx+php+Mysql directory: runServer.bat and stop items stopServer.bat

In the startup item runServer.bat, enter:

<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>

 Enter in the stop field:

<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>

Finally, check whether the startup is successful:

In the html directory of nginx, D:Nginx+php+Mysqlnginxhtml, create a new phpinfo.php

Write:

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

Enter the path to phpinfo.php in the browser to check whether the configuration is successful:

  

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

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

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.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),