一.PHP8.1安装部署 下载php 打开PHP官网,选择对应的PHP版本下载。 None Thread Safe和Thread Safe版本区别 None Thread Safe就是非线程安全,在执行时不进行线程(thread)安全检
下载php
打开PHP官网,选择对应的PHP版本下载。
None Thread Safe就是非线程安全,在执行时不进行线程(thread)安全检查。
2.Thread Safe就是线程安全,执行时会进行线程(thread)安全检查,以防止有新要求就启动新线程,耗尽系统资源。
为了能与外部交换数据,PHP提供了一种叫Sapi的接口。SAPI是一个中间过程,提供了一个和外部通信的接口,有点类似于Socket。SAPI使得PHP可以和其他应用进行交互数据(如Apache、Nginx等)。PHP默认提供了很多种SAPI,常见的提供给Apache、Nginx、IIS6/7的FastCGI,单独给IIS的ISAPI,以及shell的CLI。FastCGI执行方式是以单一线程来执行操作,所以不需要进行线程的安全检查,除去线程安全检查的防护反而可以提高执行效率。而线程安全检查是为ISAPI方式的PHP准备的,也就是为IIS准备的,因为有许多php模块都不是线程安全的,所以需要使用Thread Safe的PHP。所以,如果是以 FastCGI 执行 PHP ,都建议用Non Thread Safe的 PHP (zip安装包)。
安装部署
下载完成获得.zip压缩包,解压缩,打开cmd命令行工具,使用命令进行操作。
cmd命令行启动PHP
cd C:\Users\keke\dev\php-8.1.9-nts #切换进入目录php-cgi.exe -b 127.0.0.1:9000 -c php.ini #启动 php-cgi.exe
下载nginx
打开Nginx官网可以看到有Mainline version、Stable version、Legacy versions三种版本,这里我们选择Mainline version的windows版本,点击下载。
nginx版本类型介绍
安装部署
下载完成获得.zip压缩包,解压缩,打开cmd命令行工具,使用命令进行操作,不要直接双击nginx.exe。
命令行启动nginx
cd C:\Users\keke\dev\nginx-1.23.1 #进入解压后的nginx目录start nginx.exe#启动nginxtasklist /fi "imagename eq nginx.exe" #查看nginx是否启动成功
nginx的目录结构
nginx部分管理命令补充。
nginx.exe -t #检查配置文件nginx.exe -s reload #重启nginx.exe -s stop #快速停止nginx.exe -s quit #完整有序的关闭
修改配置文件监听 php-cgi 的配置,然后重启nginx。
#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 项目目录路径; try_files $uri $uri/ /index.php?$query_string; 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 { root 项目目录路径; } # 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$ { root 项目目录路径; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 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; # } #}}
如有侵权,联系删除
来源地址:https://blog.csdn.net/weixin_45555414/article/details/127786132
--结束END--
本文标题: windows php、nginx环境安装
本文链接: https://www.lsjlt.com/news/392897.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0