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,並且把下載好得安裝包放進去
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_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; # } #} }
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位)
二、配置
1、下載成功后,解壓安裝包到要安裝的位置,我是安裝在”D:\Program Files”
如果安裝目錄下包含data文件夾,刪除
2、在環境變量PATH中把bin目錄添加進去
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
如下圖所示:
三、安裝
1、以管理員身份運行cmd(請注意,管理員身份)
2、進入安裝目錄下的bin文件夾
3、執行mysqld --initialize
執行成功,在安裝目錄下會生成data文件夾,打開文件夾找到.err文件,已文本編輯器打開
搜索”root”,冒號后面就是隨機生成的臨時密碼
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
5、檢測安裝,輸入 mysql --version
6、啟動mysql服務,輸入net start mysql,ps:停止服務是net stop mysql
四、修改root密碼
1、在安裝目錄下新建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
2、關閉mysql服務,然后在cmd中進入bin目錄,輸入mysqld --init-file=D:\Program Files\mysql-5.7.16-winx64\mysql-init.txt,執行完成后,刪除mysql-init.txt文件,重啟mysql服務
3、輸入mysql -u root -p,隨后輸入密碼登錄(如果登錄不了,輸入.err里的隨機密碼進入mysql,執行第4步)
4、進入mysql的shell后重新鍵入前面在mysql-init.txt里的命令
輸入exit退出后重新用新密碼登錄
五、驗證mysql正常使用
輸入show databases;
輸入use mysql;
輸入SELECT User,Host,authentication_string FROM user;