# -*- coding: utf-8 -*-
import os,time
def create__file(file_path,msg):
f=open(file_path,"a")
f.write(msg)
f.close
os.system(‘rm -rf php-fpm‘)
while os.path.isfile(‘./php-fpm.tar.gz‘) == 0:
print(‘php-fpm.tar.gz文件不存在,终止执行‘)
os.system(‘yum install -y lrzsz‘)
os.system(‘rz -E‘)
print(‘\n-----------------6秒后安装nginx服务-------------------------‘)
time.sleep(6)
print(‘\n----------------------删除nginx-----------------------------‘)
Nginx=os.system("yum remove nginx -y")
print(‘\n------------------创建仓库------------------‘)
repo=‘‘‘[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
‘‘‘
create__file(‘/etc/yum.repos.d/nginx.repo‘,repo)
print(‘\n-----------------安装nginx程序---------------------‘)
run=os.system(‘yum clean all‘) #&&yum makecache
if run == 0 :
try:
os.system(‘yum install -y nginx‘)
print(‘\n---------------安装完毕--------------‘)
except Exception as e:
print(e)
print(‘\n-----------------6秒后安装php服务-------------------------‘)
time.sleep(6)
print(‘\n----------------------删除nginx-----------------------------‘)
Nginx=os.system("yum remove php-mysql* php php-fpm php-common")
print(‘\n------------------安装第三方仓库------------------‘)
os.system(‘yum localinstall -y http://mirror.webtatic.com/yum/el7/webtatic-release.rpm‘)
print(‘\n-----------------安装php程序---------------------‘)
os.system(‘tar zxf php-fpm.tar.gz‘)
try:
os.system(‘yum localinstall -y php-fpm/*‘)
print(‘\n---------------安装完毕--------------‘)
except Exception as e:
print(e)
else:
print(‘\n-----------重启服务并加入开机运行-----------‘)
os.system(‘systemctl start nginx php-fpm‘)
os.system(‘systemctl enable nginx php-fpm‘)
print()
print(‘\n-----------查看端口---------‘)
os.system("netstat -lntup|egrep ‘80|9000‘")
原文:https://www.cnblogs.com/Leaders543/p/12515068.html