nginx windows安装 php mysql_Windows下安装Nginx+php+mysql环境

系统:Windows 7 64 位系统

安装之前,首先下载软件:

第一步:在 D 盘建立文件夹Nginx+php+Mysql,路径为:D:\Nginx+php+Mysql

第二步:安装Nginx,安装目录为:D:\Nginx+php+Mysql\nginx

1.打开 D:\Nginx+php+Mysql\nginx 目录,运行该文件夹下的 nginx.exe

2.测试是否启动 nginx。打开浏览器访问 http://localhost 或 http://127.0.0.1,看看是否出现“Welcome to nginx!”,出现的证明已经启动成功了。

若启动不成功,查看是否端口被占用。

安装PHP,安装目录为:D:\Nginx+php+Mysql\php

安装 mySQL,安装目录为: D:\Nginx+php+Mysql\mysql

第三步:修改 Nginx 的 conf 文件:目录为 D:\Nginx+php+Mysql\nginx\conf

文件名为:nginx.conf

1. 去掉 worker_processes 前的#号,开启一个进程

2. 添加 events

3. 设置 http->设置 server->支持 php

1862.html

#user nobody;

worker_processes 1;

#error_log logs/error.log;

#error_log logs/error.log notice;

#error_log logs/error.log info;

#pid logs/nginx.pid;

events {

worker_connections 1024;

}

http {

include mime.types;

default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '

# '$status $body_bytes_sent "$http_referer" '

# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;

#tcp_nopush on;

#keepalive_timeout 0;

keepalive_timeout 65;

#gzip on;

server {

listen 80;

server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {

root d:/Nginx+php+Mysql/nginx/html;

index index.html index.htm;

}

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

# 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 $document_root$fastcgi_script_name;

include fastcgi_params;

}

}

}

1862.html

测试 nginx 是否安装成功

1862.html

第四步:修改 php 下 php.ini-development 文件,将文件名修改为 php.ini,找开 php.ini:

搜索“extension_dir”,找到 extension_dir = “ext” 先去前面的分号再改为 extension_dir = “./ext”

搜索“php_mysql”,找到:”extension=php_mysql.dll 和 extension=php_mysqli.dll  去掉前面的“;”extension=php_mysql.dll 和 extension=php_mysqli.dll   (支持 MYSQL 数据库)

查看 php 是否安装成功:

1862.html

第四步:在 php 目录下新建文件 php-cgi.vbs,用 php-cgi.vbs 文件启动 php-cgi:

打开 php-cgi.vbs,写入启动编码:

set wscriptObj = CreateObject("Wscript.Shell")

wscriptObj.run "php-cgi -b 127.0.0.1:9000",0

第五步:在 D:\Nginx+php+Mysql 目录下新建启动项:runServer.bat 和停止项 stopServer.bat

在启动项 runServer.bat 中输入:

1862.html

@echo off

echo Starting nginx...

cd %~dp0nginx

start "" "./nginx.exe"

echo Starting mysql...

net start mysql

echo Starting PHP FastCGI...

cd %~dp0PHP

start "" "php-cgi.vbs"

pause

Exit

1862.html

在停止项中输入:

1862.html

@echo off

echo Stopping nginx...

taskkill /F /IM nginx.exe > nul

echo Stopping PHP FastCGI...

taskkill /F /IM php-cgi.exe > nul

echo Stopping mysql...

net stop mysql

pause

exit

1862.html

最后,查看是否启动成功:

在 nginx 的 html 目录下 D:\Nginx+php+Mysql\nginx\html,新建 phpinfo.php

写入:

phpinfo();

?>

在浏览器中输入 phpinfo.php 的路径,查看是否配置成功:

1862.html

露水湾 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权

转载请注明原文链接:Windows下安装Nginx+php+mysql环境

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值