diff --git "a/\350\265\226\345\277\203\345\246\215/20240606 PacVim \344\270\216 SSL\350\257\201\344\271\246 - nginx.md" "b/\350\265\226\345\277\203\345\246\215/20240606 PacVim \344\270\216 SSL\350\257\201\344\271\246 - nginx.md" index 64015cf0ceddcd80eab955157e9134cdb92bdd2b..50d2951cfbd94b8f9631e20f5df244dd2fcff3b7 100644 --- "a/\350\265\226\345\277\203\345\246\215/20240606 PacVim \344\270\216 SSL\350\257\201\344\271\246 - nginx.md" +++ "b/\350\265\226\345\277\203\345\246\215/20240606 PacVim \344\270\216 SSL\350\257\201\344\271\246 - nginx.md" @@ -70,7 +70,7 @@ server { ```bash # 在nginx执行目录下执行命令 -sbin/nginx -t +/sbin/nginx -t # 但是执行目录也有可能在/etc/nginx # 所以可以进入/etc/nginx执行命令 diff --git "a/\350\265\226\345\277\203\345\246\215/20240624 \345\256\211\350\243\205apache.md" "b/\350\265\226\345\277\203\345\246\215/20240624 \345\256\211\350\243\205apache.md" new file mode 100644 index 0000000000000000000000000000000000000000..45db730fdb07f6198d9b619a6e273052fc0931bd --- /dev/null +++ "b/\350\265\226\345\277\203\345\246\215/20240624 \345\256\211\350\243\205apache.md" @@ -0,0 +1,57 @@ +## 安装apache + +先将网页文件备份,因为安装apache会将nginx覆盖 + +安装Apache + +```bash +apt update +apt install apache2 +``` + +因为原先安装nginx所以需要更改nginx端口或者更改apache端口 + +```bash +# 进入配置文件 +cd /etc/nginx +# 因为配置独立分开,所以配置文件不是nginx.conf,而是conf.d/域名.conf +# 将端口更改为8080 +``` + +![858f226ac1424827598bd23d8e788d9](assets/20.png) + +```bash +# 保存退出后测试配置文件并重启nginx服务 +/sbin/nginx -t +systemctl restart nginx +``` + +华为云添加安全组 + +控制台 - 安全组 + +![c29573ba1058e3ecbc072ada2d78bdc](assets/21.png) + +选择安全组 + +点击配置规则 + +![770b2fda0a02caf1730a1180f55e1eb](assets/22.png) + +点击快速添加规则 + +![c75bfb24c26ec247b9f38564ab7477d](assets/23.png) + +选择相应端口号添加即可 + +```bash +# nginx配置过ssl证书,做了https与http的重定向 +# 用http协议打开网页加上端口号可以访问 +# 但是https不行,因为暂时没有找到https更改端口号的方法,https默认端口号为443 +``` + +## 安装防火墙utw + +```bash +apt install utw +``` diff --git "a/\350\265\226\345\277\203\345\246\215/20240701 apache\344\270\216 mysql.md" "b/\350\265\226\345\277\203\345\246\215/20240701 apache\344\270\216 mysql.md" new file mode 100644 index 0000000000000000000000000000000000000000..14d28bd691722c9a4c33dbcfc72d0d54f6a60c6e --- /dev/null +++ "b/\350\265\226\345\277\203\345\246\215/20240701 apache\344\270\216 mysql.md" @@ -0,0 +1,179 @@ +## apache 添加二级域名 + +### 华为云域名解析添加新的域名解析 + +#### 点击云解析服务DNS + +![25](assets\24.PNG) + +#### 点击管理解析 + +![26](assets\25.PNG) + +#### 点击添加记录集 + +![27](assets\26.PNG) + +#### 将主机记录填写新的二级域名(别名) + +![28](assets\27.PNG) + +#### 配置apache文件 + +```bash +# 进入apache配置文件的目录 +cd /etc/apache2/sites-available +# 修改配置文件000-default.conf +``` + +![29](assets\28.PNG) + +#### 测试重启服务 + +```bash +# 测试apache服务 +apache2ctl configtest +# 重启apache服务 +systemctl restart apache2 +``` + +#### 最后查看网页别名+域名 + +```bash +jh.leejaehyunow.top +``` + +可能会出现443端口冲突,记得在ports.conf将端口改成其他 + +## apache 配置SSL证书 + +#### 上传证书文件到指定路径 + +``` +# 连接 +sftp root@60.204.154.55 +# 找到路径 +``` + +可以在apache2里新建一个文件夹ssl将密钥文件放进去 + +![](assets\29.png) + +#### 修改apache配置文件 + +sites-available目录下的000-default.conf文件 + +![31](assets\30.PNG) + +```bash +# 安装证书 +SSLEngine on +SSLCertificateFile /etc/apache2/ssl/server.crt +SSLCertificateKeyFile /etc/apache2/ssl/server.key +``` + +在apache2.conf文件最后一行添加内容 + +![bf4ed8fca05f89876e6322c0d419711](assets\31.PNG) + +``` +LoadModule ssl_module modules/mod_ssl.so +``` + +#### 开启ssl模块 + +```bash +a2enmod ssl +``` + +## 安装MySQL + +#### 下载MySQL + +这个是下载mysql所以建议选好位置,可以在家目录操作 + +```bash +wget https://dev.mysql.com/get/mysql-apt-config_0.8.30-1_all.deb +dpkg -i mysql-apt-config_0.8.30-1_all.deb +``` + +#### 安装MySQL + +```bash +apt update +apt install mysql-server +``` + +如果出现报错找不到mysql-server包可以试试替换一下仓库源 + +```bash +# 进入软件源目录 +cd /etc/apt/ + +# 修改sources.list文件 +vim sources.list + +# 将内容替换 +deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free +deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free +deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free +deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free +deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free +deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free +deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free +deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free +``` + +![b0d51178867d47b4c5f72094e5f8973](assets\32) + +![806a34133e4295731bc003d713c1dca](\assets\33) + +![309c75e5b444a601b9401b9a0658f62](\assets\34) + +安装过程中会显示设置mysql root密码 + +#### 连接数据库 + +```bash +mysql -u root -p +``` + +## MySQL 连接远程 + +#### 进入mysql + +```bash +mysql -u root -p +``` + +#### 添加权限 + +```mysql +use mysql; +# 查看用户 +select user,host from user; +# 修改用户权限 +update user set host='%' where user='root'; +grant all privileges on *.* to 'root'@'%' with grant option; +# 更新列表 +flush privileges; +``` + +可以用native连接或者cmd连接试试 + +```bash +# cmd 连接 mysql 命令 +mysql -h 域名或ip -P mysql端口号 -u mysql用户名 -p +``` + +##### 若连接不上去华为云设置安全组添加规则 + +## 安装postgresql + +```bash +apt update +apt install postgresql -y +# 验证postgresql版本 +sudo -u postgres psql -c "SELECT version();" +``` + diff --git "a/\350\265\226\345\277\203\345\246\215/assets/20.png" "b/\350\265\226\345\277\203\345\246\215/assets/20.png" new file mode 100644 index 0000000000000000000000000000000000000000..88099733cc922cea99e07deb6c2f90ef495b4d45 Binary files /dev/null and "b/\350\265\226\345\277\203\345\246\215/assets/20.png" differ diff --git "a/\350\265\226\345\277\203\345\246\215/assets/21.png" "b/\350\265\226\345\277\203\345\246\215/assets/21.png" new file mode 100644 index 0000000000000000000000000000000000000000..29a4db6432611f932527a0b89b4224f97423228f Binary files /dev/null and "b/\350\265\226\345\277\203\345\246\215/assets/21.png" differ diff --git "a/\350\265\226\345\277\203\345\246\215/assets/22.png" "b/\350\265\226\345\277\203\345\246\215/assets/22.png" new file mode 100644 index 0000000000000000000000000000000000000000..5dcc572c906199ad623a8c0e9644cedb46eeafe6 Binary files /dev/null and "b/\350\265\226\345\277\203\345\246\215/assets/22.png" differ diff --git "a/\350\265\226\345\277\203\345\246\215/assets/23.png" "b/\350\265\226\345\277\203\345\246\215/assets/23.png" new file mode 100644 index 0000000000000000000000000000000000000000..3c6c5a0ea02657c2918d477285443aa7c2a3f90c Binary files /dev/null and "b/\350\265\226\345\277\203\345\246\215/assets/23.png" differ diff --git "a/\350\265\226\345\277\203\345\246\215/assets/24.PNG" "b/\350\265\226\345\277\203\345\246\215/assets/24.PNG" new file mode 100644 index 0000000000000000000000000000000000000000..bf6560bc042abba8492c5eaafb6deef15069cd86 Binary files /dev/null and "b/\350\265\226\345\277\203\345\246\215/assets/24.PNG" differ diff --git "a/\350\265\226\345\277\203\345\246\215/assets/25.PNG" "b/\350\265\226\345\277\203\345\246\215/assets/25.PNG" new file mode 100644 index 0000000000000000000000000000000000000000..791c4a4e1cda71efdb53f31f133681e7e60f1c4b Binary files /dev/null and "b/\350\265\226\345\277\203\345\246\215/assets/25.PNG" differ diff --git "a/\350\265\226\345\277\203\345\246\215/assets/26.PNG" "b/\350\265\226\345\277\203\345\246\215/assets/26.PNG" new file mode 100644 index 0000000000000000000000000000000000000000..f0b8cf0aada55c312da3c145d86f1c5f6ec58fb4 Binary files /dev/null and "b/\350\265\226\345\277\203\345\246\215/assets/26.PNG" differ diff --git "a/\350\265\226\345\277\203\345\246\215/assets/27.PNG" "b/\350\265\226\345\277\203\345\246\215/assets/27.PNG" new file mode 100644 index 0000000000000000000000000000000000000000..51b6fc6963661091d6de9a16e819e978837badca Binary files /dev/null and "b/\350\265\226\345\277\203\345\246\215/assets/27.PNG" differ diff --git "a/\350\265\226\345\277\203\345\246\215/assets/28.PNG" "b/\350\265\226\345\277\203\345\246\215/assets/28.PNG" new file mode 100644 index 0000000000000000000000000000000000000000..27f7f4fbedb27cd3407a2ccecbdfa55b8849415e Binary files /dev/null and "b/\350\265\226\345\277\203\345\246\215/assets/28.PNG" differ diff --git "a/\350\265\226\345\277\203\345\246\215/assets/29.png" "b/\350\265\226\345\277\203\345\246\215/assets/29.png" new file mode 100644 index 0000000000000000000000000000000000000000..04612e883b98c0d23e7c5c34c64a22033d7969fa Binary files /dev/null and "b/\350\265\226\345\277\203\345\246\215/assets/29.png" differ diff --git "a/\350\265\226\345\277\203\345\246\215/assets/30.png" "b/\350\265\226\345\277\203\345\246\215/assets/30.png" new file mode 100644 index 0000000000000000000000000000000000000000..aa43bf7dfecdbcb15e3071127e75359b96f65034 Binary files /dev/null and "b/\350\265\226\345\277\203\345\246\215/assets/30.png" differ diff --git "a/\350\265\226\345\277\203\345\246\215/assets/31.png" "b/\350\265\226\345\277\203\345\246\215/assets/31.png" new file mode 100644 index 0000000000000000000000000000000000000000..d27c97cc32a2aebc0689559d8fc8ff55df14986c Binary files /dev/null and "b/\350\265\226\345\277\203\345\246\215/assets/31.png" differ diff --git "a/\350\265\226\345\277\203\345\246\215/assets/32" "b/\350\265\226\345\277\203\345\246\215/assets/32" new file mode 100644 index 0000000000000000000000000000000000000000..70d7893019e9ced012de542991713acb340c4156 Binary files /dev/null and "b/\350\265\226\345\277\203\345\246\215/assets/32" differ diff --git "a/\350\265\226\345\277\203\345\246\215/assets/33" "b/\350\265\226\345\277\203\345\246\215/assets/33" new file mode 100644 index 0000000000000000000000000000000000000000..f3448af1fef16692de7b18314c425d742c57a57d Binary files /dev/null and "b/\350\265\226\345\277\203\345\246\215/assets/33" differ diff --git "a/\350\265\226\345\277\203\345\246\215/assets/34" "b/\350\265\226\345\277\203\345\246\215/assets/34" new file mode 100644 index 0000000000000000000000000000000000000000..9cb382f8a516ef351491460c6547611775064806 Binary files /dev/null and "b/\350\265\226\345\277\203\345\246\215/assets/34" differ