如何在windows下搭建Nginx+MySQL+PHP环境
来源:互联网 发布:环球isis知乎 编辑:程序博客网 时间:2024/05/19 23:56
准备所需安装包
本次所选安装版本是:nginx1.11.5,php7.1.0,mysql5.7.16,当然可以根据喜欢的版本下载,为了方便管理,我在D盘下新建了wnmp文件夹,里面包含文件夹有mysql,php,nginx,www,www为存放项目文件夹。
Nginx: 前往nginx.org/en/download.html下载;PHP:前往Windows.php.net/download下载 ,根据自己的电脑系统位数选择对应版本,顺便说下线程安全版(Thread Safe)和非线程安全版(Non Thread Safe),在Windows下是用FastCGI模式运行php,所以就没必要使用线程安全检查,选用非线程安全版效率会高一些。MySQL:前往dev.mysql.com/downloads/mysql下载,选择Windows版本。
一 安装MySQL
1.双击安装包进入安装界面,到第二步后建议选择custom(自定义)安装,这样就可以选择mysql文件和数据库文件的存放位置,不然会全部默认安装在C盘;
进入自定义之后只选择安装server就可以,因为其他用不到
点击advanced options选择安装在D:/wnmp/mysql中
之后一直next或者execute,到设置帐号密码这一步设置自己的密码就行了
之后还是next或者execute,直到出现finished,点击,安装mysql完成。
二 安装PHP
1.将php压缩包解压到D盘新建的wnmp/php文件夹中;2.将php文件夹中的php.ini-development,复制粘贴,将副本改为php.ini;3.用记事本打开php.ini 查找到一下代码并将前面的分号去掉 ;extension_dir = "ext" ;cgi.force_redirect = 1 ;cgi.fix_pathinfo=1 ;fastcgi.impersonate = 1 ;cgi.rfc2616_headers = 0 改为: extension_dir = "D:/www/php/ext" cgi.force_redirect = 1 cgi.fix_pathinfo=1 fastcgi.impersonate = 1 cgi.rfc2616_headers = 0
三 安装Nginx
1.将Nginx压缩包解压到D盘新建的wnmp/nginx文件夹中;2.打开nginx/conf/nginx.conf进行配置将 server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; 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; #}}改为:server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root D:/wnmp/www; index index.html index.htm index.php; } # 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; }}保存后双击nginx.exe就可以直接运行Nginx服务器了,打开浏览器输入localhost就可以看到欢迎页。
四 调试
1.打开命令提示符输入D:进入到D盘 D:\>cd wnmp/php D:\wnmp\PHP>php-cgi.exe -b 127.0.0.1:9000 -c d:/wnmp/php/php.ini 启动后再新打开一个命令提示符,输入:netstat -a:findstr "9000"查看9000端口是否被监听,如果是说明cgi运行成功。
2.在www目录下新建index.php<?php $con = mysqli_connect('localhost','root','root','test'); if($con){ echo '链接数据库成功!'; }else{ echo '链接数据库失败!'; } 运行之后输出下面结果,说明可以解析PHP文件且可以链接数据库。
0 0
- 如何在windows下搭建Nginx+MySQL+PHP环境
- windows 下搭建nginx php mysql 环境
- MySQL+nginx+php环境在ubuntu14.04下的搭建
- Windows下Nginx+php环境搭建
- windows下搭建nginx+php+redis环境
- 在windows(win8)下搭建apache+Mysql+PHP环境详解。
- linux下nginx+php+mysql环境搭建
- linux下nginx+php+mysql环境搭建
- linux下nginx+php+mysql环境搭建
- linux下nginx+php+mysql环境搭建
- linux 下nginx+mysql+php环境搭建
- 在windows下搭建nginx+php
- windows下apache+php+mysql环境搭建
- windows下 apache+php+mysql环境搭建
- windows nginx php 环境搭建
- 在windows环境下搭建mysql集群
- Windows+Mysql+Nginx+PHP环境搭建(wmnp)
- (转)wnmp(windows+nginx+mysql+php)环境搭建和配置
- struts2中自定义拦截器详解
- 小马哥---高仿三星A9000 主板型号A891 芯片6580刷机拆机主板图与开机界面图 多图展示
- ios 编辑表格功能
- EXCEL VBA 正则表达式 MatchCollection对象
- STL基本容器: string、vector、list、deque、set、map
- 如何在windows下搭建Nginx+MySQL+PHP环境
- 1
- JAVA——第四章——类与对象
- iOS 开发 深入浅出Rumtime运行时之消息转发机制详解
- 一个tomcat服务器发布两个项目服务
- Java之XML(一)初识XML
- vimrc
- wait和notify的理解与使用
- Memset常用用法