演示网站URL: http://vip.262235.xyz:193/phpinfo.php
-
相关文章: https://github.com/hongwenjun/vps_setup/tree/remove/Arch#readme
-
先决条件: 先刷社区大佬的 MilkV Arch Linux 镜像,能使用
pacman
正常安装软件 -
参考文章: Milkv duo Arch Linux 安装 iperf3 gcc make gdb strace vim htop wget curl tmux fish
MilkV Arch Linux 安装 Nginx + PHP-FPM 配置填坑笔记
1. 安装nginx和php-fpm挺简单,启用服务 systemctl enable
pacman -S nginx php php-fpm
systemctl enable nginx
systemctl enable php-fpm
# 生成index.php
echo "<?php echo phpinfo(); ?>" > /usr/share/nginx/html/index.php
# 调试配置比较坑,会用到重启命令
systemctl restart nginx
systemctl restart php-fpm
2. Arch Wiki 找到的配置,因为 nginx.conf
默认配置 root变量移到了location空间里,导致SCRIPT_FILENAME
失效
# vim /etc/nginx/nginx.conf
# 默认 nginx.conf 配置 root变量移到了location空间里
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
解决方法 root 移出来,或者在 php-fpm 配置里复制一份
# 解决方法 root 移出来
root /usr/share/nginx/html;
# pass PHP scripts to FastCGI server
location ~ \.php$ {
# 404
try_files $fastcgi_script_name =404;
# root /usr/share/nginx/html; ### 在 php-fpm 配置里复制一份 root
# default fastcgi_params
include fastcgi_params;
# fastcgi settings
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
# fastcgi params
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
#fastcgi_param PHP_ADMIN_VALUE "open_basedir=$base/:/usr/lib/php/:/tmp/";
}