1、SHELL编程作业&剖析演练
1)SHELL编程Nginx虚拟主机脚本;
 安装Nginx WEB平台;
 配置虚拟主机(1个网站);
 重启&加载配置文件;
 配置hosts,虚拟主机访问测试;
v1.jfedu.net
v2.jfedu.net
#!/bin/bash
#2019年7月3日20::
#auto config nginx vhosts.
#by author www.jfedu.net
########################
NGX_VER="$1"
NGX_VHOST="$2"
NGX_YUM="yum install -y"NGX_SRC="nginx-$NGX_VER"
NGX_DIR="/usr/local/nginx"
NGX_SOFT="nginx-${NGX_VER}.tar.gz"
NGX_ARGS="--user=www --group=www"
NGX_URL="http://nginx.org/download"
#Install Nginx WEB
$NGX_YUM wget make tar gzip
$NGX_YUM gcc pcre-devel zlib-devel
wget -c $NGX_URL/$NGX_SOFT
tar xzf $NGX_SOFT
cd $NGX_SRC
useradd -s /sbin/nologin www -M
./configure --prefix=$NGX_DIR $NGX_ARGS
make
make install
$NGX_DIR/sbin/nginx
ps -ef|grep nginx
netstat -tnlp|
setenforce
systemctl stop firewalld.service
#Config Nginx Virtual Hosts.
echo "worker_processes 1;
events {
worker_connections ;
}
http {
include
mime.types;
default_type application/octet-stream;
sendfile
on;
keepalive_timeout ;
include domains/*;
}
">$NGX_DIR/conf/nginx.conf
mkdir -p $NGX_DIR/conf/domains/
cd $NGX_DIR/conf/domains/
echo "
server {
listen
80;
server_name ${NGX_VHOST};
access_log logs/${NGX_VHOST}.access.log;
location / {
root
html/${NGX_VHOST};
index index.html index.htm;}
}
">${NGX_VHOST}
mkdir -p $NGX_DIR/html/${NGX_VHOST}
cd $NGX_DIR/html/${NGX_VHOST}/
echo "
<html>
<h1>Hostname:$HOSTNAME $NGX_VHOST Test Pages.</h1>
<hr color=red>
</html>
">index.html
$NGX_DIR/sbin/nginx -s reload
2)SHELL编程LNMP一键部署脚本;(Nginx1.16+MYSQL5.6+PHP5.6)
 安装Nginx WEB服务;
 安装MYSQL数据库服务;
 安装PHP FPM模块服务;
 配置Nginx Server主机&整合PHP-FPM(9000);
 创建phpinfo测试页面,通过浏览器访问;
#!/bin/bash
#2019年7月3日18::
#auto install lnmp web.
#by author www.jfedu.net
######################
#Install Nginx WEB.
wget -c http://nginx.org/download/nginx-1.16.0.tar.gz
.tar.gz
cd nginx-
yum install -y pcre-devel gcc make
useradd -s /sbin/nologin www -M
./configure --user=www --group=www --prefix=/usr/local/nginx
make && make install
/usr/local/nginx/sbin/nginx
setenforce
systemctl stop firewalld.service#Install MYSQL Database.
cd ../
yum install cmake ncurses-devel ncurses -y
wget -c
http://mirrors.163.com/mysql/Downloads/MySQL-5.6/mysql-5.6.43.tar.
gz
.tar.gz
cd mysql-
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql56/ \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DMYSQL_DATADIR=/data/mysql \
-DSYSCONFDIR=/etc \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT= \
-DWITH_XTRADB_STORAGE_ENGINE= \
-DWITH_INNOBASE_STORAGE_ENGINE= \
-DWITH_PARTITION_STORAGE_ENGINE= \
-DWITH_BLACKHOLE_STORAGE_ENGINE= \
-DWITH_MYISAM_STORAGE_ENGINE= \
-DWITH_READLINE= \
-DENABLED_LOCAL_INFILE= \-DWITH_EXTRA_CHARSETS= \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DWITH_BIG_TABLES= \
-DWITH_DEBUG=
make
make install
#Config MYSQL Set System Service
cd /usr/local/mysql56/
\cp support-files/my-large.cnf /etc/my.cnf
\cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level  mysqld on
mkdir -p /data/mysql
useradd mysql
/usr/local/mysql56/scripts/mysql_install_db --user=mysql
--datadir=/data/mysql/ --basedir=/usr/local/mysql56/
ln -s /usr/local/mysql56/bin/* /usr/bin/
service mysqld restart
#Install PHP WEB 2018cd ../../
yum install libxml2 libxml2-devel -y
wget http://mirrors.sohu.com/php/php-5.6.28.tar.bz2
tar jxf php-5.6.28.tar.bz2
cd php-5.6.28
./configure --prefix=/usr/local/php5
--with-config-file-path=/usr/local/php5/etc
--with-mysql=/usr/local/mysql56/ --enable-fpm
make
make install
#Config LNMP WEB and Start Server.
cp php.ini-development
/usr/local/php5/etc/php.ini
cp /usr/local/php5/etc/php-fpm.conf.default
/usr/local/php5/etc/php-fpm.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod o+x /etc/init.d/php-fpm
/etc/init.d/php-fpm start
echo "
worker_processes 1;
events {
worker_connections 1024;}
http {
include
mime.types;
default_type application/octet-stream;
sendfile
on;
keepalive_timeout 65;
server {
listen
80;
server_name localhost;
location / {
root
html;
fastcgi_pass
127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
\$document_root\$fastcgi_script_name;
include
fastcgi_params;
}
}
}" >/usr/local/nginx/conf/nginx.conf
echo "
<?phpphpinfo();
?>">/usr/local/nginx/html/index.php
/usr/local/nginx/sbin/nginx -s reload

SHELL用法二(练习)的更多相关文章

  1. Linux编程 9 (shell类型,shell父子关系,子shell用法)

    一. shell类型 1.1  交互式 bin/ shell程序 当用户登录到某个虚拟控制台终端或是在GUI中启动终端仿真器时,默认的shell程序就会开始运行.系统启动什么样的shell程序取决于你 ...

  2. 【转载】Jmeter之Bean shell使用(二)

    Jmeter之Bean shell使用(二) 原博文地址为:https://www.cnblogs.com/puresoul/p/4949889.html 其中需要注意的是——三.自定义函数中Bean ...

  3. shell基础二十篇 一些笔记

    shell基础二十篇 转自 http://bbs.chinaunix.net/thread-452942-1-1.html 研讨:Bash 内建命令 read (read命令更具体的说明见博客收藏的一 ...

  4. react基础用法二(组件渲染)

    react基础用法二(组件渲染) 如图所示组件可以是函数 格式:function 方法名(){ return <标签>内容</标签>} 渲染格式: <方法名 />  ...

  5. Linux 反弹shell(二)反弹shell的本质

    Linux 反弹shell(二)反弹shell的本质 from:https://xz.aliyun.com/t/2549 0X00 前言 在上一篇文章 Linux反弹shell(一)文件描述符与重定向 ...

  6. 转 Jmeter之Bean shell使用(二)

    上一篇Jmeter之Bean shell使用(一)简单介绍了下Jmeter中的Bean shell,本文是对上文的一个补充,主要总结下常用的几种场景和方法,相信这些基本可以涵盖大部分的需求.本节内容如 ...

  7. Jmeter之Bean shell使用(二)

    上一篇Jmeter之Bean shell使用(一)简单介绍了下Jmeter中的Bean shell,本文是对上文的一个补充,主要总结下常用的几种场景和方法,相信这些基本可以涵盖大部分的需求.本节内容如 ...

  8. 转:Jmeter之Bean shell使用(二)

    上一篇Jmeter之Bean shell使用(一)简单介绍了下Jmeter中的Bean shell,本文是对上文的一个补充,主要总结下常用的几种场景和方法,相信这些基本可以涵盖大部分的需求.本节内容如 ...

  9. 【jmeter】Bean shell使用(二)

    上一篇Jmeter之Bean shell使用(一)简单介绍了下Jmeter中的Bean shell,本文是对上文的一个补充,主要总结下常用的几种场景和方法,相信这些基本可以涵盖大部分的需求.本节内容如 ...

随机推荐

  1. h5-携程页面小案例-伸缩盒子

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. CSS 之pseudo-classes 与pseudo-element的异同

    从W3School找到相关资料如下: 伪类: 伪类存在的意义是为了通过选择器找到那些不存在与DOM树中的信息以及不能被常规CSS选择器获取到的信息. 伪类由一个冒号:开头,冒号后面是伪类的名称和包含在 ...

  3. Python笔记_第一篇_面向过程_第一部分_9.Ubuntu基础操作

    第一部分   Ubuntu简介 Ubuntu(乌班图)是一个机遇Debian的以桌面应用为主的Linux操作系统,据说其名称来自非洲南部祖鲁语或科萨语的“Ubuntu”一词,意思是“人性”.“我的存在 ...

  4. gulp自动化添加版本号并修改为参数格式

    问题: 当我们修改js和css文件时往往需要清除浏览器的缓存,否则有些效果就看不到更新过后的. 通过对js,css文件内容进行hash运算,生成一个文件的唯一hash字符串(如果文件修改则hash号会 ...

  5. jest 测试入门(一)

    说实话,作为前端来说,单元测试,并不是一种必须的技能,但是确实一种可以让你加法的技能 之前我一个库添加了单元测试,加完之后感悟颇深,所以写下这篇文章来记录 环境搭建 一般来说,普通的库,如果没有添加 ...

  6. GO、 智能合约、cannot use transactionRecordId + strconv.Itoa(id) (type string) as type byte in append

    1.报错详情 2.在写fabric go智能合约发送的错误,像我这样的新手就是踩坑踩坑踩坑 3.下面是代码片段 4.研究了一下append用法.也看了下GO语言官网文章: var test_str [ ...

  7. Python常见经典

    python中if __name__ == '__main__': 的解析 当你打开一个.py文件时,经常会在代码的最下面看到if __name__ == '__main__':,现在就来介 绍一下它 ...

  8. DataSet,DataTable排序(转载)

    DataSet,DataTable排序   关于对已经绑定的DataSet的排序的问题: DataSet ds=new DataSet();DataView dv=new DataView();dv. ...

  9. hibernate 持久化对象 save

    hibernate 持久化对象 save new出来的user对象是游离状态的对象,执行session.save()方法保存后,user对象就变为持久化了,持久化的对象跟数据库表双向绑定的意思, 对象 ...

  10. 吴裕雄--天生自然python学习笔记:python 用pygame模块基本绘图

    绘制几何图形是游戏包的基本功能,很多游戏角色都是由基本图形组合而成的 . 绘制矩形: pygame.draw.rect Pygam巳绘制矩形的语法为: 用基本绘图绘制一个人脸 用基本绘图功能绘制人脸 ...