小白的树莓派. Install nginx+php+sqlite

Raspberry Pi的arm较弱,考虑到超长时间待机的发热、功耗,没有装desktop的必要,还是terminal放心。

但每次ssh登陆rpi监控状态感觉还是不爽,最终决定做个web展示,方便查看。

LAMP牛刀太重了,还是选择了nginx+php+sqlite。

1.安装软件包

pacman -S nginx php php-fpm sqlite

2.配置nginx

   vim /etc/nginx/nginx.conf 只列一下我改动的地方

 server {

        root   /usr/share/nginx/html;


        location / {

            index  index.html index.htm index.php;

        }


        location ~ \.php$ {

             fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;

             fastcgi_index  index.php;

             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

             include        /etc/nginx/fastcgi_params;

        }

        location ~ /\.ht {

             deny  all;

        }

3.配置php

    vim /etc/php/php.ini

    首先,在open_basedir 条目中增加nginx的根目录

open_basedir = /usr/share/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/

    其次,启用以下扩展

extension=curl.so

extension=gd.so

extension=gettext.so

4.配置php-pfm

    vim /etc/php/php-fpm.conf

    listen填入nginx.conf中的fastcgi_pass值。

listen = /run/php-fpm/php-fpm.sock

5.开机启动和启动服务

   systemctl enable nginx.service
   systemctl enable mysqld.service
   systemctl enable php-fpm.service
   systemctl start nginx.service
   systemctl start mysqld.service
   systemctl start php-fpm.service

6.测试nginx,web访问http://192.168.1.109

   测试php,建立test.php,web访问http://192.168.1.109/test.php

<?php phpinfo(); ?>


你可能感兴趣的:(小白的树莓派. Install nginx+php+sqlite)