windows+nginx+mongodb+php Configuration

Source: Internet
Author: User
Tags mongodb download php website vc9

Used to configure only Nginx or only MongoDB, now combine them with PHP to build a development environment on the Windows platform.


The first step: the installation and configuration of PHP
PHP website to download PHP, as to how to install, do not say in detail, the following will say configuration (believe that reading this article, since there is time and energy to study the installation of windows+nginx+mongodb+php,php is a vegetable), but to remind you that the point is, Do not download php5.4 above, because the back of PHP load MongoDB, MongoDB temporarily does not correspond to the php5.4 version of the driver, in addition, Nginx PHP is operating in a fastcgi way, so we download the thread-safe is nts PHP package.
Configure PHP: Found in PHP configuration file:

Extension_dir = "./ext"

To

Extension_dir = "C:/wnmp/php/ext"

Keep looking down and find:

; Extension=php_mysql.dll
; Extension=php_mysqli.dll.

Selectively open the function you want PHP to support, just remove the front semicolon

Next, configure PHP to combine with Nginx

Found in the PHP configuration file:

; cgi.fix_pathinfo=1
Remove the preceding semicolon and replace it with the following:

Cgi.fix_pathinfo=1

Step Two: Installation and configuration of Nginx

First to the official website download the latest version of the Nginx, extract into the C-disk Wnmp directory, and renamed to Nginx. Next, we'll configure Nginx to work with PHP. Enter Nginx's conf directory, open nginx configuration file nginx.conf, find

Location/{
      root   html; #这里是站点的根目录
      index  index.html index.htm
}
Change root HTML to root d:/wnmp/www;

Keep looking down and find:

# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
#    root           htm l;
#    Fastcgi_pass   127.0.0.1:9000;
#    Fastcgi_index  index.php;
#    Fastcgi_param  script_filename  /scripts$fastcgi_script_name;
#    include        fastcgi_params;
#}
First, remove the previous "#" and also change the root HTML to root c:/wnmp/www (the WWW folder needs to be established at this point). Then the marked red/scripts changed to "$document _root", where the "$document _root" refers to the previous "root" refers to the site path, which is changed after:

# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
Location ~ \.php$ {
      root           d:/wnmp/ww W;
      Fastcgi_pass   127.0.0.1:9000;
      Fastcgi_index  index.php;
      Fastcgi_param  script_filename  $document _root$fastcgi_script_name;
      Include        fastcgi_params;
}
Save the configuration file and it's OK. nginx+php environment on the preliminary configuration well, run a look. We can enter the command:
C:\wnmp\php\php-cgi.exe-b 127.0.0.1:9000-c C:/wnmp/php/php.ini

To start PHP, and manually start Nginx, of course, you can also use the script to implement.

In fact, here has basically completed the configuration of the Php+nginx, but today when you configure the following problem, if you also encountered such a problem, you can refer to, if not, you can skip this part

Screenshot of question:

Then the search from Baidu, some netizens have encountered the same problem, the solution is as follows:

1, you can download the Msvcr110.dll (file download address: http://download.csdn.net/detail/zhang342789912/6539739) Copy to the specified directory can ( It is generally the system directory or in the software sibling directory, or the file reference is added again.
2, first download the file to extract, and then according to your system of choice X86/x64,x86 32-bit computer, X64 64-bit computer. The default is to support 32-bit systems, if you don't know if it's X86 or X64
3, according to the software situation to select the file version. This step is more complex, if it is a Windows DLL file,
The version number begins with 5.0 or contains an NT file that is generally windows2000.
The version number that starts with 5.1 or contains XP, XPSP1, XPSP2, xpsp3 information is typically a Windows XP file.
The version number that starts with 6.0 or contains Longhorn, Vista information is generally a WindowsVista file.
The version number that begins with 6.1 or contains win7 information is generally a windows7 file. If you are not a Windows DLL file, you need to be flexible about the version number, description, information provided by the user, and the version number of the associated DLL.
4, directly copy the file to the system directory:
A, Windows 95/98/me system, copy Msvcr110.dll to C:\Windows\System directory.
B, Windows nt/2000 system, copy Msvcr110.dll to C:\WINNT\System32 directory.
C, Windows xp/win7/vista system, copy Msvcr110.dll to C:\Windows\System32 directory.

D, if your system is 64-bit, please copy the file to the C:\Windows\SysWOW64 directory

Step three: Download Runhiddenconsole.zip address: http://download.csdn.net/detail/zhang342789912/6540035

First of all, the download of the Runhiddenconsole.zip package into the Nginx directory, RunHiddenConsole.exe is the role of the command line after the execution of the script can automatically close the script, and the process opened from the script is not closed. Then to create the script, named "Start_nginx.bat," we'll edit it in notepad++.

@echo
off rem windows invalid
rem set php_fcgi_children=5

REM The maximum number of requests processed per process, or set to Windows environment variable
set Php_fcgi_ max_requests=1000
 
Echo starting PHP FastCGI
... Runhiddenconsole c:/wnmp/php/php-cgi.exe-b 127.0.0.1:9000-c C:/wnmp/php/php.ini
 
echo Starting nginx ...
Runhiddenconsole c:/wnmp/nginx/nginx.exe-p C:/wnmp/nginx

Create another script named Stop_nginx.bat to close the Nginx

@echo off
echo stopping Nginx  
... taskkill/f/im nginx.exe > Nul
echo stopping PHP FastCGI ...
taskkill/f/im php-cgi.exe > Nul
exit
When Nginx is configured, the directory structure is probably like this:

In this way, our service scripts are also created. Double-click Start_nginx.bat to see if the process Manager will find two nginx.exe processes and a php-cgi.exe process

Fourth step: Download and installation of MongoDB

MongoDB Download and installation some time ago I have written, you can refer to the http://blog.csdn.net/zhang342789912/article/details/9930973

Download and install a good MongoDB can be configured MongoDB, is PHP support MongoDB the

First, download the MONGO PHP driver, download the address: http://download.csdn.net/detail/zhang342789912/6540095

A, determine your own PHP version (Phpinfo () function can list your PHP version)
B. Select the appropriate version (not thread safe) in accordance with thread safety, if the Apache server chooses thread-safe, and if it is a CGI operation it is not thread-safe.
c, determine your own operating system version. (64 of the words are 64-bit operating systems, no 32-bit)

Like what:
Php_mongo-1.3.0rc3-5.4-vc9-nts-x86_64.dll said:
PHP version is 5.4
Non-thread-safe (NTS)
64-bit operating system (X86_64)
Php_mongo-1.3.0rc3-5.4-vc9.dll said:
PHP version is 5.4
Thread safe (no nts words)
32-bit operating system (64 is not clearly indicated, 32 bits)

Then locate the corresponding file, copy it to the "ext" subdirectory under the PHP installation directory, change the file name: Php_mongo.dll, and then modify the php.ini file to add:

Extension=php_mongo.dll
Restart Apache (or another Web server)
Verify that the installation is successful.
Open a PHP Web page (which reads as follows), search for MONGO, and if MONGO appears in the results, the installation is successful.

If you start Apache, the warning shown in the following illustration appears. It means that your PHP driver selection is wrong and you can try other drivers.


Related Article

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.