win10php
安裝以前,首先下載軟件:html
Nginx: http://nginx.org/en/download.htmlmysql
PHP Stable PHP 7.2.3: http://php.net/downloads.phpnginx
mysql: http://dev.mysql.com/downloads/utilities/sql
一、E盤創建文件wnmp,而且把下載好得安裝包放進去shell
二、安裝nginx數據庫
2.1解壓安裝包。瀏覽器
2.2運行nginx.exe,打開瀏覽器訪問http://localhost 或 http://127.0.0.1,看看是否出現「Welcome to nginx!」,出現的證實已經啓動成功了。若啓動不成功,查看是否端口被佔用。session
2.3需修改nginx.conf配置文件nginx-1.12.2\confapp
1. 去掉worker_processes前的#號,開啓一個進程
2. 添加events
3. 設置http->設置server->支持php
#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 html; index index.html index.htm inde.php; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; if (!-f $document_root$fastcgi_script_name) { return 404; } fastcgi_pass 127.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; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # 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; # } #} }
三、修改php下php.ini-development文件,將文件名修改成php.ini,找開php.ini:(自行配置)
四、在nginx下創建文件夾index.php便可確認php與nginx是否關聯
五、mysql安裝(此安裝學習該博主的技術https://www.cnblogs.com/xinxin-csharp/p/6146770.html,感謝分享,很是詳盡。)
1、下載
下載頁面http://dev.mysql.com/downloads/mysql/
選擇系統平臺後,點擊download(根據系統選擇64或32位)
2、配置
一、下載成功後,解壓安裝包到要安裝的位置,我是安裝在」D:\Program Files」
若是安裝目錄下包含data文件夾,刪除
二、在環境變量PATH中把bin目錄添加進去
三、把安裝目錄下的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
以下圖所示:
3、安裝
一、以管理員身份運行cmd(請注意,管理員身份)
二、進入安裝目錄下的bin文件夾
三、執行mysqld --initialize
執行成功,在安裝目錄下會生成data文件夾,打開文件夾找到.err文件,已文本編輯器打開
搜索」root」,冒號後面就是隨機生成的臨時密碼
四、繼續,輸入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
五、檢測安裝,輸入 mysql --version
六、啓動mysql服務,輸入net start mysql,ps:中止服務是net stop mysql
4、修改root密碼
一、在安裝目錄下新建mysql-init.txt,輸入ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';,保存
PS:5.7.5以及之前版本輸入SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
參考文檔:http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
二、關閉mysql服務,而後在cmd中進入bin目錄,輸入mysqld --init-file=D:\Program Files\mysql-5.7.16-winx64\mysql-init.txt,執行完成後,刪除mysql-init.txt文件,重啓mysql服務
三、輸入mysql -u root -p,隨後輸入密碼登陸(若是登陸不了,輸入.err裏的隨機密碼進入mysql,執行第4步)
四、進入mysql的shell後從新鍵入前面在mysql-init.txt裏的命令
輸入exit退出後從新用新密碼登陸
5、驗證mysql正常使用
輸入show databases;
輸入use mysql;
輸入SELECT User,Host,authentication_string FROM user;