vim nginx_php.py
i
# -*- coding: utf-8 -*-
import os,time
def create__file(file_path,msg):
f=open(file_path,"a")
f.write(msg)
f.close
i = os.system('rm -rf php-fpm')
while i == 0:
print('php-fpm.tar.gz文件不存在,终止执行')
os.system('yum install -y lrzsz')
os.system('rz -E')
i =+ 1
print('
-----------------6秒后安装nginx服务-------------------------')
time.sleep(6)
print('
----------------------删除nginx-----------------------------')
Nginx=os.system("yum remove nginx -y")
print('
------------------创建仓库------------------')
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('
-----------------安装nginx程序---------------------')
run=os.system('yum clean all') #&&yum makecache
if run == 0 :
try:
os.system('yum install -y nginx')
print('
---------------安装完毕--------------')
except Exception as e:
print(e)
print('
-----------------6秒后安装php服务-------------------------')
time.sleep(6)
print('
----------------------删除php-----------------------------')
Nginx=os.system("yum remove php-mysql* php php-fpm php-common")
print('
------------------安装第三方仓库------------------')
os.system('yum localinstall -y http://mirror.webtatic.com/yum/el7/webtatic-release.rpm')
print('
-----------------安装php程序---------------------')
os.system('tar zxf php-fpm.tar.gz')
try:
os.system('yum localinstall -y php-fpm/*')
print('
---------------安装完毕--------------')
except Exception as e:
print(e)
else:
print('
-----------重启服务并加入开机运行-----------')
os.system('systemctl start nginx php-fpm')
os.system('systemctl enable nginx php-fpm')
print()
print('
-----------查看端口---------')
os.system("netstat -lntup|egrep '80|9000'")