安装 Debian9
使用网络安装最小包就可以
选择镜像地址的时候记得选择China->mirrors.163.com
软件选择除了 ssh 都不选择
配置 ssh
修改 sshd_config 允许root登录和公钥登录
添加公钥至~/.ssh/authorized_keys
更新 软件源
虽然安装时选了一个软件园但是不够
/etc/apt/sources.list
deb http://mirrors.163.com/debian/ stretch main non-free contrib
deb http://mirrors.163.com/debian/ stretch-updates main non-free contrib
deb http://mirrors.163.com/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.163.com/debian/ stretch main non-free contrib
deb-src http://mirrors.163.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.163.com/debian/ stretch-backports main non-free contrib
deb http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib
deb-src http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib
更新 apt
apt update
安装 rsync
apt install rsync
安装 nginx
安装: apt install nginx
配置: /etc/nginx/site-enables/default
测试: nginx -t
重启: systemctl nginx reload
安装 php
安装: apt install php-fpm php-mysql
配置:
location ~\.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
安装 mysql
apt install mysql-server
sudo mysql_secure_installation
mysql 命令
远程访问
修改 /etc/mysql/mariadb.conf.d/50-server.cnf
注释掉 bind-address
/etc/init.d/mysql restart
新建用户
create user “test”@"%" identified by “passwd123”;
新建数据库
create database newdb default charset utf8 collate utf8_general_ci;
授权
grant all privileges on newdb.* to “test”@"%" identified by “passwd123”;
flush privileges;
配置 ssl
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt
复制两份server配置代码段
第一段添加
rewrite ^/(.*)$ https://domain/$1 permanent;
第二段 监听 443 添加
server {
listen 443 ssl;
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;