3-OpenResty 配置PHP
- 2019 年 10 月 11 日
- 筆記
https://www.cnblogs.com/yangfengwu/p/11610728.html
由於咱以前是用PHP做的東西,又不想重新用 OpenResty自帶的編寫,所以呢咱設置下,可以像以前Apache那樣訪問PHP文件
還記得咱當時怎麼安裝的PHP不 https://www.cnblogs.com/yangfengwu/p/11037653.html
修改 php.ini
修改咱的 openresty裡面的 nginx.conf
注:如果訪問的路徑一樣,單獨拿出來設置
那個 9000埠 咱一會會用到,自己可以規定哈
server { #虛擬主機 listen 80; # 監聽埠 server_name localhost; # 監聽域名 #charset koi8-r; #access_log logs/host.access.log main; root "C:openresty-1.15.8.2-win64html";#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; ?>
把自己以前的文件全部拷貝到這個目錄就可以