In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Ansibler+shell script to build wordpress Forum
As an automated operation and maintenance tool, ansible has many functional modules, which can be better deployed automatically with shell scripts.
Environment:
192.168.0.9 # LNMP+wordpress machines that need to be deployed
192.168.0.11 # ansible
Ansible configuration
[root@localhost ansible] # egrep "^ [^]" / etc/ansible/hosts
[lnmp]
192.168.0.9
Php profile
Lnmp_install file
Software version:
Nginx 1.81
Mysql 5.5 (yum installation)
Php 7.31
Wordpress 4.7
Ansible yaml file code:
Hosts: lnmp remote_user: root tasks:-name: "create install directory" file: path: / opt/lnmp state: directory-name: "copy nginx_tar.gz" copy: src: / opt/lnmp/nginx-1.8.1.tar.gz dest: / opt/lnmp-name: "start install nginx" script: / opt/lnmp/nginx_install.sh-name: "remove mariadb" yum: name=mariadb Mariadb-server state=absent-name: "install mariadb" yum: name=mariadb,mariadb-server state=latest-name: "Adding fields to my.cnf" script: / opt/lnmp/mysql_admin.sh-name: "restart mysql" service: name=mariadb state=restarted-name: "create test databases" command: mysql-uroot-p123123-e "drop database wordpress Create database wordpress;grant all privileges on wordpress.* to 'root'@'192.168.0.9' identified by' 123123 investors flush privileges "- name:" copy php tgz "copy: src: / opt/lnmp/php-7.3.1.tar.gz dest: / opt/lnmp-name:" script php install bash "script: / opt/lnmp/php_install.sh-name:" copy php-fpm.conf "template: src: / opt/lnmp/php_conf/php-fpm.conf dest: / usr/local/php7 / etc/-name: "copy php.ini" template: src: / opt/lnmp/php_conf/php.ini dest: / usr/local/php7/-name: "copy wwww.conf" copy: src: / opt/lnmp/php_conf/www.conf dest: / usr/local/php7/etc/php-fpm.d/-name: "start php" script: / opt/lnmp/ Php_restart.sh-name: "wordpress.tar.gz copy" unarchive: src: / opt/lnmp/wordpress-4.7.4-zh_CN.tar.gz dest: / var/www/php mode: 0777 owner: nobody group: nfsnobody
Nginx_install.sh code
#! / bin/bash##this is nginx install bashnginx_tar=/opt/lnmp/nginx*.gzng_path=/opt/lnmpif [- e $nginx_tar]; thentar zxvf $nginx_tar-C $ng_pathelseecho "nginx.tar.gz does not exist" fi#yumyum install-y gcc gcc-c++ autoconf gd-devel automake zlib zlib-devel openssl openssl-devel pcre*if [! $?-eq 0] Then echo "error yum install" exit 1fisleep 5#configurecd / opt/lnmp/nginx*. / configure\-- prefix=/usr/local/nginx\-- user=nginx\-- group=nginx\-- with-http_ssl_module\-- with-http_gzip_static_module\-- with-http_image_filter_module\-- with-http_stub_status_moduleif [$?-eq 0]; thenmake & & make installfi#create nginx userid nginxif [! $?-eq 0] Then useradd-M-s / sbin/nologin nginxelse userdel-r nginx useradd-M-s / sbin/nologin nginxfi#Modify configuration filesnginx_conf_path=/usr/local/nginx/conf/nginx.confcat > ${nginx_conf_path}
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.