sudo systemctl restart nginx
sudo systemctl restart php8.2-fpm
网卡模式选择桥接 mirrors.163.com
阿里镜像源 https://mirrors.aliyun.com/debian/
DeBian 安装软件选择时勾选上 SSH server
apt update
apt install sudo #安装 sudo
usermod -aG sudo username #添加普通账号到 sudo
让 root 可以 SSH , pwd:k4
配置文件 /etc/ssh/sshd_config
找到 PermitRootLogin 选项 并将其值修改为
PermitRootLogin yes
重启ssh
systemctl restart ssh
ifconfig -a 查看IP
sudo reboot 重启
sudo shutdown -h now 关机 -h 是 halt (停止) 的意思
sudo shutdown -r +60 在一个小时后重启(60分钟) -r 是 restart (重启)的意思
sudo shutdown -h +60 在一个小时后关机(60分钟)
共享文件夹
先在 VirtualBox 上添加好
然后在 Debian 客户机上安装了 VirtualBox Guest Additions。这可以提供对共享文件夹的支持和其他增强功能
sudo apt update
sudo apt install virtualbox-guest-additions-iso
sudo mkdir /home/wwwroot
#挂载共享文件夹
#qgmvc5_share 为在 VirtualBox 中设置的共享文件夹名称
sudo mount -t vboxsf qgmvc5_share /home/wwwroot
#设置自动挂载
sudo nano /etc/fstab
未尾添加
qgmvc5_share /home/wwwroot vboxsf defaults 0 0
重新挂载 /etc/fstab 中的所有条目
sudo mount -a
Nginx
sudo apt install nginx
sudo systemctl status nginx
sudo systemctl start nginx #如果服务未启动,可以手动启动它
sudo systemctl enable nginx 设置 Nginx 开机自启
sudo ln -s /usr/sbin/nginx /usr/local/bin/nginx 添加到系统命令
Nginx 的配置文件位于 /etc/nginx 目录下。
具体的站点配置文件位于 /etc/nginx/sites-available 和 /etc/nginx/sites-enabled 目录中
/etc/nginx/sites-available 用于存放所有可用的 Nginx 站点配置文件
/etc/nginx/sites-enabled 用于存放实际要被 Nginx 加载的站点配置文件的符号链接
ln -s <target> <link_name> 创建文件符号链接
ln -s /etc/nginx/sites-available/default.conf /etc/nginx/sites-enabled/default.conf
rm <link_name> 删除文件符号链接
ls -l 可以查看符号链接的详细信息
sudo nginx -t 命令检查配置文件的语法是否正确
sudo nginx -s reload 更新配置
sudo systemctl restart nginx 重启
# 将 nginx 错误日志 绑定到共享目录下的某目录下
error_log /home/wwwroot/debian_logs/nginx_error.log;
http{
access_log off; # 开发环境可以关闭访问日志
}
虚拟主机样例 /etc/nginx/sites-available/world.yiparts.debian.conf
ln -s /etc/nginx/sites-available/world.yiparts.debian.conf /etc/nginx/sites-enabled/world.yiparts.debian.conf
server {
listen 80;
server_name world.yiparts.debian;
root /home/wwwroot/xmvc/project/yiparts; #网站根目录
index index.php index.html index.htm;
location ~ ^/(static|files|cache)/ {
try_files $uri =404; # /xxx/开头的网址直接寻找对应的文件输出,不管文件是否存在
}
location ~* \.(js|css|jpg|jpeg|png|gif|ico|svg)$ {
try_files $uri =404; # 以 .xxx 结尾的直接寻找对应的文件输出,不管文件是否存在
}
location / {
try_files $uri $uri/ /index.php?$query_string; # 除前面的直接输出规则外所有的请求交给 index.php
}
location ~ \.php$ {
include snippets/fastc