树莓派 LNMP
关键词: raspberry web php dns mysq1
LNMP、LAMP是指一组通常一起使用来运行动态网站或者服务器的自由软件名称首字母缩写,
分别指 Linux、Nginx/Apache、MySQL和PHP。
这里演示如何在树莓派上搭建LNMP环境并配置多个站点。
主要内容:
- 树莓派安装nginx
- 树莓派安装php
- 树莓派安装mariadb
- 树莓派配置dns
- 添加多个站点
文档参考:
- https://lnmp.org/
- https://blog.csdn.net/qq_38265137/article/details/83082389
- https://zhuanlan.zhihu.com/p/35764236
最新地址: https://taotaodiy-raspi.readthedocs.io/en/latest/raspi/helloraspi_lnmp.html
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。
默认站点的相关配置及配置文件:
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