search
HomeBackend DevelopmentPHP Tutorialwnmp (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了,下面贴一下我的目录结构哦

wnmp (windows nginx mysql php) environment setup and configuration, wnmpnginx_PHP tutorialstart nginx //启动服务 nginx -s stop // 停止nginx nginx -s reload // 重新加载配置文件 nginx -s quit // 退出nginx

在浏览器地址中输入localhost ,如出现下图说明安装成功了!

wnmp (windows nginx mysql php) environment setup and configuration, wnmpnginx_PHP tutorial//这里根据自己的实际情况而定 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(这就是我的配置文件了)

修改如下代码,位置如下

wnmp (windows nginx mysql php) environment setup and configuration, wnmpnginx_PHP tutoriallocation / { root E:/2015/wnmp/nginx/html; index index.html index.htm index.php; }

让nginx支持PHP的设置,代码位置如下

wnmp (windows nginx mysql php) environment setup and configuration, wnmpnginx_PHP tutorialE:/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!!

wnmp (windows nginx mysql php) environment setup and configuration, wnmpnginx_PHP tutorial@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>

文件目录结构如下

wnmp (windows nginx mysql php) environment setup and configuration, wnmpnginx_PHP tutorial还不错”按钮或到页面右下角点击 “赞一个” 按钮哦。你也可以点击页面右边“分享”悬浮按钮哦,让更多的人阅读这篇文章。

作者:Li-Cheng 微博:http://weibo.com/licheng0426 出处: http://www.cnblogs.com/Li-Cheng/p/4399149.html 由于本人水平有限,文章在表述和代码方面如有不妥之处,欢迎批评指正。留下你的脚印,欢迎评论哦。你也可以关注我,一起学习哦!

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

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/980644.htmlTechArticlewnmp(windows+nginx+mysql+php)环境搭建和配置,wnmpnginx 要求 必备知识 熟悉基本编程环境搭建。 运行环境 windows 7(64位); nginx-1.4.7; MySQL Server 5.5 ph...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.