标签:pcr 创建文件 普通用户 int import 本地 bcmath 文件 输入密码
一、添加普通用户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
标签:pcr 创建文件 普通用户 int import 本地 bcmath 文件 输入密码
原文地址:http://www.cnblogs.com/jefflee168/p/7349893.html