php - 如何将 Lumen API 投入生产?什么主机?
问题描述
我在 PHP Lumen 中制作了一个 API,并尝试将其投入生产。这是我第一次这样做,所以我有点迷路了^^'
我通常使用启动服务器
php -S localhost:3000 -t public
您能解释一下如何将我的项目投入生产吗?
抱歉,我看了很多文章,但无法理解这一点!
谢谢你的帮助=)
解决方案
我遇到了同样的问题。这是您的问题的解决方案。
- 为您的项目创建服务器块。我正在使用 nginx
server {
server_name <<domin name>>;
root /srv/<<project name>>/public;
index index.php index.html;
client_max_body_size 20M;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php {
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED
$document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
}
location ~* \.(css|less|js|jpg|png|gif)$ {
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
expires 0;
}
}
推荐阅读
- system-design - 系统设计中多级缓存的缺点
- java - Java - 如何从属性文件中读取冒号而不转义文件内?
- python - 为什么我的随机数游戏无法正常运行?
- python - 如何在熊猫数据框中获得所需的行和列名?
- php - 如何修复未定义的变量:laravel 5.6 中的请求
- r - 使用字符向量对 data.table 中的行和列进行子集化
- excel - 时间表加班时间加起来
- java - Java 支持 WS-Fed 与 SAML 作为登录协议
- c# - 检查 Windows 服务是否可以从桌面应用程序访问网络共享(UNC 路径)
- android - 如果 1dp 是 1 英寸的 160 分之一,为什么在每个 android 设备上都不一样,比如 mm?