前言

由于咱以前是用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. c# CRC16位校验辅助类

    public class CRC16Helper { /// <summary> /// CRC校验 /// </summary> /// <param name=&qu ...

  2. HTML5网页上播放mp4失败的原因

    HTML5先网页直接打开mp4 如果打不开 先用格式工厂转化下格式 转成mp4 avc编码 就行了 ps:ae要先导出mp4 然后再用上面的方法 不要导出avi 不然转化成 avc也是播放不了

  3. Gin框架 - 项目目录

    概述 今天给大家分享,在 API 端使用 Gin 框架时,项目的目录. 目录 ├─ Project Name │ ├─ config //配置文件 │ ├── ... │ ├─ controller ...

  4. js中的方法如何传入多个参数

    js中的方法如何传入多个参数 $(function () { let parameter1 = 1; let parameter2 = 'Hello World'; let parameter3 = ...

  5. MobaXterm的安装和使用

    MobaXterm的安装和使用 安装 1 下载网址:https://mobaxterm.mobatek.net/,选择“Download”,选择免费版的下载. 2 解压压缩包,双击exe文件安装软件, ...

  6. Asp.Net页面刷新防止跳转到其他浏览器或新的选项卡

    前端页面js代码: <head> <script> window.name = "PremaritalCheckup_ManSocietyAgreeForm" ...

  7. css层叠规则(层叠样式表)

    CSS层叠规则: 1.找出所有相关的规则,这些规则都包含与一个给定元素匹配的选择器. 2.按权重(!important)和来源对应用到给定元素的所有声明进行排序. 3.按特殊性对应用到给定元素的所有声 ...

  8. ES6 模块(八)

    在node环境中运行需要使用babel命令将ES6代码转换为ES5代码再执行相关文件使用命令直接将src目录下所有ES6代码转换ES5代码到dist目录下: $ babel src --out-dir ...

  9. 结对编程(Python实现)

    一.Github地址:https://github.com/nullcjm/mypage 项目搭档:3117004662梁子豪 3117004648陈俊铭 二.PSP表格: PSP2.1 Person ...

  10. 定时任务突然中止,告警:Thread starvation or clock leap detected

    1.背景 定时任务告警信息如下: 02:38:24.112 [HikariPool-1 housekeeper] WARN  com.zaxxer.hikari.pool.HikariPool - H ...