debian9 配置 php ssl 环境

安装 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;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值