WNMP (Windows + Nginx + PHP + MySQL) installation, wnmpnginx

Source: Internet
Author: User

WNMP (Windows + Nginx + PHP + MySQL) installation, wnmpnginx

A new project is being developed recently. The environment uses:

Nginx1.10.3: http://nginx.org/en/download.html Download windows pack

PHP 7.1.1: http://windows.php.net/download/ Download windows Version package

MySQL 5.7.17: https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.17-winx64.zip

PS: Here MySQL is MySQL with WampServer, so it is not installed repeatedly. The specific configuration will be discussed later.

This is WampServer's: https://sourceforge.net/projects/wampserver/

 

After the preparation is complete, the installation starts.

1. Install Nginx

1. Prepare a directory. Here I am E: \ development \ nginx (here, the nginx directory is mainly used to facilitate the expansion of Nginx services of multiple versions in the future)

2. Run nginx.exe under this folder (nginx-1.10.32.16

3. Test whether to start nginx. Open a browser and access http: // localhost or http: // 127.0.0.1 to see if "Welcome to nginx!" is displayed !", It indicates that the startup is successful. If it is not started, check whether port 80 is occupied.

Note: The default directory for this website is in E: \ development \ nginx \ nginx-1.10.3 \ html

Ii. PHP installation

The nginx configuration file is nginx. conf In the conf folder.

1. Create a PHP Directory E: \ development \ php (also in the PHP Directory for future extension convenience)

2. Modify it by about 43rd ~ Between 45 rows

Location/{root E:/proj; here, change it to your own Directory index index.html index.htm ;}

Modify the path of the website file and add the hosts page of index. php.

        location / {            root   E:/Projl;            index  index.html index.htm inde.php;        }

3. Support for php settings

Modify

        # 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  /scripts$fastcgi_script_name;              include        fastcgi_params;        }

Remove "#" And change "root html" to "root E:/Proj", and then change "/scripts" to "$ document_root ", here, "$ document_root" refers to the site path referred to by "root", which is changed.

 

3. Change to php. ini.

Search for "extension_dir" and find: e; xtension_dir = "ext". Go to the semicolon and change it to extension_dir = "C: \ wnmp \ php \ ext"

Search for "date. timezone" and find:; date. timezone = Go To The semicolon before changing it to date. timezone = Asia/Shanghai.

Search "enable_dl" and find: enable_dl = Off TO enable_dl = On.

Search for "cgi. force_redirect"; cgi. force_redirect = 1 first go to the semicolon before changing it to cgi. force_redirect = 0

Search "fastcgi. impersonate" and find:; fastcgi. impersonate = 1. Remove the semicolon from the front.

Search for "cgi. rfc2616_headers" and find:; cgi. rfc2616_headers = 0 first, and then change it to cgi. rfc2616_headers = 1.

Search for "php_mysql" and find: "extension = php_pdo_mysql.dll and extension = php_mysqli.dll to remove the previous"; "extension = php_mysql.dll and extension = php_mysqli.dll (MYSQL database supported)

 

4. Start

1. Delete Nginx in progress and restart

2. php-cgi.exe-B 127.0.0.1: 9000-c

Test phpinfo:

 

5. Set Nginx and PHP as Service Startup

No. It is quite troublesome to start Nginx and PHP like this every time. Next we will set it as service startup.

1. Download RunHiddenConsole: http://www.inbeijing.org/wp-content/uploads/2015/06/RunHiddenConsole.zip

2. Start star. bat

@ Echo offREM in Windows the REM set PHP_FCGI_CHILDREN is invalid = 5REM the maximum number of requests processed by each process, or set it to the Windows environment variable set PHP_FCGI_MAX_REQUESTS = 1000 echo Starting PHP FastCGI... runHiddenConsole E:/development/php/php-7.1.1-nts-Win32-VC14-x64/php-cgi.exe-B 127.0.0.1: 9000-c E:/development/php/php-7.1.1-nts-Win32-VC14-x64/php. ini echo Starting nginx... runHiddenConsole E:/development/nginx/nginx-1.10.3/nginx.exe-p E:/development/nginx/nginx-1.10.3

3. stop. bat stop

@echo offecho Stopping nginx...  taskkill /F /IM nginx.exe > nulecho Stopping PHP FastCGI...taskkill /F /IM php-cgi.exe > nulexit

 

V. Conclusion

Nginx and PHP have been installed. If you want to connect to Mysql, check if the mysqld of the process is started? If you do not enter the mysql/bin directory, execute mysqld to start the mysql service.

You can also run mysqld -- install to set it to start the service.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.