树莓派nginx+php+MariaDB配置

1.安装nginx

sudo apt-get install nginx-light

2.安装php

sudo apt-get install php-fpm

3.配置nginx可处理php网页

sudo nano /etc/nginx/sites-available/default
# Default server configuration
#
server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html index.php;

        server_name _;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

        # pass PHP scripts to FastCGI server
        #
        location ~ \.php$ {
        #       include snippets/fastcgi-php.conf;
        #
        #       # With php-fpm (or other unix sockets):
                fastcgi_pass unix:/run/php/php7.3-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
        # 设置脚本文件请求的路径
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        # 引入fastcgi的配置文件 
                include fastcgi_params;
        }

}

4.重启,在/var/www/html添加test.php文件测试

sudo nginx -s reload

5.安装mysql

sudo apt-get install mariadb-server phpmyadmin

        中间会出现一个配置 phpMyAdmin 的选项,由于树莓派用的web服务器是nginx ,所以这里按“Esc”推出,没有选择。

        安装快结束时,又出现了一个配置选项:点击yes进行配置。之后要求输入一个密码,以注册到mysql 服务器上去。输入密码后点击 “OK”,再次确认。

        安装完成后还要把phpmyadmin 连接到 nginx服务器的php根目录上,因此建立软连接:

sudo ln -s /usr/share/phpmyadmin /var/www/html

你可能感兴趣的:(nginx,php)