因为咱之前是用PHP作的东西,又不想从新用 OpenResty自带的编写,因此呢咱设置下,能够像之前Apache那样访问PHP文件php
首先去下载 PHPhtml
https://windows.php.net/download#php-7.3nginx
或者windows
放到云端而后解压出来php7
改一下名字,名字太长..测试
把php.ini-development 这个文件复制出来一份,,而后名字改成 php.inispa
修改 php.ini.net
修改咱的 openresty里面的 nginx.conf3d
注:若是访问的路径同样,单独拿出来设置rest
那个 9000端口 咱一会会用到,本身能够规定哈
server { #虚拟主机 listen 80; # 监听端口 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 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 # 172.26.94.113 127.0.0.1 location ~ \.php$ {#~区分大小写 \前面任意 后面跟着 .php $ 表明结束 http://IP/任意/任意.php #root html; fastcgi_pass 127.0.0.1:9000; 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
根据本身的安装路径哈,个人安装路径是
9000 就是上面的端口
运行命令
如今测试下,根目录放个 ceshi.php的文件
里面写上
<?php echo 1234; ?>
把本身之前的文件所有拷贝到这个目录就能够