


wnmp (windows nginx mysql php) environment setup and configuration, wnmpnginx_PHP tutorial
wnmp(windows+nginx+mysql+php)环境搭建和配置,wnmpnginx
要求
-
必备知识
熟悉基本编程环境搭建。
-
运行环境
windows 7(64位);
nginx-1.4.7;
MySQL Server 5.5
php-5.4.39-nts -
下载地址
环境下载
Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行。由俄罗斯的程序设计师Igor Sysoev所开发,供俄国大型的入口网站及搜索引擎Rambler(俄文:Рамблер)使用。其特点是占有内存少,并发能力强,事实上nginx的并发能力确实在同类型的网页服务器中表现较好,中国大陆使用nginx网站用户有:新浪、网易、腾讯等。
上面这段介绍,摘自百度! 看了介绍就知道nginx很有逼格了shi不shi啊!那么问题来了,这么有逼格的配置,在windows下如何搭建呢? 好吧,就让我给大家介绍一下,windows下如何搭建 nginx+mysql+php 环境吧。
官方下载地址
- Nginx
- MySql
- PHP
至于我使用的版本已经上传到百度云提供大家下载了哦,请戳以下链接:
- http://pan.baidu.com/s/1gdpLa6n
Nginx
这么有逼格的服务器,我就不多做介绍,前面也提到了一些。我就直接安装吧,把下载下来的nginx-1.4.7.zip文件,解压到指定的目录就OK了,下面贴一下我的目录结构哦
start nginx //启动服务
nginx -s stop // 停止nginx
nginx -s reload // 重新加载配置文件
nginx -s quit // 退出nginx
在浏览器地址中输入localhost ,如出现下图说明安装成功了!
//这里根据自己的实际情况而定
extension_dir = "E:\2015\wnmp\php\ext"
加入扩展:
选择需要运行哪些扩展,只需将extension前面的注释去掉,例如:
extension=php_mysql.dll extension=php_mysqli.dll
CGI 设置
enable_dl =<span> On cgi.force_redirect </span>= 0<span> cgi.fix_pathinfo</span>=1<span> fastcgi.impersonate </span>= 1<span> cgi.rfc2616_headers </span>= 1
配置Nginx
这里所说的配置,主要是讲如何让Nginx对PHP提供支持!!打开nginx目录下conf文件夹里的nginx.conf(这就是我的配置文件了)
修改如下代码,位置如下
location / {
root E:/2015/wnmp/nginx/html;
index index.html index.htm index.php;
}
让nginx支持PHP的设置,代码位置如下
E:/2015/wnmp/nginx/html;。再把“/scripts”改为“$document_root”,这里的“$document_root”就是指前面“root”所指的站点路径,改完后的代码如下:
location ~<span> \.php$ { root E:</span>/2015/wnmp/nginx/<span>html; fastcgi_pass </span>127.0.0.1:9000<span>; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }</span>
上述配置改为后,别玩了要重启nginx哦,操作指令我已经到上面给出了啊!
测试
启动php内置的cgi程序,在9000端口监听nginx发过来的请求:
E:\2015\wnmp\php>php-cgi.exe -b 127.0.0.1:9000-c E:\wnmp\php\php.ini
PS:上一步操作中如果没有重启nginx的话,现在重启一遍吧!!
在网站更目录(上步操作中root所指向的路径我这里是 E:/2015/wnmp/nginx/html)下创建phpinfo.php文件,代码如下
<?php <span>phpinfo</span>(); ?>
在浏览器地址栏中输入http://localhost/phpinfo.php,一次性点亮,是不是很Happy!!
@echo off
REM Windows 下无效
REM set PHP_FCGI_CHILDREN=5
REM 每个进程处理的最大请求数,或设置为 Windows 环境变量
set PHP_FCGI_MAX_REQUESTS=1000
echo Starting PHP FastCGI...
RunHiddenConsole E:/2015/wnmp/php/php-cgi.exe -b 127.0.0.1:9000 -c E:/2015/wnmp/php/php.ini
echo Starting nginx...
RunHiddenConsole E:/2015/wnmp/nginx/nginx.exe -p E:/2015/wnmp/nginx
创建stop_nginx.bat脚本,对应的是用来关闭nginx服务
<span>@echo off echo Stopping nginx... taskkill </span>/F /IM nginx.exe ><span> nul echo Stopping PHP FastCGI... taskkill </span>/F /IM php-cgi.exe ><span> nul exit</span>
文件目录结构如下
还不错”按钮或到页面右下角点击 “赞一个” 按钮哦。你也可以点击页面右边“分享”悬浮按钮哦,让更多的人阅读这篇文章。

(^_^)如果您觉得此文对您有帮助的话,打个赏喝个咖啡吧,么么哒(^_^)

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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



How to configure an Nginx domain name on a cloud server: Create an A record pointing to the public IP address of the cloud server. Add virtual host blocks in the Nginx configuration file, specifying the listening port, domain name, and website root directory. Restart Nginx to apply the changes. Access the domain name test configuration. Other notes: Install the SSL certificate to enable HTTPS, ensure that the firewall allows port 80 traffic, and wait for DNS resolution to take effect.

How to confirm whether Nginx is started: 1. Use the command line: systemctl status nginx (Linux/Unix), netstat -ano | findstr 80 (Windows); 2. Check whether port 80 is open; 3. Check the Nginx startup message in the system log; 4. Use third-party tools, such as Nagios, Zabbix, and Icinga.

The methods that can query the Nginx version are: use the nginx -v command; view the version directive in the nginx.conf file; open the Nginx error page and view the page title.

Steps to create a Docker image: Write a Dockerfile that contains the build instructions. Build the image in the terminal, using the docker build command. Tag the image and assign names and tags using the docker tag command.

You can query the Docker container name by following the steps: List all containers (docker ps). Filter the container list (using the grep command). Gets the container name (located in the "NAMES" column).

Starting an Nginx server requires different steps according to different operating systems: Linux/Unix system: Install the Nginx package (for example, using apt-get or yum). Use systemctl to start an Nginx service (for example, sudo systemctl start nginx). Windows system: Download and install Windows binary files. Start Nginx using the nginx.exe executable (for example, nginx.exe -c conf\nginx.conf). No matter which operating system you use, you can access the server IP

To get Nginx to run Apache, you need to: 1. Install Nginx and Apache; 2. Configure the Nginx agent; 3. Start Nginx and Apache; 4. Test the configuration to ensure that you can see Apache content after accessing the domain name. In addition, you need to pay attention to other matters such as port number matching, virtual host configuration, and SSL/TLS settings.

In Linux, use the following command to check whether Nginx is started: systemctl status nginx judges based on the command output: If "Active: active (running)" is displayed, Nginx is started. If "Active: inactive (dead)" is displayed, Nginx is stopped.
