前言

由于咱以前是用PHP做的东西,又不想重新用 OpenResty自带的编写,所以呢咱设置下,可以像以前Apache那样访问PHP文件

首先去下载 PHP

https://windows.php.net/download#php-7.3

或者在文章最上面的git 链接上下载

解压到自己的电脑上

改一下名字,名字太长..

把php.ini-development  这个文件复制出来一份,,然后名字改为 php.ini

修改 php.ini

去掉前面的 ;

cgi.fix_pathinfo=1

打开并修改openresty里面的 nginx.conf文件

1.去掉屏蔽

  

修改后

  

2.修改路径

1.php路径和html路径这样设置一样,会导致启动错误

  

2.把路径统一写到外面,可以解决错误

  

root   C:\openresty-1.15.8.2-win64\html;

请根据自己的填写

3.修改

修改为

$document_root$fastcgi_script_name;

参考代码

    server { #虚拟主机
listen ; # 监听端口
server_name localhost; # 监听域名 #charset koi8-r; #access_log logs/host.access.log main; root "C:\openresty-1.15.8.2-win64\html";#PHP文件访问路径和html路径设置的访问一样,单独拿出来这个路径 location / {#就是http://IP/无论什么名字都会进来
#root html;
index index.html index.htm index.php;#如果没有前面的,就自动访问index.php
} #error_page /.html; # redirect server error pages to the static page /50x.html
#
error_page /50x.html;
location = /50x.html {
#root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:
# 172.26.94.113 127.0.0.1
location ~ \.php$ {#~区分大小写 \前面任意 后面跟着 .php $ 代表结束 http://IP/任意/任意.php
#root html;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.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;
#}
}

配置完了OpenResty

如果启动过 Nginx 需要先关闭

然后重新启动

里面有了说明启动了

然后进入命令提示行

输入命令

C:\php7/php-cgi.exe -b 127.0.0.1:9000 -c C:\php7/php.ini

提示:

C:/php7/php-cgi.exe -b 127.0.0.1:9000 -c C:/php7/php.ini

C:/php7根据自己的文件解压路径填写

按回车 运行命令

如果出现以下错误

需要安装

根据自己的系统选择安装

然后重试

正常启动后

现在测试下,根目录放个 ceshi.php的文件

里面写上

<?php
echo ;
?>

http://47.92.31.46/ceshi.php

把自己以前的文件全部拷贝到这个目录就可以

补充

如果现在关闭控制台

PHP功能也会关闭

咱用这个来解决这个问题

打开下面的文件,改一下自己的php  和 nginx 路径

然后双击启动即可

3-OpenResty 配置PHP的更多相关文章

  1. openresty配置

    目录 环境 wsl安装 openresty安装 openssl版本问题 Lua模块安装 openresty使用 nginx常用命令 nginx.conf 配置 lua 的一些坑 OpenResty缓存 ...

  2. 基于openresty配置https访问

    安装方法:http://openresty.org/cn/linux-packages.html 1. openssl的版本信息 [root@localhost conf]# openssl vers ...

  3. openresty 配置 mongodb 可操作插件

    1.下载lua-resty-mongol https://github.com/bigplum/lua-resty-mongol 2.配置_mongo.conf文件,在conf创建_mongo.con ...

  4. Openresty 进行路由系统设计

    1.系统基础设计图为: 用户通过Http访问Openresty(Nginx + Lua), 其中Nginx虚拟主机中配置文件进行Lua脚本加载. LUA通过nginx内置变量或者http请求中变量来区 ...

  5. 使用ZeroBrane Studio调试Openresty lua脚本

    介绍 ZeroBraneStudio 作为轻量级.跨平台的Lua IDE,已被广泛用来调试各种Lua引擎游戏框架.Openresty.Wireshark脚本等等. Openresty 是一个建立在Ng ...

  6. openresty 集成 sentry 异常系统

    sentry 是一个方便的错误异常追踪系统,同时社区也提供了openresty 的lua 包,使用docker-compose 进行测试 备注: sentry 部分的配置来自官方文档 环境准备 doc ...

  7. 使用prometheus+ grafana+nginx-module-vts 模块监控openresty

      nginx-module-vts 是一个很不错的nginx 模块,我们可以用来,方便的分析系统的请求状态 同时支持基于prometheus 的监控, 我参考openresty 的docker镜像已 ...

  8. openresty + lua 2、openresty 连接 redis,实现 crud

    redis 的话,openresty 已经集成,ng 的话,自己引入即可. github 地址:https://github.com/openresty/lua-resty-redis github  ...

  9. docker 安装 openresty

    文章来源: 1.拉取镜像 # docker pull openresty/openresty 2.启动openresty # docker run -it --name openresty -p : ...

  10. Nginx 配置埋点js日志采集

    页面埋点&nginx日志采集 页面(web容器:httpd/nginx负载均衡 + apache server)<===> 日志采集服务器(nginx服务器) 通过某个页面跳转到我 ...

随机推荐

  1. 小记:iterator && auto

    小记:iterator && auto iterator 众所周知,我们有一种强大的东西,它叫做STL,比如queue.vector.set.map.multimap .deque等. ...

  2. [转帖]k8s 中的服务如何沟通

    k8s 中的服务如何沟通 https://www.jianshu.com/p/9fae09876eb7 本文将介绍 k8s 中的服务如何相互访问,例如后端服务访问数据库,不同类型的服务间的相互访问.并 ...

  3. spring-session-jdbc 使用

    这个文档比较有用了,参考: https://www.cnblogs.com/davidwang456/p/10361550.html>https://www.cnblogs.com/davidw ...

  4. 优先队列 + 模拟 - HDU 5437 Alisha’s Party

    Alisha’s Party Problem's Link Mean: Alisha过生日,有k个朋友来参加聚会,由于空间有限,Alisha每次开门只能让p个人进来,而且带的礼物价值越高就越先进入. ...

  5. Unity3d—GUI能量条

    1.打开Unity编辑器. 2.在脚本文件夹中添加C#脚本,我的是添加了skill_01这个脚本.(要自己设置文件夹,方便管理,不然文件添乱不方便管理) 3.注意,脚本的名字一旦确定就不要去改动,因为 ...

  6. 【CF285E】Positions in Permutations(动态规划,容斥)

    [CF285E]Positions in Permutations(动态规划,容斥) 题面 CF 洛谷 题解 首先发现恰好很不好算,所以转成至少,这样子只需要确定完一部分数之后剩下随意补. 然后套一个 ...

  7. Docker核心组件的关系

  8. SSL证书格式转换

    crt格式转pem openssl x509 -in www.x.com.crt -out www.x.com.pem openssl x509 -in mycert.crt -out mycert. ...

  9. windows下生成ssl

    1.安装git window 需要安装 git 按部就班即可 https://git-scm.com/ 2.安装完之后,打开 Git Bash 输入以下命令并执行,然后一路按“回车”即可,效果见图: ...

  10. IDEA 部署spring Cloud

    Spring cloud Eureka Eureka Server,注册中心 Eureka Client,所有要进行注册的微服务通过Eureka Client 连接到 Eureka Server ,完 ...