首页 > 代码库 > fabric本地一键部署LAMP
fabric本地一键部署LAMP
一、添加普通用户jeff执行sudo时无需输入密码
$ sudo vim /etc/sudoers
--------------------------------------->
## Allow root to run any commands anywhere root ALL=(ALL) ALL jeff ALL=(ALL) NOPASSWD: ALL
二、安装fabric
$ sudo yum install epel-release -y $ sudo yum install python-pip -y && sudo pip install --upgrade pip $ sudo pip install fabric
三、创建文件index.php
vim /home/jeff/index.php
---------------------------------------->
<?php phpinfo() ?>
四、创建自动化安装脚本auto_install_lamp.py
$ vim anto_install_lamp.py
----------------------------------------->
#!/usr/bin/env python from fabric.colors import * from fabric.api import * env.user = ‘root‘ env.roledefs = { ‘node1‘: [‘127.0.0.1‘] } env.password = ‘redhat‘ @roles(‘node1‘) def lamptask(): print yellow("Auto install LAMP ...") with settings(warn_only=True): run("yum install httpd -y") run("yum groupinstall mariadb -y") run("yum install pcre gcc-c++ zlib* php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml* php-mbstring php-bcmath php-mhash -y") local(‘sudo cp /home/jeff/index.php /var/www/html/‘) run("systemctl start mariadb") run("systemctl enable mariadb") run("systemctl start httpd") run("systemctl enable httpd") def deploy(): execute(lamptask)
五、执行脚本
$ fab -f auto_install_lamp.py deploy
六、浏览器查看结果: http://10.0.0.20 //此处的10.0.0.20为我设置的本机IP
fabric本地一键部署LAMP
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。