Raspberry pi——树莓派Nginx 安装与卸载

安装 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

sudo service nginx start

sudo service php7.0-fpm restart

 

Nginx 的根目录在 /var/www/html

 

进行以下操作来让 Nginx 能处理 PHP

sudo nano /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;

}

 

Ctrl + O 保存再 Ctrl + X 退出

重启 Nginx

 

sudo service nginx restart

 

 

在 GitHub 下载pi-dashboard项目源码,上传到树莓派的 /var/www/html目录下

可以通过 http://树莓派IP/pi-dashboard 访问部署好了的 Pi Dashboard

 

项目主页:http://make.quwj.com/project/10

GitHub  pi-dashboard项目地址:https://github.com/spoonysonny/pi-dashboard

 

如页面无法显示,可以在树莓派终端给源码添加运行权限,例如你上传之后的路径是 /var/www/html/pi-dashboard,运行:

 

cd /var/www/html

sudo chown -R www-data pi-dashboard

 

Raspberry pi——树莓派Nginx 安装与卸载

 

 

nginx 卸载

 

  1. 删除nginx,-purge包括配置文件

sudo apt-get --purge remove nginx

  1. 移除全部不使用的软件包

sudo apt-get autoremove

  1. 罗列出与nginx相关的软件并删除

dpkg --get-selections|grep nginx

sudo apt-get --purge remove nginx

sudo apt-get --purge remove nginx-common

sudo apt-get --purge remove nginx-core

  1. 查看nginx正在运行的进程,如果有就kill掉

ps -ef |grep nginx

sudo kill -9 XXX

  1. 全局查找与nginx相关的文件

sudo  find  /  -name  nginx*

sudo rm -rf file

  1. 删除列出的所有文件

sudo rm -rf file

 

 

 

***********************常用指令*********************************

sudo su                                              #打开最高权限

chmod a+rwx /xxx/xx/xx/                    #打开文件夹权限

sudo rm -rf /var/www/html/pi                 # 删除文件夹

halt                                                          #关机