window停配置搭建 nginx+ php + mysql开发环境
window下配置搭建 nginx+ php + mysql开发环境 ? ? Nginx是一个高性能的HTTP和反向代理服务器,同时还是IMAP/POP3/SMTP代理服务器,该程序由俄罗斯Rambler.ru 站点开发,Nginx因为性能稳定、低系统资源消耗而闻名。近几年Nginx在国内已经成炙热化状态,比如像
window下配置搭建 nginx+ php + mysql开发环境? ? Nginx是一个高性能的HTTP和反向代理服务器,同时还是IMAP/POP3/SMTP代理服务器,该程序由俄罗斯Rambler.ru 站点开发,Nginx因为性能稳定、低系统资源消耗而闻名。近几年Nginx在国内已经成炙热化状态,比如像腾讯、网易、51CTO、迅雷、当当网、51、人人网等诸多大型网站都已经使用Nginx来做Web服务器,所以学习Nginx还是非常有必要的。
?
1.准备安装包
下载Nginx、MySQL和PHP的程序包,相关资源地址列表如下:
Nginx
http://nginx.org/en/download.html
MySQL
http://www.mysql.com/downloads/
PHP
http://windows.php.net/download/
?
2.安装部署
?
安装php
解压php-5.4.8-nts-Win32-VC9-x86.zip 到D:\server\php ? ? ? ? Windows下 隐藏DOS命令行窗口的程序。RunHiddenConsole.exe 是一个用来隐藏 DOS 窗口的小程序 解压RunHiddenConsole.zip ,复制RunHiddenConsole.exe到D:\server\php ? ? ? ? 重命名php目录下的php.ini-development 为php.ini,用编辑器打开此文件(最好不要用记事本打开),此文件为PHP配置文件。查找定位至:; extension_dir = "./" ,将前面的分号去掉并修改为:extension_dir = "E:/DedeCMS/PHP5/ext"
查找定位至:;extension=php_gd2.dll,将前面的分号去掉为:extension=php_gd2.dll
查找定位至:;extension=php_mbstring.dll,将前面的分号去掉为:extension=php_mbstring.dll
查找定位至:;extension=php_mysql.dll,将前面的分号去掉为:extension=php_mysql.dll
查找定位至:;extension=php_mysqli.dll,将前面的分号去掉为:extension=php_mysqli.dll
查找定位至:;extension=php_pdo_mysql.dll,将前面的分号去掉为:extension=php_pdo_mysql.dll
查找定位至:;cgi.force_redirect = 1,将前面的分号去掉为:cgi.force_redirect = 1
查找定位至:;cgi.fix_pathinfo=1,将前面的分号去掉为:cgi.fix_pathinfo=1
查找定位至:;cgi.rfc2616_headers = 0,将前面的分号去掉为:cgi.rfc2616_headers = 1
启动php-cgi D:\server\php>RunHiddenConsole.exe??php-cgi.exe?-b?127.0.0.1:9000?-c?D:\server\php\php.ini ? 使用命令 D:\server\php>netstat?-a ? 出现 TCP ? ?127.0.0.1:9000 ? ? ? ? HongJunWen-PC:0 ? ? ? ?LISTENING 说明php-cgi启动成功。安装MySQL5.5
MySQL安装:双击安装包进入安装环境界面,选择“Install MySQL Products”
?
选择“I accept the license terms”,再选择“Next”按钮继续安装(如图9)。
?
?
选择“Skip the check for updates(not recommanded)”,再选择“Next”按钮继续安装(如图10)。
?
选择“Custom”,更改安装路径为之前创建的目录。再选择“Next”继续安装(如图11)。
图11
选择“MySQL Server 5.5.13”与“MySQL Workbench 5.2.34”, “MySQL Workbench 5.2.34”是可视数据库设计工具。这个工具是设计MySql数据库的专用工具。也可根据需要选择是否安装。选择“Next”按钮继续安装(如图12)。
图12
选择“Next”按钮继续安装(如图13)。
图13
稍等片刻。程序安装完成,选择“Next”按钮进行产品配置(如图14)。
图14
选择“Server Machine”,再选择“Next”按钮继续(如图15)。
图15
默认3306端口,默认MySQL55 Windows服务进程名称。输入密码与重复密码。选择“Next”按钮继续(如图16)。
图16
程序会自动安装,安装完成选择“Next”出现安装完成界面(如图17)。
图17
?
安装nginx
在D盘下建立名为server的目录 D:\server
解压nginx-1.2.5.zip至D:\server\nginx-1.2.5
找到下面的nginx.exe,在命令行下运行nginx.exe?(注意目录中不能出现中文字符)
启动nginx.
打开任务管理器,切换到进程选项卡,出现如下进程,证明nginx已经启动。
在浏览中键入:http://127.0.0.1,看到下图所示证明nginx正常工作。
?
?
配置Nginx
打开Nginx的配置文件nginx.conf,部分修改如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 Copy after login |
location / { root D:/wwwroot; index index.php 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 D:/wwwroot$fastcgi_script_name; include fastcgi_params; } Copy after login |
?
服务的启动与关闭
建立两个文件分别启动、关闭服务进程。
在DedeCMS中建立文件start_nginx.bat
@echo off
echo Starting PHP FastCGI...
RunHiddenConsole e:/DedeCMS/PHP5/php-cgi.exe -b 127.0.0.1:9000 -c e:/DedeCMS/PHP5/php.ini
echo Starting nginx...
RunHiddenConsole e:/DedeCMS/nginx.exe
Exit
在DedeCMS中建立文件stop_nginx.bat
@echo off
echo Stopping nginx...
taskkill /F /IM nginx.exe > nul
echo Stopping PHP FastCGI...
taskkill /F /IM php-cgi.exe > nul
exit
下载软件:http://www.haoboweb.com/uploads/allimg/110613/RunHiddenConsole.zip。(只能上传图片,传不了软件)
解压至DedeCMS目录,双击start_nginx.bat启动服务进程(如图18)。由此可见,stop_nginx.bat 文件为关闭服务进程。
?
环境测试
在网站根目录中建立index.php文件,内容为:
$link = mysql_connect("localhost","root","123456");
if($link){
echo "数据库连接成功!";
}else{
echo "数据库连接失败!";
}
?>
输出“数据库连接成功!”,nginx的PHP环境配置成功(如图19)。
图19
?

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

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

One of the major changes introduced in MySQL 8.4 (the latest LTS release as of 2024) is that the "MySQL Native Password" plugin is no longer enabled by default. Further, MySQL 9.0 removes this plugin completely. This change affects PHP and other app

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

CMS stands for Content Management System. It is a software application or platform that enables users to create, manage, and modify digital content without requiring advanced technical knowledge. CMS allows users to easily create and organize content

Arrays are linear data structures used to process data in programming. Sometimes when we are processing arrays we need to add new elements to the existing array. In this article, we will discuss several ways to add elements to the end of an array in PHP, with code examples, output, and time and space complexity analysis for each method. Here are the different ways to add elements to an array: Use square brackets [] In PHP, the way to add elements to the end of an array is to use square brackets []. This syntax only works in cases where we want to add only a single element. The following is the syntax: $array[] = value; Example
