linux shell脚本之https
2013-04-26 06:28
85 查看
#!/bin/bash
#this script is use rpm package install https for centos or linux 5.x
#The role of the script is complete "Word signature the HTTPS certificate(字签名https证书)"
yum -y install httpd* mod_ssl
IP=`ifconfig | grep -A 1 "^eth" | grep -o "addr:[0-9.]\{1,\}" | cut -d: -f2` #get ip address(获取IP地址)
#IP=`ifconfig | grep -A 1 "eth0" | grep "inet addr" | cut -d: -f2 | cut -d' ' -f1 ` #if you have many network card,please use this
sed -i "$a $IP bbs.abc.com" /etc/hosts
CONF=/etc/httpd/conf/httpd.conf
mkdir -p /data/web/test01
mkdir -p /data/web/logs
touch /data/web/logs/acc.log
touch /data/web/logs/err.log
echo "this is test01 website welcome" >> /data/web/test01/index.html
mkdir -p /etc/httpd/.sslkey #建立保存证书的相关文件
openssl genrsa -out /etc/httpd/.sslkey/server.key 1024 #生成网站所用的私钥 or openssl genrsa 1024 > /etc/httpd/.sslkey/server.key
echo "====when you see Common Name (eg, your name or your server's hostname) []:==please carefully input===input the name of the client to access site==="
cd /etc/httpd/.sslkey/
openssl req -new -x509 -key server.key -out /etc/httpd/.sslkey/server.crt #生成网站所用的证书文件
chmod -R 600 /etc/httpd/.sslkey/
cat >> $CONF << EOF
<VirtualHost $IP:443>
DocumentRoot /data/web/test01/
ServerName bbs.abc.com
ErrorLog /data/web/logs/err.log
CustomLog /data/web/logs/acc.log common
SSLCertificateFile /etc/httpd/.sslkey/server.crt
SSLCertificateKeyFile /etc/httpd/.sslkey/server.key
</VirtualHost>
EOF
cd /root
service httpd restart
iptables -F
setenforce 0
chkconfig --add httpd
chkconfig --level 35 httpd on
copy以上的内容到linux新建的文件里面,然后给权限然后执行
#this script is use rpm package install https for centos or linux 5.x
#The role of the script is complete "Word signature the HTTPS certificate(字签名https证书)"
yum -y install httpd* mod_ssl
IP=`ifconfig | grep -A 1 "^eth" | grep -o "addr:[0-9.]\{1,\}" | cut -d: -f2` #get ip address(获取IP地址)
#IP=`ifconfig | grep -A 1 "eth0" | grep "inet addr" | cut -d: -f2 | cut -d' ' -f1 ` #if you have many network card,please use this
sed -i "$a $IP bbs.abc.com" /etc/hosts
CONF=/etc/httpd/conf/httpd.conf
mkdir -p /data/web/test01
mkdir -p /data/web/logs
touch /data/web/logs/acc.log
touch /data/web/logs/err.log
echo "this is test01 website welcome" >> /data/web/test01/index.html
mkdir -p /etc/httpd/.sslkey #建立保存证书的相关文件
openssl genrsa -out /etc/httpd/.sslkey/server.key 1024 #生成网站所用的私钥 or openssl genrsa 1024 > /etc/httpd/.sslkey/server.key
echo "====when you see Common Name (eg, your name or your server's hostname) []:==please carefully input===input the name of the client to access site==="
cd /etc/httpd/.sslkey/
openssl req -new -x509 -key server.key -out /etc/httpd/.sslkey/server.crt #生成网站所用的证书文件
chmod -R 600 /etc/httpd/.sslkey/
cat >> $CONF << EOF
<VirtualHost $IP:443>
DocumentRoot /data/web/test01/
ServerName bbs.abc.com
ErrorLog /data/web/logs/err.log
CustomLog /data/web/logs/acc.log common
SSLCertificateFile /etc/httpd/.sslkey/server.crt
SSLCertificateKeyFile /etc/httpd/.sslkey/server.key
</VirtualHost>
EOF
cd /root
service httpd restart
iptables -F
setenforce 0
chkconfig --add httpd
chkconfig --level 35 httpd on
copy以上的内容到linux新建的文件里面,然后给权限然后执行
相关文章推荐
- Linux Shell脚本测试案例(三)
- Linux Shell 脚本全面学习
- 思维导图学 Linux Shell攻略之干货篇 mysql数据库脚本管理系统
- linux shell脚本攻略 学习笔记2 -- 第二章 命令之乐
- 使用linux shell脚本备份
- linux shell脚本中如何自由操作字符串(转)
- Linux Shell脚本教程(LSST)---Linux是什么
- Linux shell脚本(2)
- linux shell脚本编程之hello world
- linux shell下执行mysql脚本
- Linux Shell脚本攻略学习总结:三
- Linux Shell脚本应用——使用case分支
- Linux shell脚本判断输入目录是否存在,并输出目录所在磁盘使用量
- linux shell编程指南第二十七章------几个脚本例子
- linux shell ftp脚本自动上传脚本
- 运维经验分享(二)-- Linux Shell之ChatterServer服务控制脚本二次优化
- linux shell 脚本自动从配置远程ftp服务上下载更新文件
- Linux shell脚本中调用另一个shell(exec、source、fork)
- linux shell 脚本攻略学习9--rename命令详解
- linux shell脚本快速入门