树莓派 LNMP

本文档详细介绍了如何在树莓派上搭建LNMP环境,包括安装nginx、php、mariadb,配置DNS服务器以及新建多个站点。内容涵盖了服务的安装、常用命令、配置文件详解以及域名访问的实现。
摘要由CSDN通过智能技术生成

树莓派 LNMP

关键词: raspberry web php dns mysq1

LNMP、LAMP是指一组通常一起使用来运行动态网站或者服务器的自由软件名称首字母缩写,
分别指 Linux、Nginx/Apache、MySQL和PHP。

这里演示如何在树莓派上搭建LNMP环境并配置多个站点。

主要内容:

  • 树莓派安装nginx
  • 树莓派安装php
  • 树莓派安装mariadb
  • 树莓派配置dns
  • 添加多个站点

文档参考:

最新地址: https://taotaodiy-raspi.readthedocs.io/en/latest/raspi/helloraspi_lnmp.html

start003

nginx

Nginx是一款轻量级的Web
服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,在BSD-like
协议下发行。
其特点是占有内存少,并发能力强,事实上nginx的并发能力在同类型的网页服务器中表现较好,
中国大陆使用nginx网站用户有:百度、京东、新浪、网易、腾讯、淘宝等。

安装nginx

sudo apt-get -y install nginx

nginx服务常用的命令

# 检查脚本语法
sudo nginx -t

# 查看 nginx 状态
sudo systemctl status nginx.service
# 重启 nginx
sudo systemctl restart nginx.service
# 开机运行 nginx
sudo systemctl enable nginx.service

这个时候,我们就可以通过树莓派IP来访问nginx。

nginx001

默认站点的相关配置及配置文件:

nginx 默认配置文件 nginx_conf 文件位置 /etc/nginx/nginx.conf

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}


#mail {
#   # See sample authentication script at:
#   # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
# 
#   # auth_http localhost/auth.php;
#   # pop3_capabilities "TOP" "USER";
#   # imap_capabil
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

贪贪贪丶慎独

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值