树莓派3b安装Nginx和php7和百度语音合成模块

1、安装sox系统mp3音频播放模块(项目需要)

sudo apt-get install lame
sudo apt-get install sox
sudo apt-get install libsox-fmt-mp3

2、安装百度语音合成SDK(项目需要)

sudo pip install baidu-aip

3、安装 Nginx 和 PHP7

树莓派最新的系统(我用的版本:2018-04-18-raspbian-stretch.img)已经抛弃了对php5的支持,所以只能安装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

如果安装成功,可通过 http://树莓派IP 访问到 Nginx 的默认页,Nginx 的根目录在 /var/www/html。

4、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 退出。

5、重启服务即可

sudo service nginx restart

以上步骤在树莓派3B Raspbian Stretch 系统版本上测试通过。

6、Pi Dashboard控制面板安装(监控树莓派的运行状况)

sudo apt-get install git
cd /var/www/html
sudo git clone https://github.com/spoonysonny/pi-dashboard.git

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

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

cd /var/www/html
sudo chown -R www-data pi-dashboard

猜你喜欢

转载自www.cnblogs.com/likai-abc/p/9178345.html