OneinStack 是出名 Linux 技术博客 LinuxEye 推出的一个能够一键装置 LNMP(Linux + NGINX + MySQL + PHP)、LAMP(Linux + Apache + MySQL + PHP)、LNMPA(Linux + NGINX + MySQL + PHP + Apache)等建站环境的一键安装包。次要是提供了一个可视化页面,能够间接在页面上抉择本人想要的配置,而后主动生成装置命令,而后就期待主动装置实现就行
oneinstack 官网
linux 下载oneinstackwget http://mirrors.linuxeye.com/oneinstack-full.tar.gz && tar -xvf oneinstack-full.tar.gz
oneinstack集成了acme.sh 工具,能够用 vhost.sh 脚本文件间接申请收费的R3证书,并主动创立打算工作,检测并更新证书到期工夫。
oneinstack的文件目录如下:
addons.sh backup_setup.sh # 备份设置backup.sh # 执行备份configincludeinit.dinstall.loginstall.sh # oneinstack环境装置脚本LICENSEoptions.conf # 配置信息寄存文件pureftpd_vhost.sh # ftp治理README.mdreset_db_root_password.sh # 重置数据库root明码src # 装置过程应用源码装置,将会把源码文件下载到这个文件夹toolsuninstall.sh # oneinstack环境卸载脚本upgrade.sh # 各种插件降级脚本versions.txtvhost.sh # 域名证书申请脚本
证书申请
开始之前须要首先购买、备案、并解析域名。
备案帮忙文档
解析域名帮忙文档
进入 oneinstack 工作目录,应用 root 权限执行 vhost.sh 文件./vhost.sh
抉择生成网站配置文件的形式
What Are You Doing? 1. Use HTTP Only 2. Use your own SSL Certificate and Key 3. Use Let's Encrypt to Create SSL Certificate and Key q. ExitPlease input the correct option: 3
- 不应用证书,间接生成网站配置文件
- 应用自定义证书,这个同样须要填写域名等信息,然而脚本不会去R3官网申请证书,配置文件生成后须要手动将本人的证书放在配置文件指定的地位中
- 应用 " Let's Encrypt " 提供的收费证书
输出域名、设置网站根目录
Please input domain(example: www.example.com): demo.leorain.cndomain=demo.leorain.cnPlease input the directory for the domain:demo.leorain.cn :(Default directory: /data/wwwroot/demo.leorain.cn): Virtual Host Directory=/data/wwwroot/demo.leorain.cnCreate Virtul Host directory......set permissions of Virtual Host directory......
网站根目录
网站根目录对应的是nginx配置中的 root 值,不同的我的项目对应的 root 门路不同,且对应的索引文件也不同,例如:1、一般的独立站,应用 laravel 的 blade 模板渲染,则须要 root 门路指向 laravel 的 public 目录,索引文件指向 index.php ,并将 quest_string 从定向到 index.php 文件。2、前后端拆散我的项目,须要将网站根目录指向前端的根门路:[web_root]/dist/ ,索引文件指向 index.html ,并将 query_string 指向 index.html- 重定向
这个中央输出域名,如果网站对应多个域名,域名会被重定向到后续输出的域名,例如网站对应两个域名 https://www.leorain.cn 、https://leorain.cn ,并且心愿将 https://leorain.cn 重定向到 https://www.leorain.cn ,则须要首先输出 www.leorain.cn 再增加 leorain.cn
- 重定向
防盗链、拜访日志等
Do you want to add hotlink protection? [y/n]: nAllow Rewrite rule? [y/n]: yPlease input the rewrite of programme :wordpress,opencart,magento2,drupal,joomla,codeigniter,laravelthinkphp,pathinfo,discuz,typecho,ecshop,nextcloud,zblog,whmcs rewrite was exist.(Default rewrite: other): laravelYou choose rewrite=laravelAllow Nginx/Tengine/OpenResty access_log? [y/n]: yYou access log file=/data/wwwlogs/demo.leorain.cn_nginx.lognginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successfulReload Nginx......
应用oneinstack外面的acme模块申请的证书,会主动生成续费打算工作。
- sudo su 切换root用户申请的证书,主动续费配置文件在
/root/.acme.sh/
外面
7 0 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null
- sudo vhost.sh
7 0 * * * "/home/ubuntu/.acme.sh"/acme.sh --cron --home "/home/ubuntu/.acme.sh" > /dev/null
oneinstack自带的acme.sh会因为nginx配置问题, 导致主动续费失败,在网站的nginx配置最初增加以下配置,重载nginx即可主动续费
# ACME_CRON_NGINX_WELLKNOW BEGIN ANSIBLE MANAGED BLOCKlocation /.well-known { allow all;}# ACME_CRON_NGINX_WELLKNOW END ANSIBLE MANAGED BLOCK
博客原文