安装 Nginx、PHP7和Mysqlsudo apt-get update
sudo apt-get install nginx php7.3-fpm php7.3-curl php7.3-gd php7.3-mbstring php7.3-mysql php7.3-imap php7.3-opcache php7.3-xml php7.3-xmlrpc php7.3-zip uw-mailutils php-pear mariadb-server -y
sudo systemctl start php7.3-fpm.service
安装好后先配置Mariadb//安装完毕后,暂时还不能使用,需要通过sudo mysql 登录进行修改密码,授权等操作,这些操作与其他MySQL是一样的。
$ sudo mysql
MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO root@'localhost' IDENTIFIED BY '123456';
MariaDB [mysql]> FLUSH PRIVILEGES;
MariaDB [mysql]> exit;
//需要注意的是,在raspbian中,MySQL默认是无法进行远程登陆的,需要修改配置
$ sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf //默认的配置文件位置
##bind-address = 127.0.0.1 //需要进行注释的内容
配置好Mariadb后启动数据库$ sudo systemctl start mysql.service
$ sudo systemctl restart mysql.service
$ sudo systemctl stop mysql.service
$ sudo systemctl enable mysql.service
配置Nginxsudo nano /etc/nginx/sites-available/default
ctrl+w查找index,在后面加上index.phpindex index.html index.htm index.php;
再在文件中增加一下内容:# Typecho伪静态
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php$1 last;
}
# PHP配置
location ~ .*\.php(\/.*)*$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
}
启动nginxsudo systemctl start nginx
要注意的是,typecho因为涉及到rewrite的问题,需要支持pathinfo,所以他的配置文件并不能写成最简单的location ~ .*\.php$
而是要改成location ~ .*\.php(\/.*)*$