建立 NGINX 网络服务器在 Raspberry Pi
sudo apt update
sudo apt install nginx
sudo /etc/init.d/nginx start
测试网络服务
http://localhost/
安装 PHP
sudo apt install php7.3-fpm
cd /etc/nginx
sudo vim sites-enabled/default
增加index.php 在 index 后面
index index.php index.html index.htm;
找到如下内容
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
# location ~ \.php$ {
去掉#符号
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
应该像这样:
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
重新加载服务器
sudo /etc/init.d/nginx reload
测试 PHP
重命名index.nginx-debian.html 为 index.php:
cd /var/www/html/
sudo mv index.nginx-debian.html index.php
打开 index.php
sudo vim index.php
增加动态 PHP 内容,替代现在的内容
<?php echo phpinfo(); ?>
保存并刷新浏览器,你会看到网页包含php版本,logo和目前的设置