diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9bb88d3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.DS_Store diff --git a/Nginx/ssl-install/README.md b/Nginx/ssl-install/README.md new file mode 100644 index 0000000..9cb9e39 --- /dev/null +++ b/Nginx/ssl-install/README.md @@ -0,0 +1,58 @@ +# Nginx 安装 ssl 证书 + +1、以腾讯云为例,去 SSL 证书管理控制台:https://console.cloud.tencent.com/ssl 下载并解压缩证书文件包到本地目录。 + +2.、解压缩后,可获得相关类型的证书文件。其中包含 Nginx 文件夹和 CSR 文件。 + +``` +文件夹名称:Nginx +文件夹内容: + 1_www.domain.com_bundle.crt 证书文件 + 2_www.domain.com.key 私钥文件 +CSR 文件内容: www.domain.com.csr 文件 +``` +说明:CSR 文件是申请证书时由您上传或系统在线生成的,提供给 CA 机构。安装时可忽略该文件。 + +3、将已获取到的 1_www.domain.com_bundle.crt 证书文件和 2_www.domain.com.key 私钥文件从本地拷贝到服务器的某个目录下。 + +4、Nginx 配置: + +``` +server { + listen 443; + + server_name phpedu.club www.phpedu.club; + root /usr/share/nginx/html; + index index.html index.htm index.php; + + # 启用 SSL 功能 + ssl on; + # 证书文件名称 + ssl_certificate /etc/nginx/conf.d/ssl/1_phpedu.club_bundle.crt; + # 私钥文件名称 + ssl_certificate_key /etc/nginx/conf.d/ssl/2_phpedu.club.key; + ssl_session_timeout 5m; + # 请按照这个协议配置 + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; + # 请按照这个套件配置,配置加密套件,写法遵循 openssl 标准。 + ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; + ssl_prefer_server_ciphers on; + + location ~* /\. { + deny all; + } +} + +server { + listen 80; + server_name phpedu.club www.phpedu.club; + # 把 http 的域名请求转成 https + rewrite ^(.*)$ https://$host$1 permanent; +} +``` + +5、重启Nginx。 + +### 参考 + +- [https://cloud.tencent.com/document/product/400/35244](https://cloud.tencent.com/document/product/400/35244) \ No newline at end of file diff --git a/PHP7-yum-install/PHP7-yum-install.sh b/PHP7-yum-install/PHP7-yum-install.sh new file mode 100644 index 0000000..951d287 --- /dev/null +++ b/PHP7-yum-install/PHP7-yum-install.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# 安装 epel 源(epel 是基于 Fedora 的一个项目,为"红帽系"的操作系统提供额外的软件包) + +rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + +# 安装 webtatic 源(安装 webtatic-release 之前需要先安装 epel-release) + +rpm -ivh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm + +# 安装 PHP 及其扩展 + +yum -y install mod_php72w \ + php72w-bcmath \ + php72w-cli \ + php72w-common \ + php72w-devel \ + php72w-fpm \ + php72w-gd \ + php72w-mbstring \ + php72w-mysql \ + php72w-opcache \ + php72w-pdo \ + php72w-xml + +# 安装 Composer 并配置阿里云源 +curl -sSL https://getcomposer.org/installer | php &&\ + mv composer.phar /usr/local/bin/composer &&\ + composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ + +echo "====================================================" +php -v +composer -V +echo "====================================================" \ No newline at end of file diff --git a/PHP7-yum-install/README.md b/PHP7-yum-install/README.md new file mode 100644 index 0000000..4ff5225 --- /dev/null +++ b/PHP7-yum-install/README.md @@ -0,0 +1,51 @@ +# 通过 yum 安装 PHP7 + +### 脚本描述 + +``` +通过 yum 安装 PHP7 并安装 Composer +``` + +### 脚本内容 + +[PHP7-yum-install.sh](PHP7-yum-install.sh) + +```shell +#!/bin/bash + +# 安装 epel 源(epel 是基于 Fedora 的一个项目,为"红帽系"的操作系统提供额外的软件包) +rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + +# 安装 webtatic 源(安装 webtatic-release 之前需要先安装 epel-release) +rpm -ivh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm + +# 安装 PHP 及其扩展 +yum -y install mod_php72w \ + php72w-bcmath \ + php72w-cli \ + php72w-common \ + php72w-devel \ + php72w-fpm \ + php72w-gd \ + php72w-mbstring \ + php72w-mysql \ + php72w-opcache \ + php72w-pdo \ + php72w-xml + +# 安装 Composer 并配置阿里云源 +curl -sSL https://getcomposer.org/installer | php &&\ + mv composer.phar /usr/local/bin/composer &&\ + composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ + +echo "====================================================" +php -v +composer -V +echo "====================================================" +``` + +### 执行 + +```shell +bash PHP7-yum-install.sh +``` \ No newline at end of file diff --git a/common-software-install/README.md b/common-software-install/README.md new file mode 100644 index 0000000..88b8d22 --- /dev/null +++ b/common-software-install/README.md @@ -0,0 +1,37 @@ +# CentOS7 初始化 + +### 脚本描述 +``` +纯净的 CentOS7 系统, 需要安装一些常用的软件, 如 git、vim 等. +``` + +### 脚本内容 +[common-software-install.sh](common-software-install.sh) +```shell +#!/bin/bash + +# '\033[字背景颜色;字体颜色m字符串\033[0m' +GREENCOLOR='\033[1;32m' +NC='\033[0m' + +echo "====================================================" +printf "${GREENCOLOR} common-software's install begin ${NC} \n" +echo "====================================================" + +# 为了使用 ifconfig 命令, 需要安装 net-tools +yum -y install net-tools +yum -y install vim +yum -y install wget +yum -y install autoconf +yum -y install gcc gcc-c++ make +yum -y install git + +echo "====================================================" +printf "${GREENCOLOR} common-software's install finish ${NC} \n" +echo "====================================================" +``` + +### 执行 +```shell +bash common-software-install.sh +``` diff --git a/common-software-install/common-software-install.sh b/common-software-install/common-software-install.sh new file mode 100644 index 0000000..3a82711 --- /dev/null +++ b/common-software-install/common-software-install.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# '\033[字背景颜色;字体颜色m字符串\033[0m' +GREENCOLOR='\033[1;32m' +NC='\033[0m' + +echo "====================================================" +printf "${GREENCOLOR} common-software's install begin ${NC} \n" +echo "====================================================" + +# 为了使用 ifconfig 命令, 需要安装 net-tools +yum -y install net-tools +yum -y install vim +yum -y install wget +yum -y install autoconf +yum -y install gcc gcc-c++ make +yum -y install git + +echo "====================================================" +printf "${GREENCOLOR} common-software's install finish ${NC} \n" +echo "====================================================" \ No newline at end of file diff --git a/docker-rm-all/README.md b/docker-rm-all/README.md new file mode 100644 index 0000000..1a5c5b8 --- /dev/null +++ b/docker-rm-all/README.md @@ -0,0 +1,37 @@ +# 删除所有容器和镜像 + +### 脚本描述 + +``` +删除所有容器和镜像 +``` + +### 脚本内容 +[docker-rm-all.sh](docker-rm-all.sh) + +```shell +#!/bin/bash + +# '\033[字背景颜色;字体颜色m字符串\033[0m' +GREENCOLOR='\033[1;32m' +NC='\033[0m' + +echo "====================================================" +printf "${GREENCOLOR} Docker's rm begin ${NC} \n" +echo "====================================================" + +# 删除所有容器 +docker rm -f $(docker ps -aq) +# 删除所有镜像 +docker rmi $(docker images -q) + +echo "====================================================" +printf "${GREENCOLOR} Docker's rm finish ${NC} \n" +echo "====================================================" +``` + +### 执行 + +```shell +bash docker-rm-all.sh +``` \ No newline at end of file diff --git a/docker-rm-all/docker-rm-all.sh b/docker-rm-all/docker-rm-all.sh new file mode 100644 index 0000000..a1de6ad --- /dev/null +++ b/docker-rm-all/docker-rm-all.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# '\033[字背景颜色;字体颜色m字符串\033[0m' +GREENCOLOR='\033[1;32m' +NC='\033[0m' + +echo "====================================================" +printf "${GREENCOLOR} Docker's rm begin ${NC} \n" +echo "====================================================" + +# 删除所有容器 +docker rm -f $(docker ps -aq) +# 删除所有镜像 +docker rmi $(docker images -q) + +echo "====================================================" +printf "${GREENCOLOR} Docker's rm finish ${NC} \n" +echo "====================================================" \ No newline at end of file diff --git a/docker-yum-install/README.md b/docker-yum-install/README.md new file mode 100644 index 0000000..549fc20 --- /dev/null +++ b/docker-yum-install/README.md @@ -0,0 +1,49 @@ +# 安装 docker、docker-compose + +### 脚本描述 +``` +使用 yum 安装安装 docker、docker-compose 并启动 docker, 同时配置阿里云 docker 镜像加速器. +``` + +### 脚本内容 + +[docker-yum-install.sh](docker-yum-install.sh) + +```shell +#!/bin/bash + +# '\033[字背景颜色;字体颜色m字符串\033[0m' +GREENCOLOR='\033[1;32m' +NC='\033[0m' + +echo "====================================================" +printf "${GREENCOLOR} Docker's install begin ${NC} \n" +echo "====================================================" + +# 安装 EPEL +yum -y install epel-release +# 安装docker和docker-compose +yum -y install docker docker-compose +# 配置阿里云 docker 镜像加速器 +mkdir -p /etc/docker +tee /etc/docker/daemon.json <<-'EOF' +{ + "registry-mirrors": ["https://8auvmfwy.mirror.aliyuncs.com"] +} +EOF +# 重新加载配置、重启 docker +systemctl daemon-reload +systemctl restart docker + +echo "====================================================" +printf "${GREENCOLOR} Docker's install finish ${NC} \n" +docker_version=$(docker -v) +printf "${GREENCOLOR} ${docker_version} ${NC} \n" +echo "====================================================" +``` + +### 执行 + +```shell +bash docker-yum-install.sh +``` \ No newline at end of file diff --git a/docker-yum-install/docker-yum-install.sh b/docker-yum-install/docker-yum-install.sh new file mode 100644 index 0000000..706627b --- /dev/null +++ b/docker-yum-install/docker-yum-install.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# '\033[字背景颜色;字体颜色m字符串\033[0m' +GREENCOLOR='\033[1;32m' +NC='\033[0m' + +echo "====================================================" +printf "${GREENCOLOR} Docker's install begin ${NC} \n" +echo "====================================================" + +# 安装 EPEL +yum -y install epel-release +# 安装 docker 和 docker-compose +yum -y install docker docker-compose +# 配置阿里云 docker 镜像加速器 +mkdir -p /etc/docker +tee /etc/docker/daemon.json <<-'EOF' +{ + "registry-mirrors": ["https://8auvmfwy.mirror.aliyuncs.com"] +} +EOF +# 重新加载配置、重启 docker +systemctl daemon-reload +systemctl restart docker + +echo "====================================================" +printf "${GREENCOLOR} Docker's install finish ${NC} \n" +docker_version=$(docker -v) +printf "${GREENCOLOR} ${docker_version} ${NC} \n" +echo "====================================================" \ No newline at end of file diff --git a/firewalld-disable/README.md b/firewalld-disable/README.md new file mode 100644 index 0000000..017b156 --- /dev/null +++ b/firewalld-disable/README.md @@ -0,0 +1,38 @@ +# 关闭并开机禁用 firewalld + +### 脚本描述 + +``` +关闭并开机禁用 firewalld +``` + +### 脚本内容 + +[firewalld-disable.sh](firewalld-disable.sh) + +```shell +#!/bin/bash + +# '\033[字背景颜色;字体颜色m字符串\033[0m' +GREENCOLOR='\033[1;32m' +NC='\033[0m' + +echo "====================================================" +printf "${GREENCOLOR} firewalld's disable begin ${NC} \n" +echo "====================================================" + +# 关闭防火墙 +systemctl stop firewalld +# 开机禁用防火墙 +systemctl disable firewalld + +echo "====================================================" +printf "${GREENCOLOR} firewalld's disable finish ${NC} \n" +echo "====================================================" +``` + +### 执行 + +```shell +bash firewalld-disable.sh +``` \ No newline at end of file diff --git a/firewalld-disable/firewalld-disable.sh b/firewalld-disable/firewalld-disable.sh new file mode 100644 index 0000000..091c466 --- /dev/null +++ b/firewalld-disable/firewalld-disable.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# '\033[字背景颜色;字体颜色m字符串\033[0m' +GREENCOLOR='\033[1;32m' +NC='\033[0m' + +echo "====================================================" +printf "${GREENCOLOR} firewalld's disable begin ${NC} \n" +echo "====================================================" + +# 关闭防火墙 +systemctl stop firewalld +# 开机禁用防火墙 +systemctl disable firewalld + +echo "====================================================" +printf "${GREENCOLOR} firewalld's disable finish ${NC} \n" +echo "====================================================" \ No newline at end of file diff --git a/go-install/README.md b/go-install/README.md new file mode 100644 index 0000000..f780d7a --- /dev/null +++ b/go-install/README.md @@ -0,0 +1,16 @@ +# Go 安装 + +```sh +# 下载 & 解压 +wget https://mirrors.ustc.edu.cn/golang/go1.17.1.linux-amd64.tar.gz +tar -xvf go1.17.1.linux-amd64.tar.gz -C /home/work/service + +# vim /etc/profile +export GOROOT=/home/work/service/go +export GOPATH=/home/work/gopath +export PATH=$PATH:$GOROOT/bin:$GOPATH/bin +source /etc/profile + +# 创建目录 +mkdir -p /home/work/gopath +``` diff --git a/mysql57-yum-install/README.md b/mysql57-yum-install/README.md new file mode 100644 index 0000000..f856726 --- /dev/null +++ b/mysql57-yum-install/README.md @@ -0,0 +1,88 @@ +# 安装 Mysql + +### 脚本描述 + +``` +使用 yum 安装 MySQL5.7 并启动 +``` + +### 脚本内容 + +[mysql57-yum-install.sh](mysql57-yum-install.sh) + +```shell +#!/bin/bash + +# '\033[字背景颜色;字体颜色m字符串\033[0m' +GREENCOLOR='\033[1;32m' +NC='\033[0m' + +DOWNLOAD_DIR="/usr/src" +SOURCE_DIR="http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm" + +echo "====================================================" +printf "${GREENCOLOR} MySQL's install begin ${NC} \n" +echo "====================================================" + +# 安装 MySQL +# 如果安装过 MySQL, 先卸载 +yum -y remove mysql +# 进入目录 +cd $DOWNLOAD_DIR +# 下载 MySQL 包 +wget $SOURCE_DIR +# 安装 MySQL 的 yum 源 +rpm -ivh mysql57-community-release-el7-8.noarch.rpm +# 安装 MySQL +yum -y install mysql-community-server +# 启动 MySQL +service mysqld start + +echo "====================================================" +printf "${GREENCOLOR} MySQL's install finish ${NC} \n" +cat /var/log/mysqld.log | grep 'temporary password' +echo "====================================================" +``` + +### 执行 + +```shell +bash mysql57-yum-install.sh +``` + +### 如何修改 root 密码? + +1、首先查看初始化的密码。 + +```sh +cat /var/log/mysqld.log | grep 'temporary password' +``` + +2、用初始密码登录 MySQL,然后修改 root 的密码。 + +```sql +ALTER user 'root'@'localhost' IDENTIFIED BY 'duiying*D123'; +``` + +3、刷新权限。 + +```sql +FLUSH PRIVILEGES; +``` + +4、允许其他主机连接 MySQL。 + +```sql +use mysql; +update user set host = '%' where user = 'root'; +FLUSH PRIVILEGES; +``` + +### 如何设置 MySQL 开机自启动? + +```sh +# 编辑文件 +vim /etc/rc.log +# 在尾部新增下面这行 +service mysqld start +``` \ No newline at end of file diff --git a/mysql57-yum-install/mysql57-yum-install.sh b/mysql57-yum-install/mysql57-yum-install.sh new file mode 100644 index 0000000..7c043f4 --- /dev/null +++ b/mysql57-yum-install/mysql57-yum-install.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# '\033[字背景颜色;字体颜色m字符串\033[0m' +GREENCOLOR='\033[1;32m' +NC='\033[0m' + +DOWNLOAD_DIR="/usr/src" +SOURCE_DIR="http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm" + +echo "====================================================" +printf "${GREENCOLOR} MySQL's install begin ${NC} \n" +echo "====================================================" + +# 安装 MySQL +# 如果安装过 MySQL, 先卸载 +yum -y remove mysql +# 进入目录 +cd $DOWNLOAD_DIR +# 下载 MySQL 包 +wget $SOURCE_DIR +# 安装 MySQL 的 yum 源 +rpm -ivh mysql57-community-release-el7-8.noarch.rpm +# 安装 MySQL +yum -y install mysql-community-server +# 启动 MySQL +service mysqld start + +echo "====================================================" +printf "${GREENCOLOR} MySQL's install finish ${NC} \n" +cat /var/log/mysqld.log | grep 'temporary password' +echo "====================================================" \ No newline at end of file diff --git a/nginx-yum-install/README.md b/nginx-yum-install/README.md new file mode 100644 index 0000000..9132c53 --- /dev/null +++ b/nginx-yum-install/README.md @@ -0,0 +1,48 @@ +# 安装 Nginx + +### 脚本描述 + +``` +使用 yum 安装 Nginx 并启动 +``` + +### 脚本内容 + +[nginx-yum-install.sh](nginx-yum-install.sh) + +```shell +#!/bin/bash + +# '\033[字背景颜色;字体颜色m字符串\033[0m' +GREENCOLOR='\033[1;32m' +NC='\033[0m' + +DOWNLOAD_DIR="/usr/src" +SOURCE_DIR="http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm" + +echo "====================================================" +printf "${GREENCOLOR} Nginx's install begin ${NC} \n" +echo "====================================================" + +# 安装 Nginx +# 进入目录 +cd $DOWNLOAD_DIR +# 下载 Nginx 包 +wget $SOURCE_DIR +# 安装 Nginx 的 yum 源 +rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm +# 安装 Nginx +yum -y install nginx +# 启动 Nginx +service nginx restart + +echo "====================================================" +printf "${GREENCOLOR} Nginx's install finish ${NC} \n" +echo "====================================================" +``` + +### 执行 + +```shell +bash nginx-yum-install.sh +``` \ No newline at end of file diff --git a/nginx-yum-install/nginx-yum-install.sh b/nginx-yum-install/nginx-yum-install.sh new file mode 100644 index 0000000..96d7fa8 --- /dev/null +++ b/nginx-yum-install/nginx-yum-install.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# '\033[字背景颜色;字体颜色m字符串\033[0m' +GREENCOLOR='\033[1;32m' +NC='\033[0m' + +DOWNLOAD_DIR="/usr/src" +SOURCE_DIR="http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm" + +echo "====================================================" +printf "${GREENCOLOR} Nginx's install begin ${NC} \n" +echo "====================================================" + +# 安装 Nginx +# 进入目录 +cd $DOWNLOAD_DIR +# 下载 Nginx 包 +wget $SOURCE_DIR +# 安装 Nginx 的 yum 源 +rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm +# 安装 Nginx +yum -y install nginx +# 启动 Nginx +service nginx restart + +echo "====================================================" +printf "${GREENCOLOR} Nginx's install finish ${NC} \n" +echo "====================================================" \ No newline at end of file diff --git a/redis5-src-install/README.md b/redis5-src-install/README.md new file mode 100644 index 0000000..750a20c --- /dev/null +++ b/redis5-src-install/README.md @@ -0,0 +1,72 @@ +# 通过源码安装 redis5.0.5 + +### 脚本描述 + +``` +通过源码安装 redis5.0.5 并启动服务 +``` + +### 脚本内容 + +[redis5-src-install.sh](redis5-src-install.sh) + +```shell +#!/bin/bash + +DOWNLOAD_DIR="/usr/src" +SOURCE_DIR="http://download.redis.io/releases/redis-5.0.5.tar.gz" + +# 安装依赖 +yum -y install libxml2 libxml2-devel telnet pcre-devel curl-devel + +# 进入下载目录 +cd $DOWNLOAD_DIR +# 下载源码包 +wget $SOURCE_DIR + +# 解压 +tar -xzvf redis-5.0.5.tar.gz +# 进入目录 +cd redis-5.0.5 +# 编译 +make +# 安装 +make install + +# 启动 redis 服务端 +cd src +./redis-server +``` + +### 客户端连接 + +```shell +redis-cli -h 127.0.0.1 -p 6379 +``` + +### 让 redis 服务在后台启动 + +```shell +# 进入目录 +cd /usr/src/redis-5.0.5/ +# 拷贝出一份自定义配置文件 +cp redis.conf myredis.conf +# 修改配置文件 daemonize no => daemonize yes port 6379 => port 6397 +# 如何开启远程访问?将 bind 127.0.0.1 注释掉 +# 如何设置密码?requirepass myPassword +vim myredis.conf +# 以指定配置文件启动 redis 服务 +cd /usr/src/redis-5.0.5/src +./redis-server /usr/src/redis-5.0.5/myredis.conf +# 查看 redis 服务是否启动 +[root@localhost src]# ps -ef | grep redis +root 6431 1 0 15:59 ? 00:00:00 ./redis-server 127.0.0.1:6397 +root 6438 6361 0 16:00 pts/1 00:00:00 grep --color=auto redis +# 客户端连接 +redis-cli -h 127.0.0.1 -p 6397 +``` + +### 执行 +```shell +bash redis5-src-install.sh +``` \ No newline at end of file diff --git a/redis5-src-install/redis5-src-install.sh b/redis5-src-install/redis5-src-install.sh new file mode 100644 index 0000000..f570d9d --- /dev/null +++ b/redis5-src-install/redis5-src-install.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +DOWNLOAD_DIR="/usr/src" +SOURCE_DIR="http://download.redis.io/releases/redis-5.0.5.tar.gz" + +# 安装依赖 +yum -y install libxml2 libxml2-devel telnet pcre-devel curl-devel + +# 进入下载目录 +cd $DOWNLOAD_DIR +# 下载源码包 +wget $SOURCE_DIR + +# 解压 +tar -xzvf redis-5.0.5.tar.gz +# 进入目录 +cd redis-5.0.5 +# 编译 +make +# 安装 +make install + +# 启动 redis 服务端 +cd src +./redis-server \ No newline at end of file diff --git a/samba/README.md b/samba/README.md new file mode 100644 index 0000000..5d106d3 --- /dev/null +++ b/samba/README.md @@ -0,0 +1,87 @@ +# CentOS7 搭建 samba 实现与Win共享目录 + +**搭建** + +```shell +# 1、关闭防火墙、selinux + +# 2. 安装samba +yum -y install samba + +# 3、修改 samba 配置文件(首先备份配置文件) +cp /etc/samba/smb.conf /etc/samba/smb.conf.bak +vim /etc/samba/smb.conf +# 底部新增内容 +[www] +comment = www # 说明 +path = /data/www # 资源路径 +valid users = smbuser # 能够访问资源的用户 +browseable = yes # 是yes/否no在浏览资源中显示共享目录 +writable = yes # 是yes/否no不以只读方式共享 +create mask = 0777 # 建立文件时所给的权限 +directory mask = 0777 # 建立目录时所给的权限 + +# 4、添加用户 +useradd smbuser +passwd smbuser +# samba添加用户 +smbpasswd -a smbuser + +# 5、添加共享文件夹 +mkdir -p /data/www +chmod -R 777 /data/www +chown -R smbuser:smbuser /data + +# 6、重启 samba 服务 +systemctl restart smb +``` + +**如何在 Win 中打开** + +1、文件夹中打开 + +