免构建安装 nginx php-fpm 快速运行 php 项目

文档说明:只记录关键地方; 发布时间: 2024-06-20
需求: linux 、macos 环境下,免构建安装 nginx php-fpm 快速运行 php 项目
运行环境: linux、 macos
状态: 已完成
实现原理: 静态编译 nginx 、php-fpm
例子: 快速运行 导航站点 onenav、Z-BlogPHP博客 、Discuz 论坛 、ThinkAdmin、fusionpbx

下载 nginx 、php-fpm脚本 和 运行时

git clone https://gitee.com/jingjingxyk/quickstart-nginx-php-fpm.git
cd quickstart-nginx-php-fpm
# 下载nginx
bash setup-nginx-runtime.sh
# 下载php-fpm
bash setup-php-fpm-runtime.sh
# 启动 nginx php-fpm
bash start.sh
# 重载入 nginx php-fpm
bash reload.sh
# 停止 nginx php-fpm
bash stop.sh

实操例子一: 快速 运行一个书签导航站点 onenav

cd /home/jingjingxyk
git clone https://github.com/helloxz/onenav.git
cd quickstart-nginx-php-fpm
# 下载nginx
bash setup-nginx-runtime.sh
# 需要下载 php-fpm-7.4
bash setup-php-fpm-7.4-runtime.sh
bash start.sh
# 修改nginx 配置
vi nginx.conf
root /home/jingjingxyk/onenav ;
# 重新载入nginx配置
bash reload.sh
# 打开浏览器 http://localhost 即可预览此项目

实操例子二: 快速 运行一个博客 Z-BlogPHP博客程序

cd /home/jingjingxyk/
git clone https://github.com/zblogcn/zblogphp.git
cd quickstart-nginx-php-fpm
# 下载nginx
bash setup-nginx-runtime.sh
# 需要下载 php-fpm
bash setup-php-fpm-runtime.sh
bash start.sh
# 修改nginx 配置
vi nginx.conf
root /home/jingjingxyk/zblogphp ;
# 重新载入nginx配置
bash reload.sh
# 打开浏览器 http://localhost 即可预览此项目

实操例子三: 快速 运行 Discuz 论坛 程序

cd /home/jingjingxyk/
git clone -b v3.5-20231221 https://gitee.com/Discuz/DiscuzX.git
cd quickstart-nginx-php-fpm
# 下载nginx
bash setup-nginx-runtime.sh
# 需要下载 php-fpm
bash setup-php-fpm-runtime.sh
bash start.sh
# 修改nginx 配置
vi nginx.conf
root /home/jingjingxyk/DiscuzX/upload ;
# 重新载入nginx配置
bash reload.sh
# 打开浏览器 http://localhost 即可预览此项目

实操例子四: 快速 运行 ThinkAdmin 程序

cd /home/jingjingxyk/
git clone https://gitee.com/zoujingli/ThinkAdmin.git
cd quickstart-nginx-php-fpm
# 下载nginx
bash setup-nginx-runtime.sh
# 需要下载 php-fpm
bash setup-php-fpm-runtime.sh
bash start.sh
# 修改nginx 配置
vi nginx.conf
root /home/jingjingxyk/ThinkAdmin/public/ ;
# 设置 伪静态
location / {
try_files $uri /index.php$request_uri;
}
location ~ ^/index\.php(/|$) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_hide_header X-Powered-By;
}
# 重新载入nginx配置
bash reload.sh
# 打开浏览器 http://localhost 即可预览此项目

备注 切换 nginx php-fpm 版本

修改下载脚本setup-php-fpm-runtime.sh 、setup-nginx-runtime.sh 里 nginx 、php-fpm版本 配置即可

参考文档:

  1. quickstart-nginx-php-fpm
  2. php nginx 配置
  3. symfony web server configurationg for nginx
  4. laravel web server configurationg for nginx
  5. wordpress web server configurationg for nginx
  6. nextcloud web server configurationg for nginx
  7. 使用nginx部署网站
  8. nginx 伪静态配置参考
  9. php-fpm www.conf
  10. php-fpm php-fpm.conf
  11. build-static-nginx
  12. swoole-cli
  13. php-cli
  14. php-fpm
  15. Swoole-Cli 5.0.1:PHP 的二进制发行版
  16. ELF ( Executable and Linkable Format ) 可执行和可链接格式 首字母缩略词 解释

快速准备php运行时

curl https://github.com/swoole/swoole-cli/blob/main/setup-php-runtime.sh?raw=true | bash -s -- --mirror china
curl https://gitee.com/jingjingxyk/swoole-cli/raw/main/setup-php-runtime.sh | bash -s -- --mirror china
posted @   jingjingxyk  阅读(73)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
点击右上角即可分享
微信分享提示