树莓派3b,系统 ubuntu-mate 16.04
1、安装 Nginx 和 PHP7
sudo apt-get update
sudo apt-get install nginx php7.0-fpm php7.0-cli php7.0-curl php7.0-gd php7.0-mcrypt php7.0-cgi php7.0-sqlite3 php7.0-mysql
sudo service nginx start
sudo service php7.0-fpm restart
复制代码
2、如果安装成功,可通过 http://树莓派IP 访问到 Nginx 的默认页。Nginx 的根目录在 /var/www/html。 进行以下操作来让 Nginx 能处理 PHP。
sudo vi /etc/nginx/sites-available/default
复制代码
将其中的如下内容
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
复制代码
替换为
location / {
index index.html index.htm index.php default.html default.htm default.php;
}
location ~\.php$ {
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
复制代码
保存之后重启nginx
sudo service nginx restart
以上
转载请注明原文链接和作者,作者:玩双截棍的熊猫