Windows + nginx + mongodb + php configuration

Source: Internet
Author: User
Tags install mongodb mongodb download vc9
Previously, only nginx or mongodb was configured. Now we can combine it with php to build a development environment on the windows platform. Step 1: install and configure php on the php official website to download php. As for how to install php, I will not elaborate on it. The configuration will be explained below (I believe the person who reads this article will, since you have time and energy to study windowsnginxmongodbphp

Previously, only nginx or mongodb was configured. Now we can combine it with php to build a development environment on the windows platform. Step 1: install and configure php on the php official website to download php. As for how to install php, I will not elaborate on it. The configuration will be explained below (I believe the person who reads this article will, since you have time and energy to study windowsnginxmongodbphp

Previously, only nginx or mongodb was configured. Now we can combine it with php to build a development environment on the windows platform.


Step 1: install and configure php
Go to the php official website to download php. I will not elaborate on how to install php. The configuration will be described below (I believe the person who reads this article will, since you have time and energy to study windows + nginx + mongodb + php, php installation is even more a small dish), please note that you should not download php5.4 or above, when php loads mongodb later, mongodb does not have any corresponding php5.4 or above drivers. In addition, php runs in FastCGI mode in nginx, so we download the php package for non-thread security, that is, the CNT.
Configure php: in the php configuration file, find:
extension_dir = "./ext"

Changed:

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

Continue searching and find:

;extension=php_mysql.dll;extension=php_mysqli.dll

To enable the functions supported by php, you only need to remove the semicolon.

Next, configure php to combine with nginx.

In the php configuration file, find:

;cgi.fix_pathinfo=1
Remove the semicolon and change it:
cgi.fix_pathinfo=1

Step 2: install and configure nginx

Download the latest nginx version from the official website, decompress it to the wnmp directory of drive C, and rename it nginx. Next, configure nginx to work with php. Go to the nginx conf directory, open the nginx configuration file nginx. conf, and find

Location/{root html; # Here is the site's root directory index index.html index.htm ;}
Change root html; To root D:/wnmp/www;

Continue searching and find:

# 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;#}
First remove "#" And change root html; To root C:/wnmp/www; (create a www folder at this time ). Change the/scripts marked in red to "$ document_root". Here, "$ document_root" refers to the site path referred to by "root". This is changed:
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000#location ~ \.php$ {      root           D:/wnmp/www;      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. The nginx + php environment has been initially configured. Run it. Run the following 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.

In fact, the php + nginx configuration has been basically completed here, but the following problem occurs during your own configuration today. If you have encountered such a problem, refer, if not, skip this section.

Problem:

Then I searched Baidu. Some netizens encountered the same problem. The solution is as follows:

1. You can copy the downloaded msvcr110.dll (File: http://download.csdn.net/detail/zhang342789912/6539739) to the specified directory (usually the system directory or put it in the Software Directory at the same level), or re-add file references.
2. decompress the downloaded file and select X86/X64 based on your system conditions. X86 is a 32-bit computer and X64 is a 64-bit computer. The default 32-bit system is supported. If you do not know whether it is X86 or X64
3. Select the file version based on the software. This step is complex. If it is a Windows dll file,
Files whose versions start with 5.0 or whose nt is generally windows2000.
Windows xp files whose versions start with 5.1 or contain xp, xp SP1, xp SP2, and xp SP3 information.
Files whose versions start with 6.0 or contain longhorn and vista are generally Windows vista files.
Files whose versions start with 6.1 or contain win7 information are generally Windows 7 files. If it is not a windows dll file, you need to flexibly view the version number, description, information provided by netizens, and the version number of the related dll to judge.
4. Directly copy the file to the system directory:
A. in Windows 95/98/Me, copy msvcr110.dll to the C: \ Windows \ System directory.
B. in Windows NT/2000, copy msvcr110.dll to the C: \ WINNT \ System32 directory.
C. in Windows XP/WIN7/Vista, copy msvcr110.dll to the C: \ Windows \ System32 directory.

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

Step 3: Download runhiddenconsole.zip address: http://download.csdn.net/detail/zhang342789912/6540035

First, decompress the downloaded runhiddenconsole.zippackage to the nginxdirectory. runhiddenconsole.exe automatically closes the script after executing the command line script, but the process enabled from the script is not closed. Create a script named "start_nginx.bat". Edit it in Notepad ++.

@ 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 C:/wnmp/php/php-cgi.exe-B 127.0.0.1: 9000-c C:/wnmp/php. ini echo Starting nginx... runHiddenConsole C:/wnmp/nginx/nginx.exe-p C:/wnmp/nginx

Create another script named stop_nginx.bat to disable nginx.
@echo offecho Stopping nginx...  taskkill /F /IM nginx.exe > nulecho Stopping PHP FastCGI...taskkill /F /IM php-cgi.exe > nulexit
After nginx is configured, the directory structure looks like this:

In this way, all our service scripts have been created. Double-click start_nginx.bat. check that the progress manager will find two nginx.exepaths and a php-cgi.exe process.

Step 4: download and install mongodb

Mongodb download and installation before some time I have written, you can refer to http://blog.csdn.net/zhang342789912/article/details/9930973

After downloading and installing mongodb, you can configure mongodb. php supports mongodb.

First, download the mongo php driver: http://download.csdn.net/detail/zhang342789912/6540095

A. Determine Your PHP version (the phpinfo () function can list your php version)
B. Select the corresponding version based on whether the thread is secure (not thread safe). If the apache server chooses thread security, running in CGI Mode is non-thread-safe ).
C. Determine your operating system version. (64-bit OS, 32-bit OS)

For example:
Php_mongo-1.3.0RC3-5.4-vc9-nts-x86_64.dll representation:
The PHP version is 5.4.
Non-thread-safe (NT)
64-bit operating system (x86_64)
Php_mongo-1.3.0RC3-5.4-vc9.dll representation:
The PHP version is 5.4.
Thread-safe (without the word "NT)
32-bit operating system (32-bit without explicit representation)

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

extension=php_mongo.dll
Restart apache (or other web servers)
Verify whether the installation is successful.
Open a PHP webpage (which contains the following content) and search for mongo. If mongo appears in the result, the installation is successful.

If you start apache, the Warning is displayed. It indicates that your PHP driver is incorrect. 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.