In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
How to build LAMP in batch in ansible-playbook? To solve this problem, the editor summarized this article today, hoping to help more students who want to learn LAMP to find a more simple and easy way.
First install the LAMP environment on the ansible server, and then copy the configuration file to the remote host 1. 1 via ansible. Install httpd software yum-y install httpd2. Install mysqlyum-y install mariadb-server mysqlsystemctl start mairadb3. Install php and php-mysql module yum-y install php php-mysql4. Provide php test page vim / var/www/html/index.phpsystemctl restart httpd access ip:80 to see if the test page appears
Create the corresponding file mkdir-pv / etc/ansible/lamp/roles/ {prepare,httpd,mysql,php} / {tasks,files,templates,vars,meta,default Handlers} copy the configuration files of httpd and MySQL of the successfully built LAMP environment to the playbooks of the cd / etc/ansible/cp / etc/httpd/conf/httpd.conf lamp/roles/httpd/files/cp / etc/my.cnf lamp/roles/mysql/files/ write prepare role under the corresponding directory # pre-preparation vim lamp/roles/prepare/tasks/main.yml- name: provide yumrepo file shell: rm-rf / etc/yum.repos.d/*.repo # delete the original There is a yum configuration file shell: wget-o / etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-repo # download the new yum configuration file-name: clean the yum repo shell: yum clean all- name: clean the iptables shell: systemctl stop firewalld # turn off the firewall to build the httpd task cp / var/www/html/index.php lamp/roles/httpd/files/vim lamp/roles/httpd/tasks/main.yml- Name: web server install yum: name=httpd state=present # install the httpd service-name: provide test page copy: src=index.php dest=/var/www/html # provides a test page notify: restart httpd # when the previous copy is executed successfully Notify the handlers operation named restart httpd through notify-name: restart httpd service: name=httpd enabled=yes state=restarted # restart the httpd service deployment mariadb database to create the MySQL service task, you need to install the mysql service and change the attribute of the owner Start mysqlvim lamp/roles/mysql/tasks/main.yml- name: install the mysql yum: name=mariadb-server state=present # install mysql service-name: mkdir date directory shell: mkdir-p / mydata/data # create mount point directory-name: provide configration file copy: src=my.cnf dest=/etc/my.cnf # copy mysql configuration file-name: chage the owner shell: chown-R mysql:mysql / mydata/* # change owner and owner-name: start Mariadb service: name=mariadb enabled=yes state=started # start the mysql service build php task vim lamp/roles/php/tasks/main.yml- name: install php yum: name=php state=present # install php- name: install php-mysql yum: name=php-mysql state=present # install the php and mysql interaction plug-in define the entire task vim lamp/roles/site.yml- name: LAMP build remote_user: root hosts: all roles:-prepare-mysql-php- httpd execute playbookansible- Playbook-I / etc/ansible/hosts. / site.yml
Visit 192.168.1.129 to see if there is a test page
After reading the content of the appeal, have you mastered the method of building LAMP in batch in ansible-playbook? If you want to know more related content, welcome to follow the industry information channel, thank you for reading!
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: 263
*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.