linux搭建可道云
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux搭建可道云相关的知识,希望对你有一定的参考价值。
参考技术A这个项目是个php项目,需要安装php环境
听说宝塔可以一键部署这玩意,可以先装个宝塔,在宝塔面板中找到一键部署,找到这个东西
wdnmd我竟然没找到可道云的一键部署,去官网看下,这是官网给出的,非常简单
我们就可以把这个解压到站点目录下,直接访问站点就行了
那宝塔么没有域名怎么创建站点之后可以访问:
可以使用当前ip或者127.0.0.1创建
站点根目录创建之后,宝塔为了防跨站攻击, 站点根目录都会有一个user.ini文件 ,
如果该文件存在,这个可道云就编辑不了该站点以外的文件,只能编辑本站内的文件,但是可以把想要访问的文件路径在这个文件中添加
该文件内容如下:
如果你不想这么麻烦,那么可以将这个文件删除,这个时候就可以任意访问,任意跳转,任意编辑
但是,这样的话一定要保证你这个可道云的密码安全度非常高,否则一旦被猜测到了,整个服务器就沦陷了
四ansible-playbook案例(nfslnmp+可道云tomcatnginx)
一、ansible安装并配置nfs服务
1、环境准备
192.168.10.128作为nfs服务器
192.168.10.130作为nfs客户端
创建工作目录
mkdir /project/nfs -p
2、编写主机清单文件
cat /project/nfs/hosts
---------------------------------------------------------------------------------------------
[webserver]
192.168.10.128
[dbserver]
192.168.10.130
[all:vars]
ansible_ssh_port=22
ansible_ssh_user=root
ansible_ssh_pass=\'123456\'
---------------------------------------------------------------------------------------------
3、编写nfs.yaml
cat /project/nfs/nfs.yaml
---------------------------------------------------------------------------------------------
---
- hosts: 192.168.10.128
tasks:
- name: Install NFS Server
yum: name=nfs-utils state=present
- name: Configure NFS Server
copy: src=./exports.j2 dest=/etc/exports backup=yes
- name: Create NFS Group
group: name=www gid=666
- name: Create NFS User
user: name=www uid=666 group=666 shell=/sbin/nologin create_home=no
- name: Create NFS Data
file: path=/data state=directory owner=www group=www recurse=yes
- name: Service NFS Server
service: name=nfs state=started enabled=yes
- hosts: 192.168.10.130
tasks:
- name: Client Create NFS Data
file: path=/nfs_tt state=directory
- name: Client Mount NFS Server
mount:
src: 192.168.10.128:/data
path: /nfs_tt
fstype: nfs
opts: defaults
state: mounted
---------------------------------------------------------------------------------------------
cat exports.j2
/data 192.168.10.1/24(rw,sync,all_squash,anonuid=666,anongid=666)
---------------------------------------------------------------------------------------------
ansible-playbook nfs.yaml -i hosts
二、ansible安装并配置httpd服务,根据不同的主机配置不同的网站
---------------------------------------------------------------------------------------------
cat /project/apache/hosts
[webserver]
192.168.10.128
[dbserver]
192.168.10.130
[all:vars]
ansible_ssh_port=22
ansible_ssh_user=root
ansible_ssh_pass=\'123456\'
---------------------------------------------------------------------------------------------
cat /project/apache/httpd.conf.j2 |grep 7788
Listen 7788
---------------------------------------------------------------------------------------------
cat /project/apache/apache.yaml
---
- hosts: all
remote_user: root
tasks:
- name: Install Httpd Server
yum: name=httpd state=present
- name: Configure Httpd Server
copy: src=./httpd.conf.j2 dest=/etc/httpd/conf/httpd.conf
- name: Create Httpd Group
group: name=ttt gid=7788 state=present
- name: Create Httpd User
user: name=ttt uid=7788 group=7788 shell=/sbin/nologin create_home=no
- name: Service Httpd Server
service: name=httpd state=started enabled=yes
- name: Configure Firewalld Server
firewalld:
zone: public
port: 7788/tcp
permanent: yes
immediate: yes
state: enabled
- hosts: 192.168.10.128
tasks:
- name: Configure Web site
copy: content=\'web-128...\' dest=/var/www/html/index.html
- hosts: 192.168.10.130
tasks:
- name: Configure Web site
copy: content=\'web-130...\' dest=/var/www/html/index.html
---------------------------------------------------------------------------------------------
ansible-playbook apache.yaml -i hosts
三、lnmp+可道云
创建目录
/project/lnmp
---------------------------------------------------------------------------------------------
cat /project/lnmp/hosts
[webserver]
192.168.10.128
[dbserver]
192.168.10.130
[all:vars]
ansible_ssh_port=22
ansible_ssh_user=root
ansible_ssh_pass=\'123456\'
---------------------------------------------------------------------------------------------
可道云官网下载kodexplorer4.46.zip
---------------------------------------------------------------------------------------------
cat lnmp.yaml
---
- hosts: webserver
tasks:
- name: Install Httpd PHP Firewalld
yum: name=httpd,php,php-pdo,php-mbstring,php-gd,firewalld state=present
- name: Service Httpd Server
service: name=httpd state=started
- name: Service Firewalld Server
service: name=firewalld state=started
- name: Configure Firewalld
firewalld: port=80/tcp immediate=yes state=enabled
- name: Copy kod cloud code
unarchive: src=./kodexplorer4.46.zip dest=/var/www/html/ mode=0777
- name: Chown Directory
file: path=/var/www/html owner=apache group=apache recurse=yes
---------------------------------------------------------------------------------------------
ansible-playbook lnmp.yaml -i hosts
直接网页登录查看
http://192.168.10.128/ ###可道云用的是index.php页面,之前实验如果有index.html页面记得删掉
error:您的web服务器开启了列目录功能,为安全考虑请禁用该功能!
vi /etc/httpd/conf/httpd.conf
144 Options Indexes FollowSymLinks
改为Options Indexes FollowSymLinks
systemctl restart httpd
三、tomcat源码包部署
[root@db2 project2]# cat tomcat.yaml
- hosts: webserver
gather_facts: no
vars:
tomcat_version: 8.5.34
tomcat_install_dir: /usr/local
tasks:
- name: install jdk8
yum: name=java-1.8.0-openjdk state=present
- name: download tomcat
get_url: url=http://mirrors.hust.edu.cn/apche/tomcat-8/v{{ tomcat_version }}/bin/apache-tomcat-{{ tomcat_version }}.tar.gz dest=/tmp
- name: unarchive tomcat-{{ tomcat_version }}.tar.gz
unarchive:
src: /tmp/apache-tomcat-{{ tomcat_version }}.tar.gz
dest: "{{ tomcat_install_dir }}"
copy: no
- name: start tomcat
shell: cd {{ tomcat_install_dir }} &&
mv apache-tomcat-{{ tomcat_version }} tomcat8 &&
cd tomcat8/bin && nohup ./startup.sh &
四、nginx源码包安装
只安装了部分
- name: install deps
yum: name={{ item }} state=present
with_items:
- gcc
- make
- zlib-devel
- openssl-devel
- pcre-devel
- name:copy nginx source pkg
copy: src=nginx-{{ nginx_version}}.tar.gz dest=/tmp
- name: install nginx
shell: cd /tmp &&
tar -zxf nginx-{{ nginx_version }}.tar.gz &&
cd nginx-{{ nginx_version }} &&
./configure --prefix=/usr/local/nginx --user=nobody --group=nobody
--with-http_ssl_module --with-http_stub_status_module --with-stream=dynamic &&
make && make install
- name: mkdir /usr/local/nginx/conf/vhost
file: dest=/usr/local/nginx/conf/vhost state=direstory
- name: copy nginx master configuration file
copy: src=nginx.conf dest=/usr/local/nginx/conf/vhost
notify: reload nginx
- name: copy nginx configuration fro wordpress
template: src=wordpress.conf dest=/usr/local/nginx/conf/vhost/
notify: reload nginx
- name: copy nginx systemctl service
copy: src=nginx.service dest=/usr/lib/systemd/system/
- name: systemctl start service
service: name=nginx state=started enabled=yes
以上是关于linux搭建可道云的主要内容,如果未能解决你的问题,请参考以下文章