windows+nginx+mongodb+php配置
以前都是只配置nginx或者只配置mongodb,现在将其组合起来配合php在windows平台上搭建开发环境。 第一步:php的安装与配置 到php官网下载php,至于怎么安装,就不详细说了,下面会说一下配置(相信看这篇文章的人,既然有时间精力研究windowsnginxmongodbphp
以前都是只配置nginx或者只配置mongodb,现在将其组合起来配合php在windows平台上搭建开发环境。
到php官网下载php,至于怎么安装,就不详细说了,下面会说一下配置(相信看这篇文章的人,既然有时间精力研究windows+nginx+mongodb+php,php的安装更是小菜了),不过需要提醒各位的一点就是,不要下载php5.4以上的,因为后面php加载mongodb的时候,mongodb暂时没有对应php5.4以上的版本驱动,另外nginx下php是以FastCGI的方式运行,所以我们下载非线程安全也就是nts的php包。
配置php:在php配置文件中找到:
extension_dir = "./ext"
改为:
extension_dir = "C:/wnmp/php/ext"
继续往下找,找到:
;extension=php_mysql.dll ;extension=php_mysqli.dll
选择性的开启想要php支持的功能,只需要去掉前面分号即可
接下来配置php使其与nginx结合
在php配置文件中找到:
;cgi.fix_pathinfo=1
cgi.fix_pathinfo=1
第二步:nginx的安装与配置
首先到官网下载最新版本的nginx,解压到C盘的wnmp目录下,并重命名为nginx。接下来,我们来配置nginx,让它能够和php协同工作。进入nginx的conf目录,打开nginx的配置文件nginx.conf,找到
location / { root html; #这里是站点的根目录 index index.html index.htm; }
继续往下找,找到:
# 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; #}
# 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; }
C:\wnmp\php\php-cgi.exe -b 127.0.0.1:9000 -c C:/wnmp/php/php.ini
来启动php,并手动启动nginx,当然也可以利用脚本来实现。
其实到这里基本上已经完成了php+nginx的配置,但是今天自己配置的时候出现了下面这个问题,如果你也遇到了这样的问题,可以参考下,如果没有,可以跳过这部分
问题截图:
然后就从百度上搜索,有网友遇到了相同的问题,解决方法如下:
1、您可将下载来的msvcr110.dll(文件下载地址:http://download.csdn.net/detail/zhang342789912/6539739)拷贝到指定目录即可(一般是system系统目录或放到软件同级目录里面),或者重新添加文件引用。
2、先将下载下来的文件解压, 然后根据您系统的情况选择X86/X64,X86为32位电脑,X64为64位电脑。默认都是支持32位系统的, 如果您不知道是X86还是X64
3、根据软件情况选择文件版本。此步骤比较复杂,如果是Windows的dll文件,
版本号以5.0开头的或含有 nt 一般是windows2000的文件。
版本号以5.1开头的或含有 xp、xpsp1、xpsp2、xpsp3 信息的一般是windowsXP的文件。
版本号以6.0开头的或含有 longhorn、vista 信息的一般是windowsVista的文件。
版本号以6.1开头的或含有 win7 信息的一般是windows7的文件。 如果不是windows的dll文件,则需要灵活查看版本号、描述、网友提供的信息、以及相关dll的版本号去判断。
4、直接拷贝该文件到系统目录里:
a、Windows 95/98/Me系统,将msvcr110.dll复制到C:\Windows\System目录下。
b、Windows NT/2000系统,将msvcr110.dll复制到C:\WINNT\System32目录下。
c、Windows XP/WIN7/Vista系统,将msvcr110.dll复制到C:\Windows\System32目录下。
d、如果您的系统是64位的请将文件复制到C:\Windows\SysWOW64目录
第三步:下载RunHiddenConsole.zip地址:http://download.csdn.net/detail/zhang342789912/6540035
首先把下载好的RunHiddenConsole.zip包解压到nginx目录内,RunHiddenConsole.exe的作用是在执行完命令行脚本后可以自动关闭脚本,而从脚本中开启的进程不被关闭。然后来创建脚本,命名为“start_nginx.bat”,我们在Notepad++里来编辑它
@echo off REM Windows 下无效 REM set PHP_FCGI_CHILDREN=5 REM 每个进程处理的最大请求数,或设置为 Windows 环境变量 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
再另外创建一个名为stop_nginx.bat的脚本用来关闭nginx
@echo off echo Stopping nginx... taskkill /F /IM nginx.exe > nul echo Stopping PHP FastCGI... taskkill /F /IM php-cgi.exe > nul exit
这样,我们的服务脚本也都创建完毕了。双击start_nginx.bat看看进程管理器会发现有两个nginx.exe的进程和一个php-cgi.exe的进程
第四步:mongodb的下载与安装
mongodb的下载与安装前些时间我已经写过了,可以参考http://blog.csdn.net/zhang342789912/article/details/9930973
下载和安装好mongodb后就可以配置mongodb,是php支持mongodb了
首先,下载mongo的PHP驱动,下载地址:http://download.csdn.net/detail/zhang342789912/6540095
a、确定自己的PHP版本(phpinfo()函数可以列出自己的php版本)
b、按照是否线程安全选择相应版本(有nts字样的是非线程安全的(not thread safe),如果是apache服务器选择线程安全的,如果是用CGI方式运行就是非线程安全的)。
c、确定自己操作系统版本。(有64字样的是64位操作系统,没有的就是32位的)
比如:
php_mongo-1.3.0RC3-5.4-vc9-nts-x86_64.dll表示 :
PHP 版本为5.4
非线程安全的(nts)
64位操作系统(x86_64)
php_mongo-1.3.0RC3-5.4-vc9.dll 表示:
PHP 版本为5.4
线程安全的(没有nts字样)
32位操作系统(没有明确表明64的,即为32位)
然后找到对应的文件,将其复制到PHP安装目录下的” ext ” 子目录,同时更改文件名为:php_mongo.dll,然后修改php.ini文件,添加:
extension=php_mongo.dll
验证是否安装成功。
打开一个PHP网页(里面内容为如下),搜索mongo,如果结果中出现mongo,则表示安装成功。
如果启动apache出现下图所示的Warning。则表示你的PHP驱动选择错误,可以尝试其他驱动。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Title: The working principle and configuration method of GDM in Linux systems In Linux operating systems, GDM (GNOMEDisplayManager) is a common display manager used to control graphical user interface (GUI) login and user session management. This article will introduce the working principle and configuration method of GDM, as well as provide specific code examples. 1. Working principle of GDM GDM is the display manager in the GNOME desktop environment. It is responsible for starting the X server and providing the login interface. The user enters

PyCharm is a powerful integrated development environment (IDE), and PyTorch is a popular open source framework in the field of deep learning. In the field of machine learning and deep learning, using PyCharm and PyTorch for development can greatly improve development efficiency and code quality. This article will introduce in detail how to install and configure PyTorch in PyCharm, and attach specific code examples to help readers better utilize the powerful functions of these two. Step 1: Install PyCharm and Python

Title: How to correctly configure Git in PyCharm In modern software development, the version control system is a very important tool, and Git, as one of the popular version control systems, provides developers with powerful functions and flexible operations. As a powerful Python integrated development environment, PyCharm comes with support for Git, allowing developers to manage code versions more conveniently. This article will introduce how to correctly configure Git in PyCharm to facilitate better development during the development process.

Understanding Linux Bashrc: Function, Configuration and Usage In Linux systems, Bashrc (BourneAgainShellruncommands) is a very important configuration file, which contains various commands and settings that are automatically run when the system starts. The Bashrc file is usually located in the user's home directory and is a hidden file. Its function is to customize the Bashshell environment for the user. 1. Bashrc function setting environment

PyCharm is a commonly used integrated development environment (IDE). In daily development, using Git to manage code is essential. This article will introduce how to configure Git in PyCharm and use Git for code management, with specific code examples. Step 1: Install Git First, make sure Git is installed on your computer. If it is not installed, you can go to [Git official website](https://git-scm.com/) to download and install the latest version of Git

MyBatisGenerator is a code generation tool officially provided by MyBatis, which can help developers quickly generate JavaBeans, Mapper interfaces and XML mapping files that conform to the database table structure. In the process of using MyBatisGenerator for code generation, the setting of configuration parameters is crucial. This article will start from the perspective of configuration parameters and deeply explore the functions of MyBatisGenerator.

How to configure a workgroup in Win11 A workgroup is a way to connect multiple computers in a local area network, which allows files, printers, and other resources to be shared between computers. In Win11 system, configuring a workgroup is very simple, just follow the steps below. Step 1: Open the "Settings" application. First, click the "Start" button of the Win11 system, and then select the "Settings" application in the pop-up menu. You can also use the shortcut "Win+I" to open "Settings". Step 2: Select "System" In the Settings app, you will see multiple options. Please click the "System" option to enter the system settings page. Step 3: Select "About" In the "System" settings page, you will see multiple sub-options. Please click

Title: How to configure and install FTPS in Linux system, specific code examples are required. In Linux system, FTPS is a secure file transfer protocol. Compared with FTP, FTPS encrypts the transmitted data through TLS/SSL protocol, which improves Security of data transmission. In this article, we will introduce how to configure and install FTPS in a Linux system and provide specific code examples. Step 1: Install vsftpd Open the terminal and enter the following command to install vsftpd: sudo
