前言
現在技術發展得很快,記得以前是php4,現了現在已經是php8.1了,這是nginx、mariadb、php8安裝教程,
檢查vc-redis

php依賴vc redistributable,你在設定 - 應用和功能 中搜索關鍵詞"redistributable",看有沒有,如果沒有,則下載一個,
https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170
安裝nginx
我們先下載 https://nginx.org/download/nginx-1.21.4.zip
并且解壓到 D:\nmp\nginx-1.21.4
檔案清單:D:\nmp\nginx-1.21.4\conf\nginx.conf
#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;
include sites/*.conf;
}
檔案清單:D:\nmp\nginx-1.21.4\conf\sites\127.0.0.1.conf
server {
listen 80;
server_name localhost 127.0.0.1;
#charset koi8-r;
#access_log logs/host.access.log main;
root d:/nmp/www/127.0.0.1;
location / {
index index.php index.html index.htm;
}
#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 {
}
# 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_pass 127.0.0.1:9090;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
創建目錄:
mkdir D:\nmp\www
mkdir D:\nmp\www\127.0.0.1
安裝php8.1
下載: https://windows.php.net/downloads/releases/php-8.1.1-nts-Win32-vs16-x64.zip
創建檔案夾:
mkdir D:\nmp\php-8.1.1-nts-Win32-vs16-x64
把php-8.1.1-nts-Win32-vs16-x64.zip解壓到剛創建的檔案夾中,
把D:\nmp\php-8.1.1-nts-Win32-vs16-x64\php.ini-development 重命名為php.ini
打開php.ini 把;extension_dir = "ext"前面的分號;去掉,
extension_dir = "ext"
查找extension= 然后在后面加上:
extension=pdo_mysql
extension=pdo_sqlite
extension=gd
extension=fileinfo
extension=curl
extension=openssl
extension=mbstring
創建測驗檔案:D:\nmp\www\127.0.0.1\index.php
<?php
phpinfo();

安裝Mariadb 10.7
如果你喜歡用msi安裝,則下載:
https://dlm.mariadb.com/1923178/mariadb/mariadb-10.7.1/winx64-packages/mariadb-10.7.1-winx64.msi
如果你喜歡zip安裝,則下載
https://mirrors.******/mariadb//mariadb-10.7.1/winx64-packages/mariadb-10.7.1-winx64.zip

這里我們用zip方式,把mariadb解壓縮到 D:\nmp\mariadb-10.7.1-winx64
然后創建目錄
mkdir D:\nmp\data
mkdir D:\nmp\data\mariadb_temp
mkdir D:\nmp\data\mariadb-10.7.1
安裝系統資料庫:
D:\nmp\mariadb-10.7.1-winx64\bin\mysql_install_db.exe --datadir=D:\nmp\data\mariadb-10.7.1
檔案清單:·D:\nmp\mariadb-10.7.1-winx64\my.ini
[mysqld]
socket = D:/nmp/mariadb-10.7.1-winx64/mysql.sock
tmpdir = D:/nmp/data/mariadb_temp/
basedir = D:/nmp/mariadb-10.7.1-winx64
datadir = D:/nmp/data/mariadb-10.7.1
character_set_server = utf8mb4
啟動mysql資料庫:
D:\nmp\mariadb-10.7.1-winx64\bin\mysqld --defaults-file="D:\nmp\mariadb-10.7.1-winx64\my.ini" --console
用mysql連接測驗一下:
mysql -u root
MariaDB [(none)]> show databases;
啟動腳本: D:\nmp\run_as_admin.bat
taskkill /F /IM nginx.exe /T
taskkill /F /IM php-cgi.exe /T
taskkill /F /IM mysqld.exe /T
d:
cd D:\nmp\nginx-1.21.4
start nginx.exe
cd D:\nmp\php-8.1.1-nts-Win32-vs16-x64
start php-cgi.exe -b 127.0.0.1:9090
start D:\nmp\mariadb-10.7.1-winx64\bin\mysqld --defaults-file="D:\nmp\mariadb-10.7.1-winx64\my.ini" --console
#pause
在run_as_admin.bat檔案上右鍵,選擇“以管理員身份運行(A)”
測驗一下mysql連接:
檔案清單:D:\nmp\www\127.0.0.1\db.php
<?php
$user='root';
$pass='';
$dsn="mysql:host=localhost;dbname=mysql";
$db = new PDO($dsn, $user, $pass, array(PDO::ATTR_PERSISTENT => true));
$stmt =$db->prepare("show databases");
$stmt->execute();
$dt = $stmt->fetchAll();
print_r($dt);

如果有出錯,歡迎反饋,
聯系人:楊慶榮
13714715608
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/387843.html
標籤:其他
上一篇:Nginx配置socket轉發TCP協議傳輸,記錄一下
下一篇:搭建Nginx服務器
