php mysql nginx_windows下安装php+nginx+mysql(一)

win10

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

Nginx: http://nginx.org/en/download.html

PHP Stable PHP 7.2.3: http://php.net/downloads.php

mysql: http://dev.mysql.com/downloads/utilities/

1、E盘建立文件wnmp,并且把下载好得安装包放进去

8efc996a88397dfbcf511c09adda5658.png

2、安装nginx

2.1解压安装包。

2.2运行nginx.exe,打开浏览器访问http://localhost 或 http://127.0.0.1,看看是否出现“Welcome to nginx!”,出现的证明已经启动成功了。若启动不成功,查看是否端口被占用。

2.3需修改nginx.conf配置文件nginx-1.12.2\conf

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

2. 添加events

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

#user nobody;

worker_processes1;

#error_log logs/error.log;

#error_log logs/error.log notice;

#error_log logs/error.log info;

#pid logs/nginx.pid;

events {

worker_connections1024;

}

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_timeout0;

keepalive_timeout65;

#gzip on;

server {

listen80;

server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location/{

root html;

index index.html index.htm inde.php;

}

#error_page404 /404.html;

# redirect server error pages to thestatic page /50x.html

#

error_page500 502 503 504 /50x.html;

location= /50x.html {

root html;

}

# proxy the PHP scripts to Apache listening on127.0.0.1:80#

#location~\.php$ {

# proxy_pass http://127.0.0.1;

#}

# pass the PHP scripts to FastCGI server listening on127.0.0.1:9000#

location~ [^/]\.php(/|$) {

fastcgi_split_path_info^(.+?\.php)(/.*)$;if (!-f $document_root$fastcgi_script_name) {return 404;

}

fastcgi_pass127.0.0.1:9072;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_param PATH_INFO $fastcgi_path_info;

fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

include fastcgi_params;

}

# deny access to .htaccess files,if Apache's document root

# concurs with nginx's one

#

#location~ /\.ht {

# deny all;

#}

}

# anothervirtual host using mix of IP-, name-, and port-based configuration

#

#server {

# listen8000;

# listen somename:8080;

# server_name somename alias another.alias;

# location/{

# root html;

# index index.html index.htm;

# }

#}

# HTTPS server

#

#server {

# listen443ssl;

# server_name localhost;

# ssl_certificate cert.pem;

# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;

# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;

# ssl_prefer_server_ciphers on;

# location/{

# root html;

# index index.html index.htm;

# }

#}

}

3、修改php下php.ini-development文件,将文件名修改为php.ini,找开php.ini:(自行配置)

4、在nginx下建立文件夹index.php即可确认php与nginx是否关联

5、mysql安装(此安装学习该博主的技术https://www.cnblogs.com/xinxin-csharp/p/6146770.html,感谢分享,非常详尽。)

一、下载

下载页面http://dev.mysql.com/downloads/mysql/

选择系统平台后,点击download(根据系统选择64或32位)

8d4ab102de29168e526e200354097554.png

ae9bb79f5451e99f32dd5bf1cd69891d.png

二、配置

1、下载成功后,解压安装包到要安装的位置,我是安装在”D:\Program Files”

如果安装目录下包含data文件夹,删除

4a0d46e3411507fc88cea7905a53f9c0.png

2、在环境变量PATH中把bin目录添加进去

cdc31401ea57384cb7638c9dd2688745.png

3、把安装目录下的my-default.ini复制一份并重命名为my.ini

修改配置参数,注意把安装目录改成你自己的哦

[mysqld]

# 设置mysql的安装目录

basedir = D:\Program Files\mysql-5.7.16-winx64

# 设置mysql数据库的数据的存放目录,必须是data

datadir = D:\Program Files\mysql-5.7.16-winx64\data

# mysql端口

port = 3306

# 字符集

character_set_server=utf8

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

如下图所示:

b1f296937ffd61f0831caa5155a794f1.png

三、安装

1、以管理员身份运行cmd(请注意,管理员身份)

0604038835a02cc6c7f0585c5f93c383.png

2、进入安装目录下的bin文件夹

5dfa766a94f03a1ff4f15ec3336bbe19.png

3、执行mysqld --initialize

1af11f127d84b1e6356058d05dd1f36f.png

执行成功,在安装目录下会生成data文件夹,打开文件夹找到.err文件,已文本编辑器打开

ad5187dc46bda3c8b6439571e2126738.png

搜索”root”,冒号后面就是随机生成的临时密码

f6c2f24a1f7dd3f0d434dc4ddac01674.png

4、继续,输入mysqld --install MySQL --dufaults-file=”D:\Program Files\mysql-5.7.16-winx64\my.ini”或者 输入 mysqld --install 自动检索my.ini安装

Ps:卸载mysql是cd到bin目录下执行mysqld --remove

593f5e66a26e8cb5e417adbfb8a17b4a.png

5、检测安装,输入 mysql --version

5061cd050b5e4dda4b0a0619b45c6885.png

6、启动mysql服务,输入net start mysql,ps:停止服务是net stop mysql

406708694eab58bb93af1e990dc76fe1.png

四、修改root密码

1、在安装目录下新建mysql-init.txt,输入ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';,保存

PS:5.7.5以及以前版本输入SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');

1de6974b19c1a53b1f1f078f0b6773d7.png

2、关闭mysql服务,然后在cmd中进入bin目录,输入mysqld --init-file=D:\Program Files\mysql-5.7.16-winx64\mysql-init.txt,执行完成后,删除mysql-init.txt文件,重启mysql服务

aad6934e43522c8fad0dae383a1b0a1e.png

3、输入mysql -u root -p,随后输入密码登录(如果登录不了,输入.err里的随机密码进入mysql,执行第4步)

599db69dc439a6b26be61ef7f0156b3c.png

4、进入mysql的shell后重新键入前面在mysql-init.txt里的命令

93a7b9d748e7aa104f2b388f663273c1.png

输入exit退出后重新用新密码登录

d58cba13ee13fb38530af8acc5ce1403.png

五、验证mysql正常使用

输入show databases;

e075b01f8583c80f3af25e66a639072e.png

输入use mysql;

c3732f1afffec236968de49b596c801f.png

输入SELECT User,Host,authentication_string FROM user;

77bf0e6d0c8d26750a0236fdba7d05b9.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值