Home > 类库下载 > PHP类库 > Install Nginx+php+mysql environment under Windows

Install Nginx+php+mysql environment under Windows

高洛峰
Release: 2016-10-10 09:27:15
Original
1337 people have browsed it

System: Windows 7 64-bit system

Before installation, first download the software:

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 1: 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 the 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 the Nginx conf file: the directory is D: Nginx+php+Mysqlnginxconf

The file name is: nginx.conf 

1. Remove the # before worker_processes and start a process

2. Add events

3. Set http->set server->support php

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

Test whether nginx is installed successfully

Install Nginx+php+mysql environment under Windows

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 preceding semicolon and then change it to extension_dir = "./ext"

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

Check whether php is installed successfully:

Install Nginx+php+mysql environment under Windows

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

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

set wscriptObj = CreateObject("Wscript.Shell")
wscriptObj.run "php-cgi -b 127.0.0.1:9000",0
Copy after login

Step 5: Create a new startup item: runServer.bat and stop item stopServer.bat

in the D:Nginx+php+Mysql directory

  Enter the startup item runServer.bat:

@echo off
echo Starting nginx...
cd %~dp0nginx
start "" "./nginx.exe"

echo Starting mysql...
net start mysql

echo Starting PHP FastCGI...
cd %~dp0PHP
start "" "php-cgi.vbs"

pause

Exit
Copy after login

Enter the stop item:

@echo off
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
pause
exit
Copy after login

Finally, check whether the startup is successful:

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

Write:

<?php
phpinfo();?>
Copy after login

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

Install Nginx+php+mysql environment under Windows

source:php.cn
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template