php&nginx&php-fpm&mysql&redis&php simple server code

本文介绍如何配置Nginx以支持PHP处理,并涉及mysql和redis的基本安装步骤。此外,还提供了一个简单的PHP API请求处理示例。

overview

nginx 本身不具备解析 php 的能力,通过,识别 *.php 的请求,将请求交给 php fpm 进行处理

首先启动 php fpm 服务

这里写图片描述

      location ~ \.php$ {
            root           /Users/liyang/programmer/project/vpn-project/vpn_server/OpenVpn/web;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

1 php 解析 Post 请求

原始 php 通过 $_POST[{key}] 获取 请求中的参数,获取php 请求中的数据 需要更改 php 的配置文件

获取 php 配置文件的位置

php --ini 

2 mysql 配置

下载mysql 并安装 myql -u -root -p 进行登录即可
mysql 配置文件, my.cnf 通常位于 /etc/ 或 /etc/mysq/ 目录下

3 redis

下载redis 并安装

4 php 请求处理

新建php文件,请求至 api.php 文件,前端将方法作为参数,传于其中,Php 获取请求中的 方法后,执行即可,代码如下

if (empty($function) || empty($_POST) || !function_exists($function())) {
         header('HTTP/1.1 404 Not Found');
         return;
}
// header('Content-type: application/json');
echo $function();

5 后言

使用服务时,通常都伴随着配置文件,在进行环境搭建,以及代码编写过程中,切记万变不离其宗。

6 Issue

nginx sudo 启动文件权限问题,什么时候出现权限问题,怎么解决权限问题(明晰什么时候出现权限问题,解决之道自生)

docker 文件权限问题

git 代码提交后,对文件权限的更改,是否依旧会一并提交。

[root@yfw ~]# cd /www/wwwroot/yfw.szrengjing.com [root@yfw yfw.szrengjing.com]# ./deploy.sh 🔧 开始自动化部署... fatal: not a git repository (or any of the parent directories): .git fatal: not a git repository (or any of the parent directories): .git No composer.json in current directory, do you want to use the one at /www/wwwroot? [Y,n]? y Always want to use the parent dir? Use "composer config --global use-parent-dir true" to change the default. Installing dependencies from lock file Verifying lock file contents can be installed on current platform. Nothing to install, update or remove Generating optimized autoload files 1 package you are using is looking for funding. Use the `composer fund` command to find out more! Could not open input file: think Could not open input file: think chown: changing ownership of 'public/.user.ini': Operation not permitted chmod: changing permissions of 'public/.user.ini': Operation not permitted PHP Warning: require(/www/wwwroot/yfw.szrengjing.com/vendor/autoload.php): failed to open stream: No such file or directory in Standard input code on line 2 Warning: require(/www/wwwroot/yfw.szrengjing.com/vendor/autoload.php): failed to open stream: No such file or directory in Standard input code on line 2 PHP Fatal error: require(): Failed opening required '/www/wwwroot/yfw.szrengjing.com/vendor/autoload.php' (include_path='.:') in Standard input code on line 2 Fatal error: require(): Failed opening required '/www/wwwroot/yfw.szrengjing.com/vendor/autoload.php' (include_path='.:') in Standard input code on line 2 Failed to reload php7.4-fpm.service: Unit php7.4-fpm.service not found. 🎉 部署完成 [root@yfw yfw.szrengjing.com]# lsattr /www/wwwroot/yfw.szrengjing.com/public/.user.ini ----i---------e----- /www/wwwroot/yfw.szrengjing.com/public/.user.ini [root@yfw yfw.szrengjing.com]# chattr -i /www/wwwroot/yfw.szrengjing.com/public/.user.ini [root@yfw yfw.szrengjing.com]# cd /www/wwwroot [root@yfw wwwroot]# [root@yfw wwwroot]# # 备份旧站点 [root@yfw wwwroot]# mv yfw.szrengjing.com yfw.szrengjing.com.bak [root@yfw wwwroot]# [root@yfw wwwroot]# # 使用 Composer 创建新 TP6 项目 [root@yfw wwwroot]# composer create-project topthink/think yfw.szrengjing.com Creating a "topthink/think" project at "./yfw.szrengjing.com" Cannot use topthink/think's latest version v8.1.3 as it requires php >=8.0.0 which is not satisfied by your platform. Installing topthink/think (v6.1.0) - Downloading topthink/think (v6.1.0) - Installing topthink/think (v6.1.0): Extracting archive Created project in /www/wwwroot/yfw.szrengjing.com Loading composer repositories with package information Updating dependencies Lock file operations: 17 installs, 0 updates, 0 removals - Locking league/flysystem (1.1.10) - Locking league/flysystem-cached-adapter (1.1.0) - Locking league/mime-type-detection (1.16.0) - Locking psr/cache (1.0.1) - Locking psr/container (1.1.2) - Locking psr/http-message (1.1) - Locking psr/log (1.1.4) - Locking psr/simple-cache (1.0.1) - Locking symfony/polyfill-mbstring (v1.33.0) - Locking symfony/polyfill-php72 (v1.31.0) - Locking symfony/polyfill-php80 (v1.33.0) - Locking symfony/var-dumper (v4.4.47) - Locking topthink/framework (v6.1.5) - Locking topthink/think-filesystem (v1.0.3) - Locking topthink/think-helper (v3.1.11) - Locking topthink/think-orm (v2.0.62) - Locking topthink/think-trace (v1.6) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 17 installs, 0 updates, 0 removals - Downloading psr/cache (1.0.1) - Downloading psr/container (1.1.2) - Downloading psr/http-message (1.1) - Downloading symfony/var-dumper (v4.4.47) - Downloading topthink/think-helper (v3.1.11) - Downloading psr/simple-cache (1.0.1) - Downloading psr/log (1.1.4) - Downloading topthink/think-orm (v2.0.62) - Downloading topthink/framework (v6.1.5) - Downloading league/flysystem (1.1.10) - Downloading league/flysystem-cached-adapter (1.1.0) - Downloading topthink/think-filesystem (v1.0.3) - Downloading topthink/think-trace (v1.6) - Installing league/mime-type-detection (1.16.0): Extracting archive - Installing psr/cache (1.0.1): Extracting archive - Installing psr/container (1.1.2): Extracting archive - Installing psr/http-message (1.1): Extracting archive - Installing symfony/polyfill-php80 (v1.33.0): Extracting archive - Installing symfony/polyfill-php72 (v1.31.0) - Installing symfony/polyfill-mbstring (v1.33.0): Extracting archive - Installing symfony/var-dumper (v4.4.47): Extracting archive - Installing topthink/think-helper (v3.1.11): Extracting archive - Installing psr/simple-cache (1.0.1): Extracting archive - Installing psr/log (1.1.4): Extracting archive - Installing topthink/think-orm (v2.0.62): Extracting archive - Installing topthink/framework (v6.1.5): Extracting archive - Installing league/flysystem (1.1.10): Extracting archive - Installing league/flysystem-cached-adapter (1.1.0): Extracting archive - Installing topthink/think-filesystem (v1.0.3): Extracting archive - Installing topthink/think-trace (v1.6): Extracting archive 12 package suggestions were added by new dependencies, use `composer suggest` to see details. Generating autoload files > @php think service:discover Succeed! > @php think vendor:publish Succeed! 6 packages you are using are looking for funding. Use the `composer fund` command to find out more! Found 1 security vulnerability advisory affecting 1 package. Run "composer audit" for a full list of advisories. [root@yfw wwwroot]# ls -la /www/wwwroot/yfw.szrengjing.com total 108 drwxr-xr-x 10 root root 4096 Nov 14 17:05 . drwxr-xr-x 13 www www 4096 Nov 14 17:05 .. drwxr-xr-x 3 root root 4096 Oct 24 2022 app -rw-r--r-- 1 root root 1138 Oct 24 2022 composer.json -rw-r--r-- 1 root root 37667 Nov 14 17:05 composer.lock drwxr-xr-x 2 root root 4096 Nov 14 17:05 config -rw-r--r-- 1 root root 231 Oct 24 2022 .example.env drwxr-xr-x 2 root root 4096 Oct 24 2022 extend -rw-r--r-- 1 root root 34 Oct 24 2022 .gitignore -rw-r--r-- 1 root root 1822 Oct 24 2022 LICENSE.txt drwxr-xr-x 3 root root 4096 Oct 24 2022 public -rw-r--r-- 1 root root 1459 Oct 24 2022 README.md drwxr-xr-x 2 root root 4096 Oct 24 2022 route drwxr-xr-x 2 root root 4096 Oct 24 2022 runtime -rw-r--r-- 1 root root 180 Oct 24 2022 think -rw-r--r-- 1 root root 2038 Oct 24 2022 .travis.yml drwxr-xr-x 8 root root 4096 Nov 14 17:05 vendor drwxr-xr-x 2 root root 4096 Oct 24 2022 view [root@yfw wwwroot]#
11-15
【CNN-GRU-Attention】基于卷积神经网络和门控循环单元网络结合注意力机制的多变量回归预测研究(Matlab代码实现)内容概要:本文介绍了基于卷积神经网络(CNN)、门控循环单元网络(GRU)与注意力机制(Attention)相结合的多变量回归预测模型研究,重点利用Matlab实现该深度学习模型的构建与仿真。该模型通过CNN提取输入数据的局部特征,利用GRU捕捉时间序列的长期依赖关系,并引入注意力机制增强关键时间步的权重,从而提升多变量时间序列回归预测的精度与鲁棒性。文中涵盖了模型架构设计、训练流程、参数调优及实际案例验证,适用于复杂非线性系统的预测任务。; 适合人群:具备一定机器学习与深度学习基础,熟悉Matlab编程环境,从事科研或工程应用的研究生、科研人员及算法工程师,尤其适合关注时间序列预测、能源预测、智能优化等方向的技术人员。; 使用场景及目标:①应用于风电功率预测、负荷预测、交通流量预测等多变量时间序列回归任务;②帮助读者掌握CNN-GRU-Attention混合模型的设计思路与Matlab实现方法;③为学术研究、毕业论文或项目开发提供可复现的代码参考和技术支持。; 阅读建议:建议读者结合Matlab代码逐模块理解模型实现细节,重点关注数据预处理、网络结构搭建与注意力机制的嵌入方式,并通过调整超参数和更换数据集进行实验验证,以深化对模型性能影响因素的理解。
下载前必看:https://pan.quark.cn/s/da7147b0e738 《商品采购管理系统详解》商品采购管理系统是一款依托数据库技术,为中小企业量身定制的高效且易于操作的应用软件。 该系统借助VC++编程语言完成开发,致力于改进采购流程,增强企业管理效能,尤其适合初学者开展学习与实践活动。 在此之后,我们将详细剖析该系统的各项核心功能及其实现机制。 1. **VC++ 开发环境**: VC++是微软公司推出的集成开发平台,支持C++编程,具备卓越的Windows应用程序开发性能。 在该系统中,VC++作为核心编程语言,负责实现用户界面、业务逻辑以及数据处理等关键功能。 2. **数据库基础**: 商品采购管理系统的核心在于数据库管理,常用的如SQL Server或MySQL等数据库系统。 数据库用于保存商品信息、供应商资料、采购订单等核心数据。 借助SQL(结构化查询语言)进行数据的增加、删除、修改和查询操作,确保信息的精确性和即时性。 3. **商品管理**: 系统内含商品信息管理模块,涵盖商品名称、规格、价格、库存等关键字段。 借助界面,用户能够便捷地录入、调整和查询商品信息,实现库存的动态调控。 4. **供应商管理**: 供应商信息在采购环节中占据重要地位,系统提供供应商注册、联系方式记录、信用评价等功能,助力企业构建稳固的供应链体系。 5. **采购订单管理**: 采购订单是采购流程的关键环节,系统支持订单的生成、审批、执行和追踪。 通过自动化处理,减少人为失误,提升工作效率。 6. **报表与分析**: 系统具备数据分析能力,能够生成采购报表、库存报表等,帮助企业掌握采购成本、库存周转率等关键数据,为决策提供支持。 7. **用户界面设计**: 依托VC++的MF...
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值