最近想用樹莓派作一些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!
至此已所有配置完成