找回密码
 立即加入
搜索
查看: 3156|回复: 0

在树莓派上在线安装web服务

[复制链接]

43

主题

47

回帖

847

积分

管理员

积分
847
发表于 2020-4-18 20:47 | 显示全部楼层 |阅读模式 |回复 |
树莓派支持安装web服务,可以做网站。web服务器安装的软件分别为:nginx,php,mariadb

以下教程为在pi4 Raspbian 10.3上安装成功,安装前,请选择比较快的源,并且以root用户安装。同时,这个教程也适用其它的debian系统。在线安装的好处是,所有的软件总是处于最新状态。

  1. 1,切换到root用户

  2. su root

  3. 输入两次root密码

  4. 2,更新源

  5. apt-get update -y
  6. apt-get upgrade -y
  7. apt-get dist-upgrade -y

  8. apt-get install -y rpi-update

  9. 3,安装php7.3

  10. apt-get install -y php7.3 php7.3-common php7.3-cli php7.3-fpm php7.3-json php7.3-mysql php7.3-zip php7.3-gd  php7.3-mbstring php7.3-curl php7.3-xml php7.3-bcmath

  11. 4,安装nginx

  12. apt-get install -y nginx

  13. 5,配置php.ini和nginx.conf

  14. sed -i 's/^;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' /etc/php/7.3/fpm/php.ini

  15. sed -i 's/# server_names_hash_bucket_size/server_names_hash_bucket_size/' /etc/nginx/nginx.conf

  16. 6,配置nginx

  17. cat > /etc/nginx/sites-enabled/default << "EOF"
  18. # Default server
  19. server {
  20.         listen 80 default_server;
  21.         listen [::]:80 default_server;
  22.       
  23.         server_name _;
  24.         root /var/www/default;
  25.         index index.php index.html index.htm default.html;

  26.         location / {
  27.                 try_files $uri $uri/ =404;
  28.         }

  29.         # pass the PHP scripts to FastCGI server
  30.         location ~ \.php$ {
  31.                 include snippets/fastcgi-php.conf;
  32.                 fastcgi_pass unix:/run/php/php7.3-fpm.sock;
  33.         }

  34.         # optimize static file serving
  35.         location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
  36.                 access_log off;
  37.                 log_not_found off;
  38.                 expires 30d;
  39.         }

  40.         # deny access to .htaccess files, should an Apache document root conflict with nginx
  41.         location ~ /\.ht {
  42.                 deny all;
  43.         }
  44. }
  45. EOF

  46. mkdir -p /var/www/default

  47. wget -P /var/www/default https://gitee.com/nbweb/dnmp_d/raw/master/p.php

  48. rm -rf /var/www/html
  49. chown www-data:www-data -R /var/www
  50. chmod g+s -R /var/www/.

  51. systemctl restart php7.3-fpm
  52. systemctl restart nginx

  53. 7,安装mariadb-server和mariadb-client

  54. apt-get install -y mariadb-server mariadb-client

  55. 设置mariadb的密码

  56. mysqladmin -u root password "123456"

  57. systemctl restart mysql

  58. 8,安装phpmyadmin

  59. wget -P /var/www/default https://files.phpmyadmin.net/phpMyAdmin/5.0.2/phpMyAdmin-5.0.2-all-languages.tar.gz
  60. cd /var/www/default
  61. tar zxf phpMyAdmin-5.0.2-all-languages.tar.gz
  62. mv phpMyAdmin-5.0.2-all-languages phpmyadmin

复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即加入

本版积分规则

Archiver|手机版|小黑屋|玉玲珑

GMT+8, 2024-4-27 13:09 , Processed in 0.020834 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表