最近想用树莓派作一些web测试,没想到配置的过程比我想象的复杂,php
我已经尝试写的很简洁了,各位看官随意html
sudo apt-get update #更新源 sudo apt-get install php7.3 php7.3-fpm php7.3-mysql php7.3-common sudo apt-get install nginx sudo service nginx start #重启nginx sudo service php7.3-fpm restart #重启php
sudo apt-get install mariadb-client-10.0 mariadb-server-10.0
/etc/init.d/nginx restart #重启nginx
sudo service php7.3-fpm restart #重启php
service mysql restart
此处须要选择Nginx链接到php服务的形式,tcp模式或者socket模式。mysql
首先要找到 www.conf 文件,个人文件位置在/etc/php/7.3/fpm/pool.d
nginx
编辑www.conf
文件参考:web
vim /etc/php/7.3/fpm/pool.d/www.conf
找到参数listen = /run/php/php7.3-fpm.sock
sql
请记住该参数,这将会在配置Nginx时用到。shell
修改配置文件nginx.conf
参考:vim
vim /etc/nginx/nginx.conf #在HTTP{}内有 include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; #修改成: include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*.conf;
以default
文件为模版,在sites-enabled文件夹下创建网站配置文件,shell参考以下:php7
cd /etc/nginx/sites-enabled cp default my.conf vim my.conf
配置站点信息,参考以下:socket
location / { root /home/www; index index.php index.html; try_files $uri $uri/ =404; } location ~ \.php$ { root /home/www; fastcgi_pass unix:/run/php/php7.3-fpm.sock;#socket mode #fastcgi_pass 127.0.0.1:9000;#tcp mode fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params;
建议先使用<?php phpinfo();?>进行测试一下
select Host,User,plugin from mysql.user where User='root'; 这个时候会发现plugin(加密方式)是unix_socket, >> update mysql.user set plugin='mysql_native_password'; #重置加密方式 >> update mysql.user set password=PASSWORD("newpassword") where User='root'; #设置新密码 >> flush privileges; #刷新权限信息 OK!
sudo vim/etc/mysql/mariadb.conf.d/50-server.cnf
将bind-address = 127.0.0.1 改成: bind-address = 0.0.0.0
update user set host='%' where user='root' and host='localhost';
flush privileges;
OK!
至此已所有配置完成